bbdynsize tutorial - build error

20 views
Skip to first unread message

Pavel Durov

unread,
Jun 1, 2023, 6:58:38 AM6/1/23
to DynamoRIO Users
I am following the bbdynsize tutorial: https://dynamorio.org/API_tutorial_bbdynsize4.html

DynamoRIO version: DynamoRIO-Linux-9.93.19503
OS: Ubuntu  x86_64 GNU/Linux

When I build it I get the following error:
bb_size_client.cpp:81:62: error: invalid conversion from ‘void (*)(uint)’ {aka ‘void (*)(unsigned int)’} to ‘void*’ [-fpermissive]
   81 |     dr_insert_clean_call(drcontext, bb, instrlist_first(bb), clean_call, false, 1, OPND_CREATE_INT32(num_instructions));
      |                                                              ^~~~~~~~~~
      |                                                              |
      |                                                              void (*)(uint) {aka void (*)(unsigned int)}

Should there be a cast to (void *) or am I getting it wrong:

-    dr_insert_clean_call(drcontext, bb, instrlist_first(bb), clean_call, false, 1, OPND_CREATE_INT32(num_instructions));

+    dr_insert_clean_call(drcontext, bb, instrlist_first(bb), (void *)clean_call, false, 1, OPND_CREATE_INT32(num_instructions))


Pavel Durov

unread,
Jun 1, 2023, 7:08:25 AM6/1/23
to DynamoRIO Users
I can see that there's the same cast in  Code Manipulation API, Clean Calls section documentation  https://dynamorio.org/API_BT.html#sec_IR

if (instr_is_mbr(instr)) {
  app_pc address = instr_get_app_pc(instr);
  uint opcode = instr_get_opcode(instr);
  instr_t *nxt = instr_get_next(instr);
  dr_insert_clean_call(drcontext, ilist, nxt, (void *) at_mbr,
                       false/*don't need to save fp state*/,
                       2 /* 2 parameters */,
                       /* opcode is 1st parameter */
                       OPND_CREATE_INT32(opcode),
                       /* address is 2nd parameter */
                       OPND_CREATE_INTPTR(address));
}

sharma...@google.com

unread,
Jun 1, 2023, 4:45:42 PM6/1/23
to DynamoRIO Users
Looks like you found the answer. Let us know if you have any other question.

Pavel Durov

unread,
Jun 2, 2023, 6:03:03 AM6/2/23
to DynamoRIO Users
Yeah, I found the answer.
But maybe we should fix the tutorial example so that future people won't have the same problem.
I am happy to submit a PR with the fix :)

sharma...@google.com

unread,
Jun 2, 2023, 9:43:31 AM6/2/23
to DynamoRIO Users
Yes that'd be helpful. Thanks.

Pavel Durov

unread,
Jun 5, 2023, 10:41:17 AM6/5/23
to DynamoRIO Users
Sounds good.
Created this PR https://github.com/DynamoRIO/dynamorio/pull/6111
Hopefully I found the right place for my changes :)
Reply all
Reply to author
Forward
0 new messages