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 breakpoints/17134] New: Can't step in static app after attaching to running process


https://sourceware.org/bugzilla/show_bug.cgi?id=17134

            Bug ID: 17134
           Summary: Can't step in static app after attaching to running
                    process
           Product: gdb
           Version: 7.7
            Status: NEW
          Severity: normal
          Priority: P2
         Component: breakpoints
          Assignee: unassigned at sourceware dot org
          Reporter: ks132 at yandex dot ru

Overview:
gdb hangs in single stepping

Steps to Reproduce:

:~$ cat test.cpp 
#include <netdb.h>
#include <unistd.h>

void foo() {}

int main() {
    getservbyname("daytime", "tcp");

    while (true) {
        foo();
        sleep(1);
    }

    return 0;
}
:~$ 
:~$ g++ test.cpp -g -static
/tmp/ccSdBZq8.o: In function `main':
/home/asemenov/test.cpp:7: warning: Using 'getservbyname' in statically linked
applications requires at runtime the shared libraries from the glibc version
used for linking
:~$ 
:~$ ./a.out & sudo gdb -p `pgrep a.out`
[1] 4241
GNU gdb (GDB) 7.7.1
Copyright (C) 2014 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 "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Attaching to process 4241
Reading symbols from /home/asemenov/a.out...done.
Reading symbols from /lib/x86_64-linux-gnu/libnss_files.so.2...(no debugging
symbols found)...done.
Loaded symbols for /lib/x86_64-linux-gnu/libnss_files.so.2
Reading symbols from /lib/x86_64-linux-gnu/libc.so.6...(no debugging symbols
found)...done.
Loaded symbols for /lib/x86_64-linux-gnu/libc.so.6
Reading symbols from /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2...(no debugging
symbols found)...done.
Loaded symbols for /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
0x000000000040efb0 in __nanosleep_nocancel ()
(gdb) s
Single stepping until exit from function __nanosleep_nocancel,
which has no line number information.


Additional Information:
The above step test passes either:
1) remove static linking when building test
2) don't use attach, run test inside gdb

According to backtrace, gdb enters infinite loop in wait_for_inferior():

(gdb) bt
#0  0x00007fea546d477a in sigsuspend () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x0000000000499767 in linux_nat_wait_1 (target_options=0,
ourstatus=0x7fff146e1b50, ptid=..., ops=<optimized out>) at linux-nat.c:3441
#2  linux_nat_wait (ops=<optimized out>, ptid=..., ourstatus=0x7fff146e1b50,
target_options=0) at linux-nat.c:3677
#3  0x00000000005cbc55 in target_wait (ptid=..., status=0x7fff146e1b50,
options=0) at target.c:2662
#4  0x0000000000594662 in wait_for_inferior () at infrun.c:2765
#5  0x00000000005948f5 in proceed (addr=<optimized out>,
siggnal=GDB_SIGNAL_DEFAULT, step=1) at infrun.c:2331
#6  0x0000000000585bd1 in step_once (skip_subroutines=0, single_inst=0,
count=1, thread=1) at infcmd.c:1090
#7  0x0000000000586f2a in step_1 (skip_subroutines=0, single_inst=0,
count_string=0x0) at infcmd.c:920
#8  0x000000000066511d in execute_command (p=<optimized out>, from_tty=1) at
top.c:468
#9  0x00000000005a98b5 in command_handler (command=0x14c5150 "s") at
event-top.c:435
#10 0x00000000005aa32c in command_line_handler (rl=<optimized out>) at
event-top.c:632
#11 0x00000000006ac399 in rl_callback_read_char () at callback.c:220
#12 0x00000000005a9929 in rl_callback_read_char_wrapper (client_data=<optimized
out>) at event-top.c:164
#13 0x00000000005a8b23 in process_event () at event-loop.c:342
#14 process_event () at event-loop.c:314
#15 0x00000000005a8ee8 in gdb_do_one_event () at event-loop.c:406
#16 0x00000000005a9085 in start_event_loop () at event-loop.c:431
#17 0x00000000005a2553 in captured_command_loop (data=<optimized out>) at
main.c:267
#18 0x00000000005a0adb in catch_errors (func=0x5a2540 <captured_command_loop>,
func_args=0x0, errstring=0x76f610 "", mask=RETURN_MASK_ALL) at exceptions.c:524
#19 0x00000000005a2ed6 in captured_main (data=<optimized out>) at main.c:1067
#20 0x00000000005a0adb in catch_errors (func=0x5a2860 <captured_main>,
func_args=0x7fff146e20e0, errstring=0x76f610 "", mask=RETURN_MASK_ALL) at
exceptions.c:524
#21 0x00000000005a37f4 in gdb_main (args=<optimized out>) at main.c:1076
#22 0x000000000045b56e in main (argc=<optimized out>, argv=<optimized out>) at
gdb.c:34
(gdb)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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