-
Notifications
You must be signed in to change notification settings - Fork 54
Debugging the c code
Erik B Knudsen edited this page Aug 17, 2021
·
4 revisions
McCode (pre the 3.0 line of code-generators) uses #line-pragmas in the generated code, in an attempt to jump between each of the included c-snippets in libraries, components etc. This unfortunately does not work well in all cases.
- Some files are
%included
, which is a simple concatenation. If there is such a%include
-statement the line numbering will be off. - If there are more than one component of a single type, e.g two Guides or Mirrors, the #line-pragmas hide which component the debugger is currently stepping through.
A first advisable step is therefore to
grep -v ^\#line Instrument.c > Instrument_stripped.c
Use GDB: First, compile the generated c-code including debugging symbols.
gcc -g Instrument_stripped.c -o Instrument_stripped.out
On windows it may be preferrable to use the .exe-suffix for the executable.
Then start the debugger with
gdb Instrument_stripped.out
Use LLVM, here is a list of command equivalences https://lldb.llvm.org/use/map.html