Thursday, April 26, 2018

Gdb debugging on Target and Local systems on Linux environment

GDB Debugging

Compile binary with -g option:  gcc file.c -g -o file_out

Development PC works as a client machine:
  $ gdb ./file_out

  (gdb)b main
  (gdb)b filename:10
  (gdb)c //used to run the programe
  (gdb) list
  (gdb) print var


Target GDB Debugging
Target or R&D System :
 $ ifconfig
   11.19.81.198

 $ ./gdbserver.i686 host:2345 ./file_out
   Listening on port 2345
   Remote debugging from host  11.19.89.132


Development PC works as a client machine:
  $ gdb ./file_out

  then connect remote lcoation 
  (gdb) target remote 11.19.81.198:2345
       Reading /lib/ld-linux.so.2 from remote target...
       warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
       Reading /lib/ld-linux.so.2 from remote target...
       Reading symbols from target:/lib/ld-linux.so.2...Reading /lib/ld-2.24.so from remote target...
       Reading /lib/.debug/ld-2.24.so from remote target...
       (no debugging symbols found)...done.
       0x4b6f3a20 in ?? () from target:/lib/ld-linux.so.2
  (gdb) set remote exec-file /bin/true
  (gdb)b main
  (gdb)b filename.c:10
  (gdb)c //used to run the programe
     Continuing.
     Reading /lib/libc.so.6 from remote target...
     Reading /lib/libc-2.24.so from remote target...
     Reading /lib/.debug/libc-2.24.so from remote target...
  (gdb) list
  (gdb) print var

Wrappers:
$ gdbserver --wrapper env LD_PRELOAD=libtest.so -- :2222 ./testprog
The --selftest option runs the self tests in gdbserver:
$ gdbserver --selftestmonitor set debug 0

Enable / Disable logs:
(gdb) monitor set debug 1
(gdb) monitor set debug 1
(gdb) monitor set remote-debug 0
(gdb) monitor set remote-debug 1




No comments:

"NCBN Nara chandrababu naidu" CEO Deals to grow Andhra Pradesh

CISCO network and andhra pradesh CEO Chandra babu  Microsoft Kaizala for andhra pradesh  Google Wi-fi for andhra pradesh CEO Micro...