Skip to content

Commit

Permalink
launch_lldb: cli: Force stop at entry when on launch
Browse files Browse the repository at this point in the history
  • Loading branch information
netanelc305 committed Jun 25, 2024
1 parent 5779d46 commit eac791f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ hilda launch /path/to/executable \
--stdout /path/to/output.txt \
--stderr /path/to/error.txt \
--wd /path/to/working/directory \
--flags 0x01 \
--stop-at-entry
--flags 0x01
```

### Bare mode
Expand Down
14 changes: 5 additions & 9 deletions hilda/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,16 @@ def attach(name: str, pid: int, startup_files: Optional[List[str]] = None) -> No
@click.option('--stderr', type=str, help='Redirect stderr to this file path')
@click.option('--cwd', type=str, help='Set the working directory for the process')
@click.option('--flags', type=click.INT, default=0, help='Launch flags (bitmask)')
@click.option('--stop-at-entry', is_flag=True, help='Stop the process at the entry point')
@startup_files_option
def launch(exec_path: str, argv: Optional[List] = None, envp: Optional[Mapping] = None,
stdin: Optional[Path] = None,
stdout: Optional[Path] = None, stderr: Optional[Path] = None, cwd: Optional[Path] = None,
flags: Optional[int] = 0, stop_at_entry: Optional[bool] = False,
flags: Optional[int] = 0,
startup_files: Optional[List[str]] = None) -> None:
""" Attach to given process and start a lldb shell """
if not argv:
argv = None
if not envp:
envp = None
launch_lldb.launch(exec_path, argv, envp, stdin, stdout, stderr, cwd, flags, stop_at_entry,
startup_files)
""" Attach to a given process and start a lldb shell """
argv = list(argv) if argv else None
envp = list(envp) if envp else None
launch_lldb.launch(exec_path, argv, envp, stdin, stdout, stderr, cwd, flags, startup_files)


@cli.command('bare')
Expand Down
14 changes: 6 additions & 8 deletions hilda/launch_lldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,12 @@ class LLDBLaunch(LLDBListenerThread):
def __init__(self, exec_path: str, argv: Optional[List[str]] = None, envp: Optional[List[str]] = None,
stdin: Optional[str] = None,
stdout: Optional[str] = None, stderr: Optional[str] = None, wd: Optional[str] = None,
flags: Optional[int] = 0, stop_at_entry: Optional[bool] = False):
flags: Optional[int] = 0):
self.exec_path = exec_path
self.stdout = stdout
self.stdin = stdin
self.stderr = stderr
self.flags = flags
self.stop_at_entry = stop_at_entry
self.argv = argv
self.envp = envp
self.working_directory = wd
Expand All @@ -157,7 +156,7 @@ def _create_process(self) -> lldb.SBProcess:
logger.debug(f'Lunching process {self.exec_path}')
return self.target.Launch(self.listener, self.argv, self.envp,
self.stdin, self.stdout, self.stderr, self.working_directory,
self.flags, self.stop_at_entry,
self.flags, True,
self.error)


Expand All @@ -173,7 +172,7 @@ def remote(hostname: str, port: int, startup_files: Optional[List[str]] = None)

def attach(name: Optional[str] = None, pid: Optional[int] = None, wait_for: bool = False,
startup_files: Optional[List[str]] = None) -> None:
""" Attach to given process and start a lldb shell """
""" Attach to a given process and start a lldb shell """
if (name is not None and pid is not None) or (name is None and pid is None):
raise ValueError('Provide either a process name or a PID, but not both.')

Expand All @@ -191,11 +190,10 @@ def attach(name: Optional[str] = None, pid: Optional[int] = None, wait_for: bool
def launch(exec_path: str, argv: Optional[List] = None, envp: Optional[List] = None,
stdin: Optional[str] = None,
stdout: Optional[str] = None, stderr: Optional[str] = None, wd: Optional[str] = None,
flags: Optional[int] = 0, stop_at_entry: Optional[bool] = False,
startup_files: Optional[List[str]] = None) -> None:
""" Launch to given process and start a lldb shell """
flags: Optional[int] = 0, startup_files: Optional[List[str]] = None) -> None:
""" Launch to a given process and start a lldb shell """
try:
lldb_t = LLDBLaunch(exec_path, argv, envp, stdin, stdout, stderr, wd, flags, stop_at_entry)
lldb_t = LLDBLaunch(exec_path, argv, envp, stdin, stdout, stderr, wd, flags)
lldb_t.start()
hilda(lldb_t.debugger, startup_files)
except LLDBException as e:
Expand Down

0 comments on commit eac791f

Please sign in to comment.