[non-stop] 02/10 Don't trim ptids on fork/exec

Pedro Alves pedro@codesourcery.com
Sun Jun 15 21:04:00 GMT 2008


With the previous patch installed, we hit an assertion inside
is_running on the follow-* tests.  Here is a backtrace:

#0  internal_error (file=0x830eadf "../../src/gdb/thread.c", line=515, 
string=0x830eac1 "%s: Assertion `%s' failed.")
    at ../../src/gdb/utils.c:817
#1  0x08142650 in is_executing (ptid={pid = 13049, lwp = 0, tid = 0}) 
at ../../src/gdb/thread.c:515
#2  0x08140dc3 in get_selected_block (addr_in_block=0x0) 
at ../../src/gdb/stack.c:1647
#3  0x0812df2a in decode_objc (argptr=0xffe590fc, funfirstline=1, 
file_symtab=0x0, canonical=0x0,
    saved_arg=0x8438088 "main") at ../../src/gdb/linespec.c:1125
#4  0x0812d691 in decode_line_1 (argptr=0xffe590fc, funfirstline=1, 
default_symtab=0x0, default_line=0,
    canonical=0x0, not_found_ptr=0xffe59104) at ../../src/gdb/linespec.c:746
#5  0x080f6e96 in breakpoint_re_set_one (bint=0x84382b0) 
at ../../src/gdb/breakpoint.c:7435
#6  0x08143ff8 in catch_errors (func=0x80f6d71 <breakpoint_re_set_one>, 
func_args=0x84382b0,
    errstring=0x84143d8 "Error in re-setting breakpoint 1: ", mask=6) 
at ../../src/gdb/exceptions.c:509
#7  0x080f710e in breakpoint_re_set () at ../../src/gdb/breakpoint.c:7577
#8  0x08128255 in clear_symtab_users () at ../../src/gdb/symfile.c:2837
#9  0x08124d75 in new_symfile_objfile (objfile=0x851e508, mainline=1, verbo=0) 
at ../../src/gdb/symfile.c:978
#10 0x081250f1 in symbol_file_add_with_addrs_or_offsets (abfd=0x848e700, 
from_tty=0, addrs=0x0, offsets=0x0,
    num_offsets=0, mainline=1, flags=0) at ../../src/gdb/symfile.c:1137
#11 0x08125149 in symbol_file_add_from_bfd (abfd=0x848e700, from_tty=0, 
addrs=0x0, mainline=1, flags=0)
    at ../../src/gdb/symfile.c:1156
#12 0x08125182 in symbol_file_add (
    
name=0x84662c8 "/home/pedro/gdb/nonstop_head/build-32/gdb/testsuite/gdb.base/execd-prog", 
from_tty=0, addrs=0x0,
    mainline=1, flags=0) at ../../src/gdb/symfile.c:1169
#13 0x081251d5 in symbol_file_add_main_1 (
    
args=0x84662c8 "/home/pedro/gdb/nonstop_head/build-32/gdb/testsuite/gdb.base/execd-prog", 
from_tty=0, flags=0)
    at ../../src/gdb/symfile.c:1191
#14 0x081251a4 in symbol_file_add_main (
    
args=0x84662c8 "/home/pedro/gdb/nonstop_head/build-32/gdb/testsuite/gdb.base/execd-prog", 
from_tty=0)
    at ../../src/gdb/symfile.c:1185
#15 0x08135152 in follow_exec (pid=13049,
    
execd_pathname=0x84662c8 "/home/pedro/gdb/nonstop_head/build-32/gdb/testsuite/gdb.base/execd-prog")
    at ../../src/gdb/infrun.c:423
#16 0x08137078 in handle_inferior_event (ecs=0xffe59490) 
at ../../src/gdb/infrun.c:1935

The issue is that the thread module should never see an inferior_ptid
not listed in the thread list if there are threads in the thread
list.  We accept that an ptid is not listed iff there are no
threads listed, so targets that don't yet register the main
thread in the thread/task list continue working.

Now, the assert triggers, because, across an exec and a fork, we're
transfering a ptid to the core with only that has the pid member filled.
A problem similar to the other crash across an exec when doing an
"info thread" we just fixed recently (execl.exp).

From infrun.c:handle_inferior_event:

(gdb)
1923
1924        case TARGET_WAITKIND_EXECD:
1925          if (debug_infrun)
1926            fprintf_unfiltered (gdb_stdlog, "infrun: 
TARGET_WAITKIND_EXECD\n");
1927          stop_signal = TARGET_SIGNAL_TRAP;
1928
1929          pending_follow.execd_pathname =
1930            savestring (ecs->ws.value.execd_pathname,
1931                        strlen (ecs->ws.value.execd_pathname));
1932
(gdb)
1933          /* This causes the eventpoints and symbol table to be reset.  
Must
1934             do this now, before trying to determine whether to stop. */
1935          follow_exec (PIDGET (inferior_ptid), 
pending_follow.execd_pathname);
1936          xfree (pending_follow.execd_pathname);

The fix is to not trim the ptids the targets report.

The patch touches inf-ttrace.c to adapt to the new interface, but
unfortunatelly, I have no HPUX access to test it.  If someone
could do a spin there for me, it would be really appreciated.

win32-nat.c was also touched.  I've tested the whole series
on cygwin, although this hunk in question should be obvious --
related_pid is not used at all in either cygwin or mingw32, so
setting it is a nop really -- it is only defined on on
TARGET_WAITKIND_FORK|EXEC, but we don't support those on cygwin
or mingw.

-- 
Pedro Alves
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 002-fork_exec_ptid.diff
Type: text/x-diff
Size: 14640 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20080615/685a930c/attachment.bin>


More information about the Gdb-patches mailing list