Splitting Basic Block

66 views
Skip to first unread message

Stefano Carnà

unread,
Jan 31, 2024, 10:48:38 AMJan 31
to DynamoRIO Users
Hi all,
does anyone know if there is a way to split a basic block into 2 basic blocks?
Somehow I'd like to obtain the same result of what dynamorio does when the max_bb_instrs option is enabled.

Thanks

Abhinav Sharma

unread,
Jan 31, 2024, 10:55:50 AMJan 31
to DynamoRIO Users
Hi,
You can just remove the later instructions of the basic block from the given instrlist_t in the app2app phase. E.g., see the documentation and implementation of scatter_gather_split_bb (https://github.com/DynamoRIO/dynamorio/blob/34898ced2242ad8e52a1354391c01cd2a1f84e40/ext/drx/scatter_gather_shared.c#L58).

Abhinav

Stefano Carnà

unread,
Jan 31, 2024, 12:37:08 PMJan 31
to DynamoRIO Users
Thank you! That example is what I was looking for.
Working in the app2app phase I can easily split the BB and add my own instructions. However, it seems that if I try to add some instructions at the beginning of the BB and then removing following instructions (i.e., the whole original BB), the first instruction from the BB is completely removed (not being part of the next instrlist during app2app callback).

Is there a way to prepend a handcraft BB (non meta instructions) to any app BBs?

Abhinav Sharma

unread,
Jan 31, 2024, 1:16:36 PMJan 31
to Stefano Carnà, DynamoRIO Users
> That example is what I was looking for.

Good to know that helped.

> However, it seems that if I try to add some instructions at the beginning of the BB and then removing following instructions (i.e., the whole original BB), the first instruction from the BB is completely removed (not being part of the next instrlist during app2app callback).

For any added non-meta instructions, you should use instr_set_translation (https://dynamorio.org/dr__ir__instr_8h.html#a463d5a15e50d1578dce60bc44343eb1a). Generally you can set it to the pc of the next app instr that you're keeping in the BB. But this is tricky if you're removing the whole original BB (what would you set the translation app_pc to?).

Can you give more details on why you want to remove the whole original BB, and why the instructions you're adding cannot be added as  meta instructions?

Abhinav

--
You received this message because you are subscribed to the Google Groups "DynamoRIO Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dynamorio-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dynamorio-users/863608db-99a1-4223-a219-345a5487290cn%40googlegroups.com.

Stefano Carnà

unread,
Feb 1, 2024, 4:58:56 AMFeb 1
to DynamoRIO Users
I understand your point. Actually I wanted to assess a bit the capabilities of dynamorio and see what I can/cannot do. Most likely meta instructions are enough to address my problems.

Thank you,
Stefano
Reply all
Reply to author
Forward
0 new messages