Running a program through gdb without "interfering"

Nate Eldredge nate at thatsmathematics.com
Fri Oct 9 17:30:48 UTC 2009


On Fri, 9 Oct 2009, Mel Flynn wrote:

> On Friday 09 October 2009 11:38:29 Dag-Erling Smørgrav wrote:
>> Mel Flynn <mel.flynn+fbsd.hackers at mailing.thruhere.net> writes:
>>> is there a way to have a program run through gdb and gdb only record a
>>> segfault, but otherwise let the program run?
>>
>> Yes, just run "gdb /path/to/program" and type "run".
>
> Not what I was looking for. The segfaults are random and the only way to
> somewhat reliably reproduce it is to have portmaster invoke it as it's
> PM_SU_CMD. And no, running that same command again doesn't trigger the
> segfault, so it's "something environmental". Hence I'm looking for something
> like:
> gdb -batch -x script_with_run_cmd.gdb -exec /usr/local/bin/sudo $argv
>
> where somehow I need $argv to be passed as arguments to sudo. I'm thinking i
> should just wrap it and mktemp(1) a new command script for gdb to use with set
> args $*, but if anyone has a more clever idea, I'd love to hear it.

This won't work.  You can't debug setuid programs (for reasons which 
should be obvious).  You could do it if you ran everything as root, but it 
sounds like the bug doesn't occur in that case.

-- 

Nate Eldredge
nate at thatsmathematics.com


More information about the freebsd-hackers mailing list