Originally posted by: sangameshm
The correct way to attach a process to gdb is gdb <fiile> <pid>
or we can use attach command inside the gdb prompt.
# gdb /usr/sbin/sshd 6029580
GNU gdb (GDB) 8.1.1
Copyright (C) 2018 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 "powerpc64-ibm-aix6.1.0.0".
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"...
Reading symbols from /usr/sbin/sshd...done.
Attaching to program: /usr/sbin/sshd, process 6029580
BFD: BFD (GNU Binutils) 2.29.51 assertion fail format.c:453
warning: "/usr/lib/libdl.a": member "shr.o" missing.
warning: Could not load shared library symbols for /usr/lib/libdl.a(shr.o).
Do you need "set solib-search-path" or "set sysroot"?
[New Thread 1]
[Switching to Thread 1]
0xd0277a8c in __fd_select () from /usr/lib/libc.a(shr.o)
(gdb) bt
#0 0xd0277a8c in __fd_select () from /usr/lib/libc.a(shr.o)
#1 0x10002510 in select (__fds=7, __readlist=0x2005b988, __writelist=0x0,
__exceptlist=0x0, __timeout=0x0)
at time.h:234
#2 0x100027b0 in server_accept_loop (sock_in=0x2ff22bfc, sock_out=0x2ff22c00,
newsock=0x2ff22c04, config_s=0x2ff22c28) at sshd.c:1191
#3 0x10004e68 in main (ac=2, av=0x20059ec8) at sshd.c:1960
(gdb) q
A debugging session is active.
Inferior 1 [process 6029580] will be detached.
Quit anyway? (y or n) y
Detaching from program: /usr/sbin/sshd, process 6029580
# gdb
GNU gdb (GDB) 8.1.1
Copyright (C) 2018 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 "powerpc64-ibm-aix6.1.0.0".
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".
(gdb) attach 6029580
Attaching to process 6029580
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
0xd0277a8c in ?? ()
(gdb) bt
#0 0xd0277a8c in ?? ()
#1 0xffffffff in ?? ()
#2 0x10002510 in ?? ()
#3 0x100027b0 in ?? ()
#4 0x10004e68 in ?? ()
#5 0x100001ec in ?? ()
(gdb) q
A debugging session is active.
Inferior 1 [process 6029580] will be detached.
Quit anyway? (y or n) y
Detaching from program: , process 6029580
#
# gdb
GNU gdb (GDB) 8.1.1
Copyright (C) 2018 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 "powerpc64-ibm-aix6.1.0.0".
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".
(gdb) file /usr/sbin/sshd
Reading symbols from /usr/sbin/sshd...done.
(gdb) attach 6029580
Attaching to program: /usr/sbin/sshd, process 6029580
BFD: BFD (GNU Binutils) 2.29.51 assertion fail format.c:453
warning: "/usr/lib/libdl.a": member "shr.o" missing.
warning: Could not load shared library symbols for /usr/lib/libdl.a(shr.o).
Do you need "set solib-search-path" or "set sysroot"?
[New Thread 1]
[Switching to Thread 1]
0xd0277a8c in __fd_select () from /usr/lib/libc.a(shr.o)
(gdb) bt
#0 0xd0277a8c in __fd_select () from /usr/lib/libc.a(shr.o)
#1 0x10002510 in select (__fds=7, __readlist=0x2005b988, __writelist=0x0,
__exceptlist=0x0, __timeout=0x0)
at time.h:234
#2 0x100027b0 in server_accept_loop (sock_in=0x2ff22bfc, sock_out=0x2ff22c00,
newsock=0x2ff22c04, config_s=0x2ff22c28) at sshd.c:1191
#3 0x10004e68 in main (ac=2, av=0x20059ec8) at sshd.c:1960
(gdb)
Try these steps and let us know how it goes.