$expose
Version information
Introduced in version v0.1
This macro is considered stable
About
The $expose macro allows v5dbg to expose variables to the debugger. The exposed variables can be viewed and modified later using debugger commands such as print
Why do I need to use this macro?
V5dbg cannot see where local variables are in memory, see the engineering page for more information.
Notes
Required environment
- This macro requires the debug server to have been initialized before being called.
- This macro requires the current thread to be supervised with $ntask or
V5Dbg_Init - This macro requires the current function to be debuggable
Potential memory error
The $expose macro allows you to expose memory which should be marked as const. For example the following code is valid:
#include "v5dbg/debug.h"
void funcWithParams(const std::string &data)
{
$function
$expose(data);
}
void opcontrol()
{
$ntask
$function
funcWithParams("Hello this usually cannot be changed!");
}
Using the debugger you can set the value of the data parameter even though in standard C++ this would result in a compiler error.
Setting the value will usually be fine but it should be classified as undefined behavior.
Examples
- Here we allocate a new
floatvariable on the stack and expose it with$expose. We only need to do this when a variable is allocated and any changes made to the variable afterwards will be automatically reflected in the debugger.
- We can expose arguments, even references! This value with show up in a different stack frame from
opcontrol - Expose our variable
ihere, this will show up in a different stack frame from the$exposeinprintAndSleep