truss

Anton Yuzhaninov citrin at citrin.ru
Tue Sep 20 13:20:02 UTC 2011


On Tue, 20 Sep 2011 00:27:22 +0300, Kostik Belousov wrote:
>> With this patch truss works for me:
>> 
>> --- usr.bin/truss/main.c        (revision 225504)
>> +++ usr.bin/truss/main.c        (working copy)
>> @@ -255,6 +255,11 @@ main(int ac, char **av)
>> 
>>         if (trussinfo->pid == 0) {      /* Start a command ourselves */
>>                 command = av;
>> +               /*
>> +                * SIGTRUP used to stop traced process after execve
>> +                * un-ignore this signal (it can be ignored by parents)
>> +                */
>> +               signal(SIGTRAP, SIG_DFL);
>>                 trussinfo->pid = setup_and_wait(command);
>>                 signal(SIGINT, SIG_IGN);
>>                 signal(SIGTERM, SIG_IGN);
KB> This is quite a hack. The proper fix should go in kernel, otherwise
KB> we cannot debug programs that decided to ignore SIGTRAP. The reason

It seems to be, that in gdb used similar hack:

citrin:~> procstat -i 2433 | fgrep TRAP
 2433 dd               TRAP     -I-

:~> gdb /bin/dd 2433
...
(gdb) next
Single stepping until exit from function write,
which has no line number information.
dd_out (force=1) at dd.c:458
458                             if (nw <= 0) {
(gdb)
...

:~> procstat -i 2433 | fgrep TRAP
 2433 dd               TRAP     ---

KB> Could you, please, test the change below ? For me, I still can truss(1)
KB> or debug with gdb after the change applied. Does truss work for you
KB> with only this change, without resetting SIGTRAP handler in truss process ?

I'll test this patch.

-- 
 Anton Yuzhaninov



More information about the freebsd-current mailing list