Skip to content

Commit 8ffed53

Browse files
Petr BauchPetr Bauch
Petr Bauch
authored and
Petr Bauch
committed
Search the JSON for symbol table
In case we get an array (and not an object) we first find the right object and then pass it to be converted.
1 parent 6869881 commit 8ffed53

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/goto-harness/memory_snapshot_harness_generator.cpp

+26-3
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,32 @@ void memory_snapshot_harness_generatort::get_memory_snapshot(
227227
throw deserialization_exceptiont("failed to read JSON memory snapshot");
228228
}
229229

230-
// throws a deserialization_exceptiont or an incorrect_goto_program_exceptiont
231-
// on failure to read JSON symbol table
232-
symbol_table_from_json(json, snapshot);
230+
if(json.is_array())
231+
{
232+
// since memory-analyzer produces an array JSON we need to search it
233+
// to find the first JSON object that is a symbol table
234+
const auto &jarr = to_json_array(json);
235+
for(auto const &arr_element : jarr)
236+
{
237+
if(!arr_element.is_object())
238+
continue;
239+
const auto &json_obj = to_json_object(arr_element);
240+
const auto it = json_obj.find("symbolTable");
241+
if(it != json_obj.end())
242+
{
243+
symbol_table_from_json(json_obj, snapshot);
244+
return;
245+
}
246+
}
247+
throw deserialization_exceptiont(
248+
"JSON memory snapshot does not contain symbol table");
249+
}
250+
else
251+
{
252+
// throws a deserialization_exceptiont or an incorrect_goto_program_exceptiont
253+
// on failure to read JSON symbol table
254+
symbol_table_from_json(json, snapshot);
255+
}
233256
}
234257

235258
void memory_snapshot_harness_generatort::generate(

0 commit comments

Comments
 (0)