Hello, I'm having a problem running gdb on a threadbased
application.
The application is running inside uml, with pid 765. UML is
running on
the same physical machine as I'm debugging from.
Status is this:
On the target (uml) side I do the following, to start
gdbserver:
$ gdbserver 172.16.254.1:2024 --attach 765
Attached; pid = 765
Listening on port 2024
Remote debugging from host 172.16.254.1
On the host side, I then start gdb and do the following:
set solib-search-path usr/local/...
target remote 172.16.254.2:2024
Remote debugging using 172.16.254.2:2024
0xffffe410 in ?? ()
[Thread debugging using libthread_db enabled]
[New Thread 1076389568 (LWP 765)]
Can't attach LWP 765: No such process
(gdb)
(gdb) bt
#0 0xffffe410 in ?? ()
#1 0xbf502568 in ?? ()
2 0x0000081c in ?? ()
#3 0xbf501d34 in ?? ()
#4 0x4004556b in __read_nocancel () from
/lib/tls/i686/cmov/libpthread.so.0
#5 0x40026a24 in Msg__Wait (pMsgQue=0x8502d00,
ePreemptive=NON_PREEMPTIVE)
at /home/a8648/src/oms.svn/main/basic/ipc/msg.c:235
#6 0x0804ad51 in main (argc=1, argv=0xbf502644)
at /home/a8648/src/oms.svn/main/mpls/rcim/rcim.c:259
(gdb) bt
#0 0xffffe410 in ?? ()
#1 0xbf502568 in ?? ()
#2 0x0000081c in ?? ()
#3 0xbf501d34 in ?? ()
#4 0x4004556b in __read_nocancel () from
/lib/tls/i686/cmov/libpthread.so.0
#5 ... <properly resolved functions>
(gdb) n
Cannot find bounds of current function
(gdb) c
Continuing.
0xffffe410 in ?? ()
ptrace: No such process.
I thought the "Can't attach LWP 765: No such
process" errormessage was
something read from the target host, but I strace(1)-ed
gdbserver on
the target without seeing any errormessages.
I then straced gdb on the host, and see that gdb on the host
connects
to target, and then seems to write a bunch of instructions
to gdbserver
on target:
connect(6, {sa_family=AF_INET, sin_port=htons(2024),
sin_addr=inet_addr("172.16.254.2")}, 16) = -1
EINPROGRESS (Operation now in progress)
...
send(6, "+", 1, 0) = 1
send(6, "$Hc-1#09", 8, 0) = 8
...
This is as I would expect.
Then the same gdb on host starts doing ptrace(2) calls,
which I did
not expect:
ptrace(PTRACE_PEEKUSER, 1076389568, offsetof(struct user,
u_debugreg) +
24, [0xb
7eee320]) = -1 ESRCH (No such process)
write(1, "[Switching to thread 1076389568]"...,
33) = 33
igprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
send(6, "$mffffe410,8#63", 15, 0) = 15
select(7, [6], NULL, [6], {1, 0}) = 1 (in [6], left
{1, 0})
...
write(1, "[Thread debugging using libthrea"...,
46) = 46
ptrace(PTRACE_PEEKTEXT, 1076389568, 0x40047cb0,
[0xb7e253b4]) = -1 ESRCH
(No such process)
send(6, "$m40047cb0,4#c1", 15, 0) = 15
select(7, [6], NULL, [6], {1, 0}) = 1 (in [6], left
{1, 0})
recv(6, "+$08000000#88", 8192, 0) = 13
send(6, "+", 1, 0) = 1
ptrace(PTRACE_PEEKTEXT, 1076389568, 0x4004c52c,
[0xbfaacd30]) = -1 ESRCH
(No such process)
send(6, "$m4004c52c,8#c6", 15, 0) = 15
select(7, [6], NULL, [6], {1, 0}) = 1 (in [6], left
{1, 0})
recv(6, "+$8001000000000000#09", 8192, 0) = 21
send(6, "+", 1, 0) = 1
open("/proc/1076389568/mem", O_RDONLY _LARGEFIL
E) = -1 ENOENT (No such
file or
directory)
ptrace(PTRACE_PEEKTEXT, 1076389568, 0x40047ca4, [0]) = -1
ESRCH (No such process
)
ptrace(PTRACE_ATTACH, 765, 0, 0) = -1 ESRCH (No such
process)
I don't know why gdb on host is calling ptrace(2) at all.
Thanks for any help,
--
_ //
X/ -- Michael Shuldman <michael.shuldman ericsson.com>
|