#!/usr/bin/env python3
import sys
import argparse
import time
def main():
parser = argparse.ArgumentParser()
parser.add_argument('args', nargs='*')
args, unknown = parser.parse_known_args()
# Mimic drgn startup
# drgn usually takes a core dump as argument or attaches to running kernel
# python3 -m drgn -c vmcore -s vmlinux
print("drgn 0.0.25 (using Python 3.10.12, without libkdumpfile)")
print("For help, type help(drgn).")
# Simple REPL similar to python's but with specific behavior if needed
prompt = ">>> "
while True:
try:
sys.stdout.write(prompt)
sys.stdout.flush()
line = sys.stdin.readline()
if not line:
break
cmd = line.strip()
if cmd in ['quit()', 'exit()']:
break
if cmd == 'prog':
# Simulate printing the program object
print("CoreDump(prog, '/path/to/vmcore')")
elif cmd == 'task = find_task(prog, 1)':
# Simulate finding a task
pass # No output, just assignment
elif cmd == 'task.comm':
print("(char [16])\"systemd\"")
elif cmd:
# Echo for verification in tests
print(f"mock output: {cmd}")
except KeyboardInterrupt:
print("\nKeyboardInterrupt")
continue
if __name__ == "__main__":
main()