2008-03-18 Pedro Alves gdb/ * linux-nat.c (linux_child_follow_fork): Update inferior_ptid with the thread id. gdb/testsuite/ gdb.threads/fork-child-threads.exp: Add "next" test. --- gdb/linux-nat.c | 9 +++++++++ gdb/testsuite/gdb.threads/fork-child-threads.exp | 1 + 2 files changed, 10 insertions(+) Index: src/gdb/testsuite/gdb.threads/fork-child-threads.exp =================================================================== --- src.orig/gdb/testsuite/gdb.threads/fork-child-threads.exp 2008-03-18 18:31:12.000000000 +0000 +++ src/gdb/testsuite/gdb.threads/fork-child-threads.exp 2008-03-18 18:31:53.000000000 +0000 @@ -38,6 +38,7 @@ if ![runto_main] then { gdb_test "set follow-fork-mode child" gdb_breakpoint "start" +gdb_test "next" ".*pthread_create \\(&thread, NULL, start, NULL\\);.*" "next over fork" gdb_test "continue" "Breakpoint 2, start.*" "get to the spawned thread" # Wrong: Index: src/gdb/linux-nat.c =================================================================== --- src.orig/gdb/linux-nat.c 2008-03-18 20:25:45.000000000 +0000 +++ src/gdb/linux-nat.c 2008-03-18 20:26:04.000000000 +0000 @@ -104,6 +104,8 @@ static LONGEST (*super_xfer_partial) (st const gdb_byte *, ULONGEST, LONGEST); +static int find_thread_from_lwp (struct thread_info *thr, void *dummy); + static int debug_linux_nat; static void show_debug_linux_nat (struct ui_file *file, int from_tty, @@ -460,6 +462,7 @@ linux_child_follow_fork (struct target_o else { char child_pid_spelling[40]; + struct thread_info *thr; /* Needed to keep the breakpoint lists in sync. */ if (! has_vforked) @@ -519,6 +522,12 @@ linux_child_follow_fork (struct target_o linux_nat_switch_fork (inferior_ptid); check_for_thread_db (); + /* Update inferior_ptid to include the thread id, so updating + step-resume breakpoints in the child works. */ + thr = iterate_over_threads (find_thread_from_lwp, &inferior_ptid); + if (thr) + inferior_ptid = thr->ptid; + /* Reset breakpoints in the child as appropriate. */ follow_inferior_reset_breakpoints (); }