How do I attach `gdb` and/or `valgrind` to the tes...
# general
r
How do I attach
gdb
and/or
valgrind
to the test process when running
./pants test
? Is there any recommended way?
I'm going to debug a potential memory corruption caused by one of our 3rd-party native module dependencies
Just running
gdb --args ./pants test --debug ...
does not work because
pants
is a script not an executable (obviously!)
Probably I need to figure out which Python interpreter that
./pants
script detects and selects, and mimic all the arguments passed to it, but I think this will be just the pants itself not the Python process that actually runs pytest.
It would be great if we have a simpler way to "inject" invocation of
gdb
or
valgrind
when running a specific target.
It seems to be possible that I can "attach" the pytest process in gdb, but I'm not sure that how this would affect the Pants engine.
b
Two things: •
test
and
run
now have
--debug-adapter
flag which if supported launches the relevant debug adapter. In this case though it's be launching the Python one, and not a native one (although that support could be added, but less useful in most cases) • You probably wanna run
./pants --no-proccess-cleanup test --force ...
And use the sandbox to run
gdb ...
f
Another solution could be to allow injecting a “prefix” to any process invocation. For the immediate issue, if you are willing to edit a copy of the pants sources, you could just hard code what you want and invoke Pants using the checked out copy of Pants.