Disclaimer : All the postings on this site are my own and don’t necessarily represent IBM’s positions, strategies or opinions.
This post is part of the “Learn debugging using AIX DBX” series. It provides tips for customizing the DBX debugging environment using .dbxinit file. If you looking for some other aspect of debugging with AIX DBX go to the parent topic or other sub-topics here : http://www.sangeek.com/day2dayunix/2013/08/learn-debugging-using-aix-dbx/

.dbxinit file gives an opportunity for the debuggers to provide initial set of commands that should be executed at the beginning of the dbx session. Using this we can provide “Useful customization for the dbx debugging environment”.

For the .dbxinit file to be automatically picked up by the dbx command. it has to be placed in the $HOME directory of the user or the user’s current directory from where DBX is being executed.

Here’s the list of subcommands that I find very useful :
set $repeat
set $deferevents
set $expandunions
set $catchbp

Here’s why each is for :

1. “set $repeat” saves you the pain of typing the same commands again and again. It re-executes the last command on pressing the enter key.


(dbx) r
[1] stopped in main at line 18
18           int val = 0, a, b, c, d;
(dbx) next
stopped in main at line 20
20           a = 12;
(dbx) <———————————————————- Pressing “enter” key execute the “next” subcommand
stopped in main at line 21
21           b = 5;
(dbx)<———————————————————- Pressing “enter” key execute the “next” subcommand
stopped in main at line 22
22           c = 3;

2. “set $deferevents” turns on the defer events feature allowing the user to set breakpoints in functions which are not yet loaded

e.g.  I want to stop in function process_output(), which is defined/declared in a separate library which is not yet loaded by the binary being debugged :

(dbx) st in process_output
“process_output” is not loaded. Creating deferred event: <————- creates a deferred breakpoint
<3> stop in process_output
(dbx) r
Processing deferred event# 3 <————- Identifies a library load and checks if the symbol of deferred event is loaded
[3] stopped in new_lib.process_output [/usr/lib/libtest.a] at line 234 <————- Stops at the deferred breakpoint
234           int a = 20;

This subcommand helps the user by allowing us to set breakpoints in functions of libraries which are not yet loaded. User does not have to wait till the library is loaded for setting a breakpoint.

3. “set $expandunions” allows the user print and see values of all the individual members of a union. By default, dbx allows us to print the values of each union member separately.

e.g. In your program you have a union defined like this :

union un
int ival;
float fval;

Without “set $expandunions” subcommand, you would have to print each member of the union :

(dbx) print un1
(dbx) print un1.ival
(dbx) print un1.fval

With “set $expandunions” enabled, you can just do this :

(dbx) print un1
union:(ival = 1, fval = 1.40129846e-45) <————- prints all the members of union in one shot

4. By default dbx skips the breakpoints e.g. the ones set in “called functions” while the user is stepping through the program using “next”.
With “set $catchbp” set we can ensure that we don’t miss on those breakpoints.





What do you think ?

Set your Twitter account name in your settings to use the TwitterBar Section.
%d bloggers like this: