18 #ifndef CPROVER_MEMORY_ANALYZER_GDB_API_H
19 #define CPROVER_MEMORY_ANALYZER_GDB_API_H
23 #include <forward_list>
68 const std::vector<std::string> &
args,
const bool log =
false);
79 const std::string &
address =
"",
80 const std::string &
pointee =
"",
82 const std::optional<std::string> &
string = {},
83 const bool valid =
false)
130 std::optional<std::string>
get_value(
const std::string &expr);
172 std::string
eval_expr(
const std::string &expr);
191 const std::string &value_name);
203 static std::string
r_opt(
const std::string ®ex);
206 r_or(
const std::string ®ex_left,
const std::string ®ex_right);
210 const std::string
r_hex_addr = R
"((0x(?:0|[1-9a-f][0-9a-f]*)))";
214 const std::string
r_id = R
"(<([^<>]+)>)";
218 const std::string
r_char = R
"(\\"(\\\\[0-7]{3})\\")";
Base class for exceptions thrown in the cprover project.
std::string reason
The reason this exception was generated.
Interface for running and querying GDB.
static std::string r_opt(const std::string ®ex)
bool was_command_accepted()
void check_command_accepted()
bool run_gdb_to_breakpoint(const std::string &breakpoint)
Run gdb to the given breakpoint.
void collect_malloc_calls()
Intercepts the gdb-analysis at the malloc call-site to add the corresponding information into allocat...
void create_gdb_process()
Create a new gdb process for analysing the binary indicated by the first element in args
std::map< std::string, size_t > allocated_memory
track the allocated size for each malloc call maps hexadecimal address to the number of bytes
const std::string r_hex_addr
void write_to_gdb(const std::string &command)
std::map< std::string, std::string > gdb_output_recordt
void run_gdb_from_core(const std::string &corefile)
Run gdb with the given core file.
const commandst & get_command_log()
Return the vector of commands that have been written to gdb so far.
std::optional< std::string > get_value(const std::string &expr)
Get the memory address pointed to by the given pointer expression.
std::string eval_expr(const std::string &expr)
std::string read_next_line()
const std::string r_string
std::forward_list< std::string > commandst
std::string get_register_value(const gdb_output_recordt &record)
Parse the record produced by listing register value.
gdb_output_recordt get_most_recent_record(const std::string &tag, const bool must_exist=false)
const std::string malloc_name
static std::string r_or(const std::string ®ex_left, const std::string ®ex_right)
std::string get_value_from_record(const gdb_output_recordt &record, const std::string &value_name)
Locate and return the value for a given name.
static gdb_output_recordt parse_gdb_output_record(const std::string &s)
std::vector< std::string > args
pointer_valuet get_memory(const std::string &expr)
Get the value of a pointer associated with expr.
size_t query_malloc_size(const std::string &pointer_expr)
Get the exact allocated size for a pointer pointer_expr.
gdb_apit(const std::vector< std::string > &args, const bool log=false)
Create a gdb_apit object.
std::string read_most_recent_line()
bool most_recent_line_has_tag(const std::string &tag)
~gdb_apit()
Terminate the gdb process and close open streams (for reading from and writing to gdb)
bool hit_malloc_breakpoint(const gdb_output_recordt &stopped_record)
Check if the breakpoint we hit is inside a malloc.
gdb_interaction_exceptiont(std::string reason)
Memory address imbued with the explicit boolean data indicating if the address is null or not.
std::string string() const
memory_addresst(const std::string &address_string)
std::string address_string
bool operator<(const memory_addresst &other) const
Data associated with the value of a pointer, i.e.
std::optional< std::string > string
bool has_known_offset() const
pointer_valuet(const std::string &address="", const std::string &pointee="", const std::string &character="", const std::optional< std::string > &string={}, const bool valid=false)