Adds the support of instrumentation events specific to opcode instructions to drmgr. In particular, two new API functions are introduced: drmgr_register_opcode_instrumentation_event() and drmgr_unregister_opcode_instrumentation_event().
drmgr_register_opcode_instrumentation_event() takes a call-back function and an opcode as input. The call-back is triggered during the insert per instruction stage (i.e., stage 3) only for those instructions that have the specified opcode.
Call-backs pertaining to an opcode are maintained via a hashtable.
Some care is taken to avoid any performance hits if opcode events are not registered. For instance, with the use of flags, the code avoids locking or hash-lookups if opcode events are never registered by the user.
In order to ensure call-backs pertaining to insert-bb and insert-opcode events are jointly triggered in the right order, with respect to their priorities, drmgr combines them into a single list on the fly by performing lookups. I avoided using one monolithic cb list as clients with a long list of different registered opcode events would have required drmgr to do wasteful iterations.
Fixes: #4280 (closed)