@@ -391,6 +391,37 @@ static void instrument_get_current_thread_id(
391
391
code = code_assign;
392
392
}
393
393
394
+ // / Transforms the codet stored in in \p f_code, which is a call to function
395
+ // / CProver.getMonitorCount:(Ljava/lang/Object;)I into a
396
+ // / code_assignt that assigns the cproverMonitorCount field of the
397
+ // / java.lang.Object argument passed to getMonitorCount.
398
+ // /
399
+ // / The resulting codet is stored in the output parameter \p code.
400
+ // /
401
+ // / \param f_code: call to CProver.getMonitorCount:(Ljava/lang/Object;)I
402
+ // / \param [out] code: resulting transformation
403
+ // / \param symbol_table: a symbol table
404
+ static void instrument_get_monitor_count (
405
+ const code_function_callt &f_code,
406
+ codet &code,
407
+ symbol_tablet &symbol_table)
408
+ {
409
+ PRECONDITION (f_code.arguments ().size () == 1 );
410
+
411
+ const namespacet ns (symbol_table);
412
+ const auto &followed_type =
413
+ ns.follow (to_pointer_type (f_code.arguments ()[0 ].type ()).subtype ());
414
+ const auto &object_type = to_struct_type (followed_type);
415
+ code_assignt code_assign (
416
+ f_code.lhs (),
417
+ member_exprt (
418
+ dereference_exprt (f_code.arguments ()[0 ]),
419
+ object_type.get_component (" cproverMonitorCount" )));
420
+ code_assign.add_source_location () = f_code.source_location ();
421
+
422
+ code = code_assign;
423
+ }
424
+
394
425
// / Iterate through the symbol table to find and appropriately instrument
395
426
// / thread-blocks.
396
427
// /
@@ -501,6 +532,13 @@ void convert_threadblock(symbol_tablet &symbol_table)
501
532
std::placeholders::_1,
502
533
std::placeholders::_2,
503
534
std::placeholders::_3);
535
+ else if (
536
+ f_name == " org.cprover.CProver.getMonitorCount:(Ljava/lang/Object;)I" )
537
+ cb = std::bind (
538
+ &instrument_get_monitor_count,
539
+ std::placeholders::_1,
540
+ std::placeholders::_2,
541
+ std::placeholders::_3);
504
542
505
543
if (cb)
506
544
expr_replacement_map.insert ({expr, cb});
0 commit comments