]> Bdb Top Bdb Copying Conditions Copying conditions Conditions for copying Bdb This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Bug descriptions, use reports, comments or suggestions are welcome. Send them to Manuel Serrano – New versions or updates may be found at: http://kaolin.unice.fr/~serrano/bigloo/bigloo.html. BDB is a symbol debugger for programs compiled with Bigloo, compiler for an extended version of the Scheme programming language. This is the BDB documentation, Nov 1999, for BDB Version 1.0. Overview Overview BDB is a symbolic debugger for programs compiled and linked with Bigloo BDB allows to stop executions by the means of breakpoints. It allows to step inside the source code, to inspect global and local variables, to inspect the execution stack and to evaluate Bigloo expression. Bigloo is designed to interleave Scheme and C code. In consequence, debugging Bigloo programs requires the ability to step into C code. BDB allows that because BDB knows how to handle C code and C data structures. BDB is built on the top of GDB In consequence, all GDB commands are available to BDB. When a Bigloo program stops because of an error, BDB stops the execution in the error handler and gives you the opportunity to inspect the data structure of your program. Running Programs Under BDB Running Programs Under BDB Other informations may be found at See . Solaris Run On the Solaris platform, the normal initialization process of the Garbage Collector is to raise a SIGSEGV signal. You can safely ignore this signal. Simply emit a |continue| when the execution first stops because of that signal. Scheme vs C BDB is able to debug both Scheme and C code. Commands to inspect variables and code are the same for Scheme and C. The general convention adopted by BDB is to represent Scheme symbols in uppercase. This distinction is of importance because the BDB treatment is different for a Scheme expression and for a C expression. For instance, the commandbreak main sets a breakpoint into a C function named main. While the commandbreak MAIN sets a breakpoint into a Scheme function named main. Compilation BDB requires special compilation mode for Bigloo and C files. Some of the files may not be compiled in that special mode. For those, BDB won't be able to step over the code. It is mandatory that, at least, the Bigloo module that contains the main entry point is compiled with debugging informations The two options that tells Bigloo to produce BDB code are -gbdb and -gbdb2. The second delivers more runtime informations but may enlarge the size of the binary file. The option to use when compiling C code is the regular debugging option (e.g. -g) There is no need to link programs with static version of the libraries although setting up breakpoints in library code is enabled only for static libraries. On some platforms linking with static versions of the libraries will prevent the debugger from getting confused when loading a dynamic library (e.g. it may happen that the debugger steps the dynamic code loader). Starting runr runUse the run command to start your program under BDB. You mustfirst specify the program name with an argument to BDB, or by using thefile command The arguments. Specify the arguments passed to your program as the arguments of therun command. If no arguments are specified and this run invocationis not the first one, previous arguments to the last run commandare used The standard input and output. The current BDB version is unable to debug interactive programs. This is amajor flaw remedied by the graphical version of BDB (namely KBDB). Stopping Stopping In addition to the GDB commands, BDB enables breakpoints inside Bigloo source code Setting breakpoints You may use any of the GDB commands to set breakpoints The key point is that none of these commands know Bigloo identifiers. Setting breakpoints inside Bigloo functions requires special BDB commands: break FUNCTIONb FUNCTION breakSet a breakpoint at entry to the function FUNCTION. IF FUNCTIONis an uppercase symbol, FUNCTION is interpreted as the name of a Bigloofunction. If FUNCTION contains at least one lower case character itis interpreted as the name of a C function. tbreak FUNCTIONtb FUNCTION tbreakSet a temporary breakpoint at entry to the function FUNCTION. Break conditions Conditions may be associated with breakpoints inside debugged code. The syntax is: bcond BNUM EXPRESSION bcondSpecify EXPRESSION as the break condition for breakpoint numberBNUM. EXPRESSION is an expression that is evaluated in theenvironment of the breakpoint. That is EXPRESSION may uses localvariables. If EXPRESSION is made of uppercase symbols, it isinterpreted as a Bigloo expression and is thus evaluated by the Bigloointerpreter. Otherwise it is interpreted as a C expression. Continuing execution after a breakpoint Continuing execution after a breakpoint When the execution has stopped at a breakpoint several commands allow the execution to be resumed: You may use any of the GDB commands to resume an execution No distinction is made between Bigloo and C code. That is, it is possible when stepping a Bigloo function to enter a C function and vice versa. BDB does not try to hide the execution of C functions. Each code compiled in debug mode is visible from BDB. continue [IGNORE-COUNT]c [IGNORE-COUNT] continueResume program execution at the address where your program laststopped; any breakpoints set at that address are bypassed. Theoptional argument IGNORE-COUNT allows you to specify a furthernumber of times to ignore a breakpoint at this location. step [COUNT]s [COUNT] stepContinue running your program until control reaches a differentScheme source line, then stop it and return control to BDB. This commandis abbreviated bs. next [COUNT]n [COUNT] nextContinue to the next source line in the current (innermost) stackframe. This is similar to step, but function calls that appearwithin the line of code are executed without stopping. Executionstops when control reaches a different line of code at theoriginal stack level that was executing when you gave the nextcommand. This command is abbreviated n.An argument COUNT is a repeat count, as for step.The next command now only stops at the first instruction of asource line. This prevents the multiple stops that used to occurin switch statements, for loops, etc. finishf finishContinue running until just after the function in the selected stackframe returns. Print the returned value (if any). untilu buntilContinue running until a source line past the current line, in thecurrent stack frame, is reached. This command is used to avoidsingle stepping through a loop more than once. It is like thenext command, except that when until encounters a jump, itautomatically continues execution until the program counter isgreater than the address of the jump.This means that when you reach the end of a loop after singlestepping through it, until makes your program continue executionuntil it exits the loop. In contrast, a `next' command at the endof a loop simply steps back to the beginning of the loop, whichforces you to step through the next iteration.until always stops your program if it attempts to exit thecurrent stack frame. return [EXPRESSION]r [EXPRESSION] returnYou may return from a function, using the return GDB commandThis cancels the execution of a function call.If you give an EXPRESSION argument, its value is used as the function'sreturn value. Examining the Stack Examining the Stack When your program has stopped, the first thing you need to know is where it stopped and how it got there. All GDB commands apply here See . These commands let you inspect and browse the C stack. In addition you may inspect the stack restricted to Bigloo stack frames. info stacki s info stackPrint the current stack frames. These frames may be inspected in turnwith the frame command. info argsi a info argsPrint the arguments of the selected frame, each on a separate line. cinfo argsci a cinfo argsIf the current stack frame belongs to a Bigloo function then the argumentshold Bigloo values. The info args displays the Bigloo valuesof these arguments. In some situation it is useful to access the Crepresentation for these arguments. This can be achieved by thecinfo args command that forces BDB not to interpret the currentfunction as a Bigloo function. info localsi l info localsPrint the local variables of the selected frame, each on a separateline. cinfo localsci a cinfo localsPrint the local variables as if they were C variables, each on a separateline. Using BDB under Emacs emacs A special interface allows you to use Emacs to view (and edit) the source files for the program you are debugging with BDB. To use this interface, use the command M-x bdb in Emacs or click the Bdb icon of the Bee tool bar Give the executable file you want to debug as an argument. This command starts BDB as a subprocess of Emacs, with input and output through a newly created Emacs buffer. Breakpoints may be set by the means of mouse clicks. Once a buffer is connected to the debugger (connection is automatic when the execution thread stops inside a buffer, or connection may be explicitly requested with the Connect icon), a left margin is printed. Clicking button-3 on the margin will pop up a menu that enables breakpoint settings. Breakpoints may be disabled or deleted by the means of mouse menu. Click button-2 on a breakpoint icon. The M-x bdb provides facilities for displaying all kinds of information such as stack frames, automatic display, source code browsing, stepping, etc. Bibliography [Bigloo]M. Serrano.‘Bigloo User Manual’http://kaolin.unice.fr/~serrano/bigloo/bigloo.html [Gdb]R. Stallman‘Gdbhttp://www.cygnus.com/gdb/ xreflabel="Index" id="Index"> Index B bcond, see break, see buntil, see C cinfo args, see cinfo locals, see Conditions for copying Bdb, see continue, see Continuing execution after a breakpoint, see Copying conditions, see E emacs, see Examining the Stack, see F finish, see I info args, see info locals, see info stack, see N next, see O Overview, see R return, see run, see Running Programs Under BDB, see S step, see Stopping, see T tbreak, see