Repository navigation
Debugging
Home › Using the FreeBASIC compiler › 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
-gcommand-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.exeNote: under windows if the GDB command prompt seems not to work well (like backspace not working), tryset TERM=#win32conbefore launching GDB.
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 calledfuncuse:b FUNC.
Note: the compiler exports variable/function names to UPPERCASE. GDB is case sensitive by default, but you can use theset language pascalcommand to change GDB to case-insensitive mode.
Use GDB shortcuts to run your code or to step through it
- Type
rto start running the application. - Type
nto step to the next line, stepping over function calls. - Keep pressing
[return]to step forward to the next line. - Type
sto step into function calls. - As above, keep pressing
[return]to step through. - Type
cto continue execution until the next breakpoint.
Use GDB shortcuts to inspect variables
-
Use
print VAR_NAMEto show the contents of the variable calledvar_name. -
GDB supports pointer/pointer field dereferencing, indexing and arithmetics too, so
print *MYPOINTERwill also work. -
(note: undeclared variables or the ones with suffixes like
%&!#$can't be printed).
Use
disp VAR_NAMEto display the contents of a variable calledvar_name.
Usewatch VAR_NAMEto stop each time a variable calledvar_nameis changed.Additional commands:
- Use
ragain to restart the application when it finishes. - Type
qto quit. - Type
helpto see a list of commands, there are many others.
- use the
Category: Using the FreeBASIC compiler
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Home
- What Is tiko-lang
- Quick Start
- Installing on macOS
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Time Zones
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing