User Tips |
22 |
![]() |
Using dbx Equivalents for Common GDB Commands
The following table lists approximate equivalent dbx commands for some common GNU Debugging (GDB) commands:
Reviewing dbx Changes
Using the .dbxinit File
Long-time users of dbx might be using the .dbxinit file instead of the newer .dbxrc file. If you have a .dbxrc file, dbx reads it and ignores any .dbxinit file present. If necessary, you can get dbx to read both by adding the following lines to your .dbxrc file:
kalias alias=dalias source ~/.dbxinit kalias alias=kalias |
If you don't have a .dbxrc file, but do have a .dbxinit file, you should see the warning message:
Using .dbxinit compatibility mode. See \Qhelp .dbxrc' for more information. |
Currently, dbx still reads your .dbxinit file. although this feature may disappear in a future release.
Alias Definition
The alias command is now a pre-defined alias for dalias or kalias. The Symbols / and ?
With the introduction of a KornShell-based parser, the / (forward slash) command had to be renamed because it cannot be distinguished from a UNIX pathname. Use search instead.
(dbx) /abc |
now means to execute the file abc from the root directory.
Similarly, ? (question mark) had to be renamed because it is now a shell metacharacter. Use bsearch instead.
(dbx) ?abc |
If you use these commands frequently, you may wish to create aliases for them:
alias ff=search |
find forward |
alias fb=bsearch |
find backward |
Embedded Slash Command
The embedded slash command was renamed. This is no longer valid:
0x1234/5X |
Use the examine command or its alias, x:
examine 0x1234/5X x 0x1234/5X |
Using assign Instead of set
set is now the KornShell set command, and is no longer an alias for assign.
Enabling Command-Line Editing
You can enable command-line editing in several ways. First, if $FCEDIT, $EDITOR, or $VISUAL is set, its value is checked. If the last component, the component after the last slash, contains the string emacs, then emacs-mode is enabled. If it contains vi, vi-mode is enabled. If none of the three environment variables are set or if the first one in the list that is set does not contain emacs or vi, then command-line editing is disabled.
set -o emacs set -o vi |
To disable command-line editing,:
set +o emacs +o vi |
Being In Scope
If dbx claims that abc is not defined in the current scope, it means that no symbol named abc is accessible from the current point of execution. See Chapter 3, "Viewing and Visiting Code" for details.
Locating Files
All files created by dbx are placed in the directory /top unless the environment variable TMPDIR is set, in which case the directory $TMPDIR is used.
Reaching Breakpoints
If you do not reach the breakpoint you expected to reach, consider the following possibilities:
while (condition) statement |
if (condition) { again: statement if condition goto again; } |
(dbx) whatis stack class stack { ... static stackcount; /* Never defined or allocated */ ... }; |
When a class member is not defined or allocated, dbx cannot determine its type so there is no type to print.
Runtime Checking 8Megabyte Limit
Only access checking has this limit. Leak checking is not affected by this limit.
Locating Floating-Point Exceptions with dbx
You need to do two things. First, to stop the process whenever an FP exception occurs, type:
(dbx) catch FPE |
Next, add the following to your Fortran application:
integer ieeer, ieee_handler, myhandler ieeer = ieee_handler('set', 'all', myhandler) ... integer function myhandler(sig, code, context) integer sig, code(5) call abort() end |
This is necessary because the ieee software typically sets all errors to be silent (not raising signals). This causes all ieee exceptions to generate a SIGFPE as appropriate, which is probably too much.
stop sig FPE |
which acts just like catch FPE, or
stop sig FPE subcode |
For finer control, subcode can be one of the following:
Note that stop and catch are independent and that if you use stop FPE you should also ignore FPE.
Using dbx with Multithreaded Programs
Multithreaded features are an inherent part of the standard dbx.
stop in foo -thread t@4 |
Where the t@4 refers to the thread with id 4.
_cb_prompt() { if [ $mtfeatures = "true"] then PS1='[$thread $lwp]: ' else PS1="(dbx-$proc) " fi } |
dbx Identification of Multithreaded Applications
If an application is linked with -lthread, dbx assumes it is multithreaded. The Collector, RTC, fix and continue, and Watchpoints
The collector and fix and continue work with multithreaded applications. RTC works with multithreaded applications, however a libthread patch is needed. Multithreaded Pitfalls
It is very easy to get your program to deadlock by resuming only a specific thread while other threads are still and hold a resource that the resumed thread might need. Sleeping Threads
You cannot "force" a sleeping thread to run. In general, when debugging multithreaded applications it is recommended that you take a "stand back and watch" approach rather than trying to alter the program's natural execution flow. thr_join, thr_create(),and thr_exit
Starting from the threads list, you can determine which thread id came from which start function. The "base function" as it is known, is printed in the thread listing.