Wiki source for DebuggerRunning


Show raw source

{{fbdoc item="title" value="Debugging"}}----

The debugger is in the ##bin\win32## or ##bin\dos## directories (the **GDB**.EXE file), for the Windows and DOS versions respectively. It usually comes already installed in most Linux distros.


(Note: all commands should be typed without quotes and then ##[return]## must be pressed.)


- Compile the source code for your program in debug mode
- use the ##[[CompilerOptg|-g]]## command-line option to add debugging support, e.g. ##fbc -g myapp.bas##.

- Load your compiled program in GDB
- For example, in Windows/DOS: ##gdb myapp.exe##

- Set any arguments you want to send to your application
- For example: ##set args arg1 arg2 argn##.
- You can also run GDB and pass the arguments directly to the application been debugged: ##gdb --args myapp.exe arg1 arg2 arg3##.

- Ensure GDB can see your program's source code directory
- If the executable isn't in the same directory of the source files where it was compiled, type: ##dir path/to/my/application/sources##.

- Set a breakpoint in your program
- Place a breakpoint in the first line using: ##b main##.
- To place a breakpoint in a function called ##func## use: ##b FUNC##.
- Note: fbc exports variable/function names to UPPERCASE. GDB is case sensitive by default, but you can use the ##set language pascal## command to change GDB to case-insensitive mode.

- Use GDB shortcuts to run your code or to step through it
- Type ##r## to start running the application.
- Type ##n## to step to the next line, stepping over function calls.
- Keep pressing ##[return]## to step forward to the next line.
- Type ##s## to step into function calls.
- As above, keep pressing ##[return]## to step through.
- Type ##c## to continue execution until the next breakpoint.

- Use GDB shortcuts to inspect variables
- Use ##print VAR_NAME## to show the contents of the variable called ##var_name##.
- GDB supports pointer/pointer field dereferencing, indexing and arithmetics too, so ##print *MYPOINTER## will also work.
- (note: undeclared variables or the ones with suffixes like ##%## ##&## ##!## ##""#""## ##$## can't be printed).
- Use ##disp VAR_NAME## to display the contents of a variable called ##var_name##.
- Use ##watch VAR_NAME## to stop each time a variable called ##var_name## is changed.

- Additional commands:
- Use ##r## again to restart the application when it finishes.
- Type ##q## to quit.
- Type ##help## to see a list of commands, there are many others.


{{fbdoc item="back" value="DocToc|Table of Contents"}}
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode