Skip to content

Commit 8903dfa

Browse files
committed
Initialise the databases for dynamic allocation and known symbols
Via dynamically_allocated and memory_map.
1 parent ba5748c commit 8903dfa

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/memory-analyzer/analyze_symbol.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,22 @@ void gdb_value_extractort::analyze_symbols(const std::vector<irep_idt> &symbols)
111111
CHECK_RETURN(value.pointee.empty() || (id == value.pointee));
112112

113113
values.insert({value.address, symbol_expr});
114+
115+
const symbolt &symbol = ns.lookup(id);
116+
const symbol_exprt actual_expr = symbol.symbol_expr();
117+
if(actual_expr.type().id() != ID_pointer)
118+
{
119+
memory_map[id2string(id)] = value;
120+
continue;
121+
}
122+
123+
const std::string c_symbol = c_converter.convert(actual_expr);
124+
const pointer_valuet &symbol_value = gdb_api.get_memory(c_symbol);
125+
size_t symbol_size = gdb_api.query_malloc_size(c_symbol);
126+
127+
if(symbol_size > 1)
128+
dynamically_allocated.emplace_back(symbol_value.address, symbol_size, id);
129+
memory_map[id2string(id)] = symbol_value;
114130
}
115131

116132
for(const auto &id : symbols)

0 commit comments

Comments
 (0)