In our ever more abstracted and open systems, it's becoming increasingly important to be able to inspect code more effectively. A very useful technique for this, is to trigger your debugger from code. I.E. rather than setting arbitrarily complex breakpoints in your debugger, one can use the following simple triggers in various languages.

LanguageTrigger
Casm("int $0x3\n");
Pythonimport pdb; pdb.set_trace()
Javascriptdebugger

These will pass control to your debugger where you can inspect or modify the current context and continue.

Note this technique is useful in conjunction with library calls, where you may want to break on certain values of the parameters. To do this a wrapper funcion could be used, which can be handled with the ld --wrap option. Note glibc itself will call functions with a leading __ so as not to clash with any user redefinitions, so to wrap at the lowest level you may need to wrap __close() rather than close() for example.
© Feb 24 2011