-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from doronz88/staging/next_major
Staging/next major
- Loading branch information
Showing
31 changed files
with
671 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# .pre-commit-config.yaml | ||
repos: | ||
- repo: https://github.com/pre-commit/mirrors-isort | ||
rev: v5.9.3 | ||
hooks: | ||
- id: isort | ||
args: [ '-m', 'HANGING_INDENT', '-l', '120','--check-only' ] | ||
files: \.py$ | ||
|
||
- repo: https://github.com/pycqa/flake8 | ||
rev: "7.0.0" | ||
hooks: | ||
- id: flake8 | ||
args: [ '--max-complexity=14', '--max-line-length=127' ] | ||
files: \.py$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
from hilda.launch_lldb import cli | ||
from hilda.cli import cli | ||
|
||
|
||
def main(): | ||
cli() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import logging | ||
from pathlib import Path | ||
from typing import List, Mapping, Optional | ||
|
||
import click | ||
import coloredlogs | ||
|
||
from hilda import launch_lldb | ||
from hilda._version import version | ||
|
||
DEFAULT_HILDA_PORT = 1234 | ||
|
||
coloredlogs.install(level=logging.DEBUG) | ||
|
||
|
||
@click.group() | ||
def cli(): | ||
pass | ||
|
||
|
||
startup_files_option = click.option('-f', '--startup_files', multiple=True, default=None, help='Files to run on start') | ||
|
||
|
||
def parse_envp(ctx: click.Context, param: click.Parameter, value: List[str]) -> List[str]: | ||
env_list = [] | ||
for item in value: | ||
try: | ||
key, val = item.split('=', 1) | ||
env_list.append(f'{key}={val}') | ||
except ValueError: | ||
raise click.BadParameter(f'Invalid format for --envp: {item}. Expected KEY=VALUE.') | ||
return env_list | ||
|
||
|
||
@cli.command('remote') | ||
@click.argument('hostname', default='localhost') | ||
@click.argument('port', type=click.INT, default=DEFAULT_HILDA_PORT) | ||
@startup_files_option | ||
def remote(hostname: str, port: int, startup_files: Optional[List[str]] = None) -> None: | ||
""" Connect to remote debugserver at given address """ | ||
launch_lldb.remote(hostname, port, startup_files) | ||
|
||
|
||
@cli.command('attach') | ||
@click.option('-n', '--name', help='process name to attach') | ||
@click.option('-p', '--pid', type=click.INT, help='pid to attach') | ||
@startup_files_option | ||
def attach(name: str, pid: int, startup_files: Optional[List[str]] = None) -> None: | ||
""" Attach to given process and start a lldb shell """ | ||
launch_lldb.attach(name=name, pid=pid, startup_files=startup_files) | ||
|
||
|
||
@cli.command('launch') | ||
@click.argument('exec_path') | ||
@click.option('--argv', multiple=True, help='Command line arguments to pass to the process') | ||
@click.option('--envp', multiple=True, callback=parse_envp, help='Environment variables in the form KEY=VALUE') | ||
@click.option('--stdin', type=Path, help='Redirect stdin from this file path') | ||
@click.option('--stdout', type=Path, help='Redirect stdout to this file path') | ||
@click.option('--stderr', type=Path, help='Redirect stderr to this file path') | ||
@click.option('--cwd', type=Path, 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, | ||
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) | ||
|
||
|
||
@cli.command('bare') | ||
def cli_bare(): | ||
""" Just start a lldb shell """ | ||
commands = [f'command script import {Path(__file__).resolve().parent / "lldb_entrypoint.py"}'] | ||
commands = '\n'.join(commands) | ||
launch_lldb.execute(f'lldb --one-line "{commands}"') | ||
|
||
|
||
@cli.command('version') | ||
def cli_version(): | ||
"""Show the version information.""" | ||
click.echo(version) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.