AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
#Power
 View Only
Expand all | Collapse all

How to make dbx display stack, register information for all user threads *non-interactively*

  • 1.  How to make dbx display stack, register information for all user threads *non-interactively*

    Posted Thu April 12, 2007 03:00 PM

    Originally posted by: SystemAdmin



    Hi.
    As an ISV, we are currently using 'dbx' on AIX to obtain the stack traces for threads at the time of the crash of our application. So essentially, at time of crash , we go into a signal handler and invoke the dbx with a preset commands (-c option to dbx) to get the thread information for all the user threads in the process at that time.

    Currently, dbx does not provide any option to get the stack info, register values etc for all threads by a single sub-command. We have to change the current thread to each of the user threads and then do a "where". In a non-inyteractive session, there is no telling on the number of actual user threads in the process. "procstack" command just gives the stack but no register information. Is there a way to achieve that functionality.??
    #AIX-Forum


  • 2.  Re: How to make dbx display stack, register information for all user threads *non-interactively*

    Posted Sat April 14, 2007 12:15 AM

    Originally posted by: rayhiggs


    If your actively doing development, it would probably be easier to use assert() to get a core file. Otherwise, try using a shell script with a here document. Check out the attached file.
    #AIX-Forum


  • 3.  Re: How to make dbx display stack, register information for all user threads *non-interactively*

    Posted Sat April 14, 2007 12:16 AM

    Originally posted by: rayhiggs



    #AIX-Forum


  • 4.  Re: How to make dbx display stack, register information for all user threads *non-interactively*

    Posted Tue April 17, 2007 02:40 PM

    Originally posted by: SystemAdmin



    Hi Ray, Thanks for the shell script.
    That will work except that we will have to attach to the debugger twice, which an be time consuming.

    Is there another faster way we can get the list of threads? What about using /proc? It looks to me like the LWP IDs in /proc do not match the pthread IDs as seen in 'dbx'. Is there any way to determine the 'pthread' ID from the LWP ID?
    #AIX-Forum


  • 5.  Re: How to make dbx display stack, register information for all user threads *non-interactively*

    Posted Thu December 27, 2007 10:59 AM

    Originally posted by: dickdunbar


    Right ... the multiple dbx invocations is a performance problem.

    I solve this using a dbx command file:
    source core.dbx
    _ core.dbx ___snip___

    sh rm -f /tmp/core.dbx /tmp/core.tmp
    ignore int
    ignore alrm
    th > /tmp/core.tmp
    sh cat /tmp/core.tmp | egrep -v '_event_sleep|wchan' | cut -b 4-8 | awk '{print "ts("$1",$t"$1")"}' > /tmp/core.dbx
    alias ts(tid,tnum) "p '--------- thread tid'; p tnum; th current tid; x; where"
    source /tmp/core.dbx
    _ core.dbx _ snip _

    Sometimes additional stack information is useful.
    Try adding this dbx command at the top of the file:

    set $stack_details

    Message was edited by: dickdunbar
    #AIX-Forum