This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug remote/10606] New: gdb/gdbserver hangs when trying to single step over pthread_create() (target: 2.6.30/powerpc)


Hi,

--- Setup ---
Kernel: 2.6.30 (Debian)
gdb/gdbserver: 6.8
gcc: 4.1 (Debian)
Target: powerpc32
Host: x86


--- Problem ---
Single-stepping over pthread_create() in the test application (see below)
causes gdb to hang because gdbserver stays in an infinite while() loop in
linux-low.c: linux_wait_for_process(). Everything works just _fine_ on 
2.6.26 (Debian) though! 
To me it seems that waitpid() on the newly created child doesn't return
anything useful which causes gdbserver to stay inside that while() loop.


--- Test Application ---
#include <sys/mman.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <pthread.h>

pthread_t   first_task;
pthread_t   second_task;

const char n1[] = "first";
const char n2[] = "second";

void* second_task_body(void* cookie)
{
    while(1) {
        printf("Info: In %s task\n", (char*)cookie);
        sleep(1);
    }

    return NULL;
}

void* first_task_body(void* cookie)
{
    int err = pthread_create(&second_task, NULL,
                             second_task_body, (void*)n2);
    while(!err) {
        printf("Info: In %s task\n", (char*)cookie);
        sleep(1);
    }

    return NULL;
}

int main(void)
{
    int err;

    err = pthread_create(&first_task, NULL,
                         first_task_body, (void*)n1);
    if(!err) {
        while(1) {
            printf("Info: In linux task\n");
            sleep(1);
        }
    }
    return err;
}


--- Build instructions ---

powerpc-linux-gnu-gcc -Wall -O0 -g -o main -lpthread main.c

--- Gdbserver invocation on target (powerpc) ---

./gdbserver --multi :2345 &

--- gdbinit file for gdb running on x86 ---

# Connect to the remote target
target extended-remote 10.200.19.138:2345

monitor set debug 1

# Copy 'main' to remote target
remote put out/main /tmp/main

# Load symbol table
file out/main

# Set 'main' as main executable
set remote exec-file /tmp/main

# Set breakpoints
b main
b first_task_body

--- Output of gdb on the host ---

andreasglatz@andreasglatz:~$ powerpc-linux-gnu-gdb -x gdbinit_ROX_MPC83XX_hu 
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i486-linux-gnu --target=powerpc-linux-gnu".
Debug output enabled.
Breakpoint 1 at 0x1000070c: file main.c, line 82.
Breakpoint 2 at 0x10000680: file main.c, line 55.
(gdb) run
Starting program: /home/andreasglatz/ROX-RCLib/ROX-RCLibrary/ROX-MPC83XX/out/main 
[New Thread 3054]
warning: .dynamic section for "/usr/powerpc-linux-gnu/lib/libgcc_s.so.1" is not
at the expected address (wrong library or version mismatch?)
[Switching to Thread 3054]

Breakpoint 1, main () at main.c:82
82		err = pthread_create(&first_task, NULL, 
(gdb) c
Continuing.
[New Thread 3056]
[Switching to Thread 3056]

Breakpoint 2, first_task_body (cookie=0x10010d80) at main.c:55
55								 second_task_body, (void*)n2);
(gdb) s <<<<<< !!!This instruction causes the FREEZE!!! >>>>>>>>>>>

--- Output of pstree -p on the target ---

...
        |-gdbserver(2952)---main(3054)-+-{main}(3056)
        |                              `-{main}(3057)
...

--- Last lines of debug output of gdbserver on the target (single-step) ---

Writing 7d to 4800fa40
Writing 7d to 1000070c
Writing 7d to 10000680
Resuming, no pending status
Resuming process 3054 (continue, signal 0, stop not expected)
  Resuming process 3056 (step, signal 0, stop not expected)
  Got an event from 3056 (57f)
Hit a non-gdbserver breakpoint.
Sending sigstop to process 3054
Got an event from 3054 (137f)
Writing resume reply for 3056

Resuming, no pending status
Resuming process 3054 (continue, signal 0, stop not expected)
  Resuming process 3056 (step, signal 0, stop not expected)
  Got an event from 3056 (57f)
Hit a non-gdbserver breakpoint.
Sending sigstop to process 3054
Got an event from 3054 (137f)
Writing resume reply for 3056

Resuming, no pending status
Resuming process 3054 (continue, signal 0, stop not expected)
  Resuming process 3056 (step, signal 0, stop not expected)
  Got an event from 3056 (57f)
Hit a non-gdbserver breakpoint.
Sending sigstop to process 3054
Got an event from 3054 (137f)
Writing resume reply for 3056

Resuming, no pending status
Resuming process 3054 (continue, signal 0, stop not expected)
  Resuming process 3056 (step, signal 0, stop not expected)
  Got an event from 3056 (57f)
Hit a non-gdbserver breakpoint.
Sending sigstop to process 3054
Got an event from 3054 (137f)
Writing resume reply for 3056

Resuming, no pending status
Resuming process 3054 (continue, signal 0, stop not expected)
  Resuming process 3056 (step, signal 0, stop not expected)
  Got an event from 3056 (57f)
Hit a non-gdbserver breakpoint.
Sending sigstop to process 3054
Got an event from 3054 (137f)
Writing resume reply for 3056

Resuming, no pending status
Resuming process 3054 (continue, signal 0, stop not expected)
  Resuming process 3056 (step, signal 0, stop not expected)
  Got an event from 3056 (57f)
Hit a non-gdbserver breakpoint.
Sending sigstop to process 3054
Got an event from 3054 (137f)
Writing resume reply for 3056

Resuming, no pending status
Resuming process 3054 (continue, signal 0, stop not expected)
  Resuming process 3056 (step, signal 0, stop not expected)
  Got an event from 3056 (57f)
Hit a non-gdbserver breakpoint.
Sending sigstop to process 3054
Got an event from 3054 (137f)
Writing resume reply for 3056

Writing 7d to 100006a0
Resuming, no pending status
Resuming process 3054 (continue, signal 0, stop not expected)
  Info: In linux task
Resuming process 3056 (continue, signal 0, stop not expected)
  Got an event from 3057 (137f)
Got an event from 3056 (3057f)
Resuming process 3056 (continue, signal 0, stop not expected)
  Got an event from 3056 (57f)
Hit a non-gdbserver breakpoint.
Sending sigstop to process 3054
Have pending sigstop for process 3057
Got an event from 3054 (137f)

---------------------------

We _really_ need a working gdbserver for the new kernel. 
Any help (and if that's just an explanation why this shouldn't 
work) is appreciated!

Regards, Andreas

-- 
           Summary: gdb/gdbserver hangs when trying to single step over
                    pthread_create() (target: 2.6.30/powerpc)
           Product: gdb
           Version: 6.8
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: remote
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: andreasglatz at ruggedcom dot com
                CC: gdb-prs at sourceware dot org
  GCC host triplet: i486-linux-gnu
GCC target triplet: powerpc-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=10606

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]