Showing posts with label Gdb. Show all posts
Showing posts with label Gdb. Show all posts

Tuesday, August 7, 2012

Enabling Core on Ubuntu

Check  
 ulimit -c   It should not be zero.
set ulimit -c unlimited


  1. Vim /etc/sysctl.conf
  2. Add the lines:
    kernel.core_uses_pid = 1
    kernel.core_pattern = core-%e-%s-%u-%g-%p-%t    
    fs.suid_dumpable = 2
  3. If  we need to redirect core in some path mention that in kernel.core_pattern = /tmp/core-%e-%s-%u-%g-%p-%t
  4. sysctl -p

Monday, February 1, 2010

GDB and Strace Attach to running process

Strace -p PID
note it should not run more as it eats lot of resources .

$ gdb --quiet
(gdb) attach pid
(gdb) info proc
process 13601
cmdline = './a.out'
cwd = '/home/amit/ccode'
exe = '/home/amit/ccode/a.out'

(gdb) info functions
---Fir this command in compilation -g flag is mandatory in gcc to insert debug information
(gdb) list main
22           printf("done thread #%ld!\n", tid);
23           pthread_exit(NULL);
24      }
25
26      int main (int argc, char *argv[])
27      {
28           pthread_t threads[NUM_THREADS];
29           int rc;
30           long t;
--------Show Assembler code disass option of gdb------
(gdb)  disass main
Dump of assembler code for function main:
0x0804858f :    push   %ebp
0x08048590 :    mov    %esp,%ebp
0x08048592 :    sub    $0x28,%esp



$gdb -p pid 
Ref : http://www.ibm.com/developerworks/aix/library/au-unix-strace.html