-
Notifications
You must be signed in to change notification settings - Fork 6
Process tree visualizer #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
barisione
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get a minimal test in core for this?
| "help": "whatmap EXPRESSION -- Locate memory map containing EXPRESSION.\n\n\nExamples:\n\nwhatmap my_variable: looks up the map where my_variable is stored.\n\nwhatmap *0x1234: looks up the map containing the address 0x1234." | ||
| }, | ||
| "process-tree": { | ||
| "description": "Visualizes process trees from .undo recording files showing parent-child relationships.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The correct term is “Undo recordings”.
| "repo": "addons", | ||
| "script": "process_tree/process_tree.py", | ||
| "version_min": "9.1.0", | ||
| "help": "process-tree RECORDINGS_DIR [OPTIONS] -- Visualize process tree from .undo recordings.\n\n\nBy default, only ASCII tree output is shown. Use --output-svg to also generate an SVG.\n\n\nRequires 'undo' executable to be available on PATH.\n\n\nOptions:\n\n--output-svg FILE: Output SVG file path (generates SVG in addition to ASCII)\n\n\nExamples:\n\nprocess-tree /path/to/recordings\n\nprocess-tree /path/to/recordings --output-svg tree.svg" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here as well.
| print(f"Error processing {recording_file}: {e}", file=sys.stderr) | ||
| return None, None, 0.0 | ||
|
|
||
| def _run_recording_json(self, recording_file: Path, section: str) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be easier to get all the sections up front and use them when appropriate?
| ) | ||
|
|
||
|
|
||
| @dataclass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all the dataclasses could be frozen.
|
|
||
| y: int | ||
| line_start_x: int = 0 | ||
| fork_positions: List[ForkPosition] = field(default_factory=list) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use list[Foo] instead of List[Foo], Foo | None instead of Optional[Foo], and so on for Tuple, Dict, etc.
| raise gdb.GdbError("Usage: process-tree RECORDINGS_DIR [--output-svg FILE]") | ||
|
|
||
| # Parse arguments | ||
| args = shlex.split(argument) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to use gdb.string_to_argv.
| # Parse optional arguments | ||
| i = 1 | ||
| while i < len(args): | ||
| if args[i] == "--output-svg": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually, arguments in GDB use one dash. In UDB, we allow either one or two dashes. You could check this with a trivial regex.
| raise gdb.GdbError(f"Unknown argument: {args[i]}") | ||
|
|
||
| # Validate recordings directory | ||
| if not recordings_dir.exists() or not recordings_dir.is_dir(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just is_dir is enough.
| output_svg = str(Path(args[i + 1]).expanduser()) | ||
| i += 2 | ||
| else: | ||
| raise gdb.GdbError(f"Unknown argument: {args[i]}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not the nicest way to parse arguments, but our own arugment parsing is not in the public API, so this is fine.
| print(f"SVG visualization saved to: {output_file}") | ||
|
|
||
|
|
||
| class ProcessTreeVisualizer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be a class.
To coincide with the 9.1 release which contains --on-fork.