E.3 Using Agent Expressions

Agent expressions can be used in several different ways by gdb, and the debugger can generate different bytecode sequences as appropriate.

One possibility is to do expression evaluation on the target rather than the host, such as for the conditional of a conditional tracepoint. In such a case, gdb compiles the source expression into a bytecode sequence that simply gets values from registers or memory, does arithmetic, and returns a result.

Another way to use agent expressions is for tracepoint data collection. gdb generates a different bytecode sequence for collection; in addition to bytecodes that do the calculation, gdb adds trace bytecodes to save the pieces of memory that were used.