Skip to content

Conversation

@Tim---
Copy link
Contributor

@Tim--- Tim--- commented Jan 25, 2023

The ProgramFlags are set by the program_from_* functions, and cannot be modified. This makes several features of drgn unavailable if used as a library.

This patch adds write access to the program flags.

In practice, I use qemu-system and gdb to debug a vmlinux.
Changing the program flags allows me to use a Program created with the default constructor to use Linux specific functions (eg: getting threads).

import gdb
from drgn import Architecture, Platform, Program, ProgramFlags

def read_mem(address, count, offset, physical):
    return gdb.inferiors()[0].read_memory(address, count)

prog = Program(Platform(Architecture.I386))
prog.flags |= ProgramFlags.IS_LINUX_KERNEL
prog.add_memory_segment(1, (1<<32)-1, read_mem)
prog.load_debug_info(['vmlinux'])

for thread in prog.threads():
    print(thread.object.comm)

The ProgramFlags are set by the program_from_* functions, and cannot be
modified. This makes several features of drgn unavailable if used as a
library.

This patch adds write access to the program flags.

Signed-off-by: Timothée Cocault <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant