@@ -284,76 +284,22 @@ exprt gdb_value_extractort::get_pointer_to_member_value(
284
284
285
285
const symbolt *struct_symbol = symbol_table.lookup (struct_name);
286
286
DATA_INVARIANT (struct_symbol != nullptr , " unknown struct" );
287
- const auto maybe_struct_size =
288
- pointer_offset_size (struct_symbol->symbol_expr ().type (), ns);
289
- bool found = false ;
290
- CHECK_RETURN (maybe_struct_size.has_value ());
291
- for (const auto &value_pair : values)
287
+
288
+ if (memory_map.count (struct_name) == 0 )
292
289
{
293
- const auto &value_symbol_expr = value_pair.second ;
294
- if (to_symbol_expr (value_symbol_expr).get_identifier () == struct_name)
295
- {
296
- found = true ;
297
- break ;
298
- }
290
+ memory_map[struct_name] = gdb_api.get_memory (struct_name);
291
+ analyze_symbol (irep_idt{struct_name});
299
292
}
300
293
301
- if (!found)
302
294
if (struct_symbol->symbol_expr ().type ().id () == ID_array)
303
295
{
304
- const typet target_type = expr.type ().subtype ();
305
-
306
- symbol_exprt dummy (" tmp" , expr.type ());
307
- code_blockt assignments;
308
-
309
- auto emplace_pair = values.emplace (
310
- memory_location,
311
- allocate_objects.allocate_automatic_local_object (
312
- assignments, dummy, target_type));
313
- const symbol_exprt &new_symbol = to_symbol_expr (emplace_pair.first ->second );
314
-
315
- dereference_exprt dereference_expr (expr);
316
-
317
- const auto zero_expr = zero_initializer (target_type, location, ns);
318
- CHECK_RETURN (zero_expr);
319
-
320
- // add assignment of value to newly created symbol
321
- add_assignment (new_symbol, *zero_expr);
322
-
323
- const auto &struct_symbol = values.find (memory_location);
324
-
325
- const auto maybe_member_expr = get_subexpression_at_offset (
326
- struct_symbol->second , member_offset, expr.type ().subtype (), ns);
327
- if (maybe_member_expr.has_value ())
328
- return *maybe_member_expr;
329
- UNREACHABLE;
330
296
return index_exprt{
331
297
struct_symbol->symbol_expr (),
332
298
from_integer (
333
299
member_offset / get_type_size (expr.type ().subtype ()), index_type ())};
334
300
}
335
-
336
- const auto it = values.find (memory_location);
337
- // if the structure we are pointing to does not exists we need to build a
338
- // temporary object for it: get the type from symbol table, query gdb for
339
- // value, allocate new object for it and then store into assignments
340
- if (it == values.end ())
341
301
if (struct_symbol->symbol_expr ().type ().id () == ID_pointer)
342
302
{
343
- const auto symbol_expr = struct_symbol->symbol_expr ();
344
- const auto zero = zero_initializer (symbol_expr.type (), location, ns);
345
- CHECK_RETURN (zero.has_value ());
346
- const auto val = get_expr_value (symbol_expr, *zero, location);
347
-
348
- symbol_exprt dummy (" tmp" , pointer_type (symbol_expr.type ()));
349
- code_blockt assignments;
350
-
351
- const symbol_exprt new_symbol =
352
- to_symbol_expr (allocate_objects.allocate_automatic_local_object (
353
- assignments, dummy, symbol_expr.type ()));
354
-
355
- add_assignment (new_symbol, val);
356
- values[memory_location] = val;
357
303
return dereference_exprt{
358
304
plus_exprt{struct_symbol->symbol_expr (),
359
305
from_integer (member_offset, size_type ()),
0 commit comments