Now we register for events we'll need. For our first pass we only need to register for the bb event (to add our instrumentation) and the exit event (to display the results). We don't need to register for trace events (as we will add our instrumentation to the constituent bbs) and we can ignore the for_trace and translating arguments to the basic block callback as our changes are deterministic and idempotent so DynamoRIO default translation will work fine.

#include "dr_api.h"

+ static void
+ event_exit(void);
+ static dr_emit_flags_t
+ event_basic_block(void *drcontext, void *tag, instrlist_t *bb,
+                   bool for_trace, bool translating);

DR_EXPORT void 
dr_init(client_id_t id)
{
+     /* register events */
+     dr_register_exit_event(event_exit);
+     dr_register_bb_event(event_basic_block);
}

+ static void
+ event_exit(void)
+ {
+     /* empty */
+ }
+ 
+ static dr_emit_flags_t
+ event_basic_block(void *drcontext, void *tag, instrlist_t *bb,
+                   bool for_trace, bool translating)
+ {
+     /* empty */
+     return DR_EMIT_DEFAULT;
+ }

[ prev | next ]


  DynamoRIO API version 2.0.0 --- Thu Apr 22 00:18:19 2010