Skip to content

Commit

Permalink
Define ppc, ppc64le, arm, and aarch64 regs
Browse files Browse the repository at this point in the history
  • Loading branch information
mephi42 committed Aug 15, 2024
1 parent 93b2b38 commit e2dad47
Show file tree
Hide file tree
Showing 2 changed files with 578 additions and 0 deletions.
45 changes: 45 additions & 0 deletions valgrind-tracer/generate-regs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env python3
import os.path

from clang.cindex import Index


def iter_subtree(node):
yield node
for child_node in node.get_children():
yield from iter_subtree(child_node)


def find_struct_state(node):
for subtree_node in iter_subtree(node):
if subtree_node.spelling == "VexGuestArchState":
return subtree_node.type.get_canonical()
return None


def main():
basedir = os.path.dirname(__file__)
valgrind = os.path.join(basedir, "..", "valgrind")
for arch in [
"VGA_x86",
"VGA_amd64",
"VGA_ppc64be",
"VGA_ppc64le",
"VGA_arm",
"VGA_arm64",
"VGA_s390x",
]:
print(f"#if defined({arch})")
index = Index.create()
tu = index.parse(
os.path.join(valgrind, "include", "pub_tool_guest.h"),
[f"-D{arch}", "-I" + os.path.join(valgrind, "VEX", "pub")],
)
struct_state = find_struct_state(tu.cursor)
for field in struct_state.get_fields():
print(f" DEFINE_REG({field.spelling}),")
print("#endif")


if __name__ == "__main__":
main()
Loading

0 comments on commit e2dad47

Please sign in to comment.