Using core files
When code crashes on BGL, usually you'll get
core.<process id> files, which are plain-text stack traces. You can figure out where your code crashed by using
addr2line -e <exe> <address>. You get the addresses from the "function call chain:" section at the end of the core file.
Jim Edwards wrote a perl script to automatically spit out a full stack trace for a given binary; it is located at
/contrib/bgl/bin/decode.pl. You need to compile and link with the '-g' flag to get the proper routine names.
Monitoring stack and heap usage (memmon)
The memmon library is at
/contrib/bgl/lib/libmemmon.rts.a, with a README at
Memmon allows you to trace and view stack and heap usage in your code. These functions are provided:
Compile your code with these flags, depending on the compiler you are using:
If you just link with memmon and do not add any of the memmon_ function calls, memmon will watch your memory usage and exit if the stack overwrites the heap.
If you add calls to
memmon_trace_off in your code, memmon will print memory usage at the entry and exit of each funtion surrounded by the
memon_print_usage() anywhere in your code prints out a message like this:
Note that memmon shows the maximum (not the current) stack and heap usage in the program at the point where the routine is called.