Oracle® Solaris Studio 12.4: dbxtool Tutorial

Exit Print View

Updated: October 2014

Using Breakpoint Scripts to Patch Your Code

In Using Breakpoints and Stepping, you discovered a bug where an empty line yields a NULL first token and causes a SEGV. You can use a workaround to avoid the error.

  1. Delete all of the breakpoints you created previously. You can do this quickly by right-clicking in the Breakpoints window and selecting Delete All.

  2. Delete the <in argument in the Debug Executable dialog box.

  3. Toggle a line breakpoint at line 130 in

    image:Editor window with breakpoint on line 130
  4. In the Breakpoints window, right-click the breakpoint you just created and choose Customize.

  5. In the Customize Breakpoint dialog box, type token == 0 in the Condition field.

  6. Select Run Script from the Action drop-down list.

  7. In the Script field, type assign token = line.

    Note -  You cannot assign token = “dummy” because dbx cannot allocate the dummy string in the debugged process. On the other hand, line is known to be equal to "".

    The dialog box should look like the following screen.

    image:Custom breakpoint dialog box
  8. Click OK.

Now if you run the program and enter an empty line, instead of crashing, it will warn you, as shown in the following screen.

image:Output window

This workaround might be clearer if you look at the command that dbxtool sent to dbx.

when at "":130 -if token == 0 { assign token = line; }