Skip to content

Commit 347bf43

Browse files
committed
Add and check type of pointees in memory analyzer
GDB does not know (the CBMC) types but the resulting symbol table requires them. Also prevents catch-by-value error when compiled with gcc-8.
1 parent 49ac991 commit 347bf43

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/memory-analyzer/analyze_symbol.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void gdb_value_extractort::analyze_symbol(const irep_idt &symbol_name)
6767

6868
add_assignment(symbol_expr, target_expr);
6969
}
70-
catch(gdb_interaction_exceptiont e)
70+
catch(gdb_interaction_exceptiont &e)
7171
{
7272
throw analysis_exceptiont(e.what());
7373
}
@@ -292,7 +292,9 @@ exprt gdb_value_extractort::get_non_char_pointer_value(
292292
}
293293
else
294294
{
295-
return it->second;
295+
const symbol_exprt typed_symbol_value = symbol_exprt{
296+
to_symbol_expr(it->second).get_identifier(), expr.type().subtype()};
297+
return typed_symbol_value;
296298
}
297299
}
298300

@@ -348,7 +350,9 @@ exprt gdb_value_extractort::get_pointer_value(
348350
}
349351
else
350352
{
351-
return address_of_exprt(target_expr);
353+
const auto result_expr = address_of_exprt(target_expr);
354+
CHECK_RETURN(result_expr.type() == zero_expr.type());
355+
return result_expr;
352356
}
353357
}
354358
}

0 commit comments

Comments
 (0)