Skip to content

Conversation

@smokeysa
Copy link
Contributor

To coincide with the 9.1 release which contains --on-fork.

@barisione barisione self-assigned this Nov 27, 2025
Copy link
Collaborator

@barisione barisione left a 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.",
Copy link
Collaborator

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"
Copy link
Collaborator

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:
Copy link
Collaborator

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
Copy link
Collaborator

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)
Copy link
Collaborator

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)
Copy link
Collaborator

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":
Copy link
Collaborator

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():
Copy link
Collaborator

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]}")
Copy link
Collaborator

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:
Copy link
Collaborator

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.

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.

2 participants