Interface for running and querying GDB.
More...
#include <gdb_api.h>
|
using | commandst = std::forward_list< std::string > |
|
Interface for running and querying GDB.
Definition at line 29 of file gdb_api.h.
◆ commandst
◆ gdb_output_recordt
◆ gdb_statet
Enumerator |
---|
NOT_CREATED | |
CREATED | |
STOPPED | |
Definition at line 151 of file gdb_api.h.
◆ gdb_apit()
gdb_apit::gdb_apit |
( |
const std::vector< std::string > & |
args, |
|
|
const bool |
log = false |
|
) |
| |
|
explicit |
Create a gdb_apit object.
- Parameters
-
args | arguments to pass to gdb, the first argument is the command to execute |
log | boolean indicating whether gdb input and output should be logged |
Definition at line 28 of file gdb_api.cpp.
◆ ~gdb_apit()
Terminate the gdb process and close open streams (for reading from and writing to gdb)
Definition at line 33 of file gdb_api.cpp.
◆ check_command_accepted()
void gdb_apit::check_command_accepted |
( |
| ) |
|
|
protected |
◆ collect_malloc_calls()
void gdb_apit::collect_malloc_calls |
( |
| ) |
|
|
protected |
Intercepts the gdb-analysis at the malloc call-site to add the corresponding information into allocated_memory.
Definition at line 288 of file gdb_api.cpp.
◆ create_gdb_process()
void gdb_apit::create_gdb_process |
( |
| ) |
|
Create a new gdb process for analysing the binary indicated by the first element in args
Definition at line 67 of file gdb_api.cpp.
◆ eval_expr()
std::string gdb_apit::eval_expr |
( |
const std::string & |
expr | ) |
|
|
protected |
◆ get_command_log()
Return the vector of commands that have been written to gdb so far.
- Returns
- the list of commands
Definition at line 190 of file gdb_api.cpp.
◆ get_memory()
Get the value of a pointer associated with expr
.
- Parameters
-
expr | the expression to be analyzed |
- Returns
- the
pointer_valuet
filled with data gdb produced for expr
◆ get_most_recent_record()
◆ get_register_value()
Parse the record produced by listing register value.
- Parameters
-
record | gdb record for one register value |
- Returns
- get the value associated with some register value
◆ get_value()
std::optional<std::string> gdb_apit::get_value |
( |
const std::string & |
expr | ) |
|
Get the memory address pointed to by the given pointer expression.
- Parameters
-
expr | an expression of pointer type (e.g., &x with x being of type int or p with p being of type int * ) |
- Returns
- memory address in hex format
◆ get_value_from_record()
std::string gdb_apit::get_value_from_record |
( |
const gdb_output_recordt & |
record, |
|
|
const std::string & |
value_name |
|
) |
| |
|
protected |
Locate and return the value for a given name.
- Parameters
-
record | gdb record to search |
value_name | name of the value to be extracted |
- Returns
- the value associated with
value_name
◆ hit_malloc_breakpoint()
Check if the breakpoint we hit is inside a malloc.
- Parameters
-
stopped_record | gdb record pertaining to a breakpoint being hit |
- Returns
- true if the breakpoint the gdb stopped at was malloc
◆ most_recent_line_has_tag()
bool gdb_apit::most_recent_line_has_tag |
( |
const std::string & |
tag | ) |
|
|
protected |
◆ parse_gdb_output_record()
◆ query_malloc_size()
size_t gdb_apit::query_malloc_size |
( |
const std::string & |
pointer_expr | ) |
|
Get the exact allocated size for a pointer pointer_expr
.
- Parameters
-
pointer_expr | expression with a pointer name |
- Returns
- 1 if the pointer was not allocated with malloc otherwise return the number of allocated bytes
Definition at line 56 of file gdb_api.cpp.
◆ r_opt()
static std::string gdb_apit::r_opt |
( |
const std::string & |
regex | ) |
|
|
staticprotected |
◆ r_or()
static std::string gdb_apit::r_or |
( |
const std::string & |
regex_left, |
|
|
const std::string & |
regex_right |
|
) |
| |
|
staticprotected |
◆ read_most_recent_line()
std::string gdb_apit::read_most_recent_line |
( |
| ) |
|
|
protected |
◆ read_next_line()
std::string gdb_apit::read_next_line |
( |
| ) |
|
|
protected |
◆ run_gdb_from_core()
void gdb_apit::run_gdb_from_core |
( |
const std::string & |
corefile | ) |
|
Run gdb with the given core file.
- Parameters
-
Definition at line 275 of file gdb_api.cpp.
◆ run_gdb_to_breakpoint()
bool gdb_apit::run_gdb_to_breakpoint |
( |
const std::string & |
breakpoint | ) |
|
Run gdb to the given breakpoint.
- Parameters
-
breakpoint | the breakpoint to set (can be e.g. a line number or a function name) |
- Returns
- true if something failed
Definition at line 345 of file gdb_api.cpp.
◆ was_command_accepted()
bool gdb_apit::was_command_accepted |
( |
| ) |
|
|
protected |
◆ write_to_gdb()
void gdb_apit::write_to_gdb |
( |
const std::string & |
command | ) |
|
|
protected |
◆ allocated_memory
std::map<std::string, size_t> gdb_apit::allocated_memory |
|
protected |
track the allocated size for each malloc call maps hexadecimal address to the number of bytes
Definition at line 162 of file gdb_api.h.
◆ args
std::vector<std::string> gdb_apit::args |
|
protected |
◆ command_log
◆ command_stream
FILE* gdb_apit::command_stream |
|
protected |
◆ gdb_state
◆ log
◆ malloc_name
const std::string gdb_apit::malloc_name = "malloc" |
|
protected |
◆ r_char
const std::string gdb_apit::r_char = R"(\\"(\\\\[0-7]{3})\\")" |
|
protected |
◆ r_hex_addr
const std::string gdb_apit::r_hex_addr = R"((0x(?:0|[1-9a-f][0-9a-f]*)))" |
|
protected |
◆ r_id
const std::string gdb_apit::r_id = R"(<([^<>]+)>)" |
|
protected |
◆ r_string
const std::string gdb_apit::r_string = R"((\\".*\\"))" |
|
protected |
◆ response_stream
FILE* gdb_apit::response_stream |
|
protected |
The documentation for this class was generated from the following files:
- /home/runner/work/cbmc/cbmc/src/memory-analyzer/gdb_api.h
- /home/runner/work/cbmc/cbmc/src/memory-analyzer/gdb_api.cpp