hilda 1.4.3__tar.gz → 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hilda-1.4.3 → hilda-2.0.0}/.github/workflows/python-app.yml +11 -11
- hilda-2.0.0/.pre-commit-config.yaml +15 -0
- {hilda-1.4.3 → hilda-2.0.0}/PKG-INFO +82 -28
- {hilda-1.4.3 → hilda-2.0.0}/README.md +80 -27
- hilda-2.0.0/hilda/__main__.py +9 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/_version.py +2 -2
- hilda-2.0.0/hilda/cli.py +89 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/exceptions.py +9 -1
- {hilda-1.4.3 → hilda-2.0.0}/hilda/hilda_client.py +101 -118
- hilda-2.0.0/hilda/ipython_extensions/events.py +53 -0
- hilda-2.0.0/hilda/ipython_extensions/keybindings.py +22 -0
- hilda-2.0.0/hilda/ipython_extensions/magics.py +40 -0
- hilda-2.0.0/hilda/launch_lldb.py +189 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/lldb_entrypoint.py +2 -2
- hilda-2.0.0/hilda/lldb_importer.py +23 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/objective_c_class.py +2 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/objective_c_symbol.py +2 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/boringssl.py +1 -1
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/dyld.py +1 -1
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/fs_utils.py +1 -1
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/mach/CFRunLoopServiceMachPort_hooks.py +1 -2
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/macho/all_image_infos.py +1 -1
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/macho/image_info.py +1 -1
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/macho/macho_load_commands.py +1 -1
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/remotepairingd.py +1 -1
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/xpc.py +1 -1
- {hilda-1.4.3 → hilda-2.0.0}/hilda/symbol.py +1 -1
- {hilda-1.4.3 → hilda-2.0.0}/hilda/symbols_jar.py +8 -4
- {hilda-1.4.3 → hilda-2.0.0}/hilda.egg-info/PKG-INFO +82 -28
- {hilda-1.4.3 → hilda-2.0.0}/hilda.egg-info/SOURCES.txt +6 -3
- {hilda-1.4.3 → hilda-2.0.0}/pyproject.toml +2 -1
- hilda-2.0.0/tests/conftest.py +32 -0
- hilda-1.4.3/hilda/__main__.py +0 -5
- hilda-1.4.3/hilda/launch_lldb.py +0 -85
- hilda-1.4.3/tests/__main__.py +0 -4
- hilda-1.4.3/tests/conftest.py +0 -13
- hilda-1.4.3/tests/hilda_tests.py +0 -17
- hilda-1.4.3/tests/lldb_entrypoint.py +0 -33
- {hilda-1.4.3 → hilda-2.0.0}/.github/workflows/python-publish.yml +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/.gitignore +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/LICENSE +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/gifs/.gitattributes +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/gifs/ui.png +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/gifs/xpc_print_message.gif +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/__init__.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/common.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/hilda_ascii_art.html +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/objective_c/from_ns_to_json.m +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/objective_c/get_objectivec_class_by_module.m +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/objective_c/get_objectivec_class_description.m +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/objective_c/get_objectivec_symbol_data.m +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/objective_c/lsof.m +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/objective_c/to_ns_from_json.m +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/registers.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/__init__.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/collections.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/mach/__init__.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/macho/__init__.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/macho/apple_version.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/macho/macho.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/syslog.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/snippets/uuid.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/ui/colors.json +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/ui/ui_manager.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda/ui/views.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda.egg-info/dependency_links.txt +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda.egg-info/entry_points.txt +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda.egg-info/requires.txt +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/hilda.egg-info/top_level.txt +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/requirements.txt +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/setup.cfg +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/tests/__init__.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/tests/test_hilda_client/test_from_ns.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/tests/test_hilda_client/test_hilda_client.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/tests/test_hilda_client/test_monitor.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/tests/test_hilda_client/test_ns.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/tests/test_hilda_client/test_rebind_symbols.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/tests/test_hilda_client/test_registers.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/tests/test_snippets/test_xpc.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/tests/test_symbols/test_objective_c_class.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/tests/test_symbols/test_objective_c_symbol.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/tests/test_symbols/test_symbol.py +0 -0
- {hilda-1.4.3 → hilda-2.0.0}/tests/test_symbols/test_symbols_jar.py +0 -0
|
@@ -17,7 +17,7 @@ jobs:
|
|
|
17
17
|
strategy:
|
|
18
18
|
matrix:
|
|
19
19
|
python-version: [ 3.8, 3.9, "3.10", "3.11", "3.12" ]
|
|
20
|
-
os: [
|
|
20
|
+
os: [ macos-latest ]
|
|
21
21
|
|
|
22
22
|
steps:
|
|
23
23
|
- uses: actions/checkout@v3
|
|
@@ -25,18 +25,18 @@ jobs:
|
|
|
25
25
|
uses: actions/setup-python@v4
|
|
26
26
|
with:
|
|
27
27
|
python-version: ${{ matrix.python-version }}
|
|
28
|
-
- name:
|
|
28
|
+
- name: Install dependencies
|
|
29
29
|
run: |
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
- name:
|
|
30
|
+
python3 -m pip install --upgrade pip
|
|
31
|
+
python3 -m pip install pre-commit
|
|
32
|
+
- name: Run pre-commit hooks
|
|
33
33
|
run: |
|
|
34
|
-
|
|
35
|
-
isort . -m HANGING_INDENT -l 120 --check-only
|
|
34
|
+
pre-commit run --all-files
|
|
36
35
|
- name: Test install
|
|
37
36
|
run: |
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
xcrun python3 -m pip install --upgrade pip
|
|
38
|
+
xcrun python3 -m pip install -r requirements.txt
|
|
39
|
+
xcrun python3 -m pip install -e ".[test]"
|
|
40
|
+
- name: Run pytest
|
|
41
41
|
run: |
|
|
42
|
-
|
|
42
|
+
sudo xcrun python3 -m pytest -k "not set_implementation"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# .pre-commit-config.yaml
|
|
2
|
+
repos:
|
|
3
|
+
- repo: https://github.com/pre-commit/mirrors-isort
|
|
4
|
+
rev: v5.9.3
|
|
5
|
+
hooks:
|
|
6
|
+
- id: isort
|
|
7
|
+
args: [ '-m', 'HANGING_INDENT', '-l', '120','--check-only' ]
|
|
8
|
+
files: \.py$
|
|
9
|
+
|
|
10
|
+
- repo: https://github.com/pycqa/flake8
|
|
11
|
+
rev: "7.0.0"
|
|
12
|
+
hooks:
|
|
13
|
+
- id: flake8
|
|
14
|
+
args: [ '--max-complexity=14', '--max-line-length=127' ]
|
|
15
|
+
files: \.py$
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hilda
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: LLDB wrapped and empowered by iPython's features
|
|
5
5
|
Author-email: doronz88 <doron88@gmail.com>, matan <matan1008@gmail.com>, netanel cohen <netanelc305@protonmail.com>
|
|
6
6
|
Maintainer-email: doronz88 <doron88@gmail.com>, matan <matan1008@gmail.com>, netanel cohen <netanelc305@protonmail.com>
|
|
@@ -27,6 +27,7 @@ License: Copyright (c) 2012-2023 Doron Zarhi and Metan Perelman
|
|
|
27
27
|
Project-URL: Homepage, https://github.com/doronz88/hilda
|
|
28
28
|
Project-URL: Bug Reports, https://github.com/doronz88/hilda/issues
|
|
29
29
|
Keywords: python,debugger,lldb,ipython,ios,debug
|
|
30
|
+
Classifier: Operating System :: MacOS
|
|
30
31
|
Classifier: Development Status :: 5 - Production/Stable
|
|
31
32
|
Classifier: License :: OSI Approved :: MIT License
|
|
32
33
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -56,18 +57,29 @@ Requires-Dist: pytest; extra == "test"
|
|
|
56
57
|
- [Description](#description)
|
|
57
58
|
- [Installation](#installation)
|
|
58
59
|
- [How to use](#how-to-use)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
- [Starting a Hilda shell](#starting-a-hilda-shell)
|
|
61
|
+
- [Attach mode](#attach-mode)
|
|
62
|
+
- [Launch mode](#launch-mode)
|
|
63
|
+
- [Bare mode](#bare-mode)
|
|
64
|
+
- [Remote mode](#remote-mode)
|
|
65
|
+
- [The connected device is connected via network](#the-connected-device-is-connected-via-network)
|
|
66
|
+
- [Startup Files](#startup-files)
|
|
67
|
+
- [Usage](#usage)
|
|
68
|
+
- [Magic functions](#magic-functions)
|
|
69
|
+
- [Shortcuts](#shortcuts)
|
|
70
|
+
- [Configurables](#configurables)
|
|
71
|
+
- [Attributes](#attributes)
|
|
72
|
+
- [Example Usage](#example-usage)
|
|
73
|
+
- [UI Configuration](#ui-configuration)
|
|
74
|
+
- [Symbol objects](#symbol-objects)
|
|
75
|
+
- [Globalized symbols](#globalized-symbols)
|
|
65
76
|
- [Searching for the right symbol](#searching-for-the-right-symbol)
|
|
77
|
+
- [Objective-C Classes](#objective-c-classes)
|
|
78
|
+
- [Objective-C Objects](#objective-c-objects)
|
|
79
|
+
- [Using snippets](#using-snippets)
|
|
80
|
+
- [Contributing](#contributing)
|
|
66
81
|
|
|
67
|
-
|
|
68
|
-
* [Objective-C Objects](#objective-c-objects)
|
|
69
|
-
* [Using snippets](#using-snippets)
|
|
70
|
-
* [Contributing](#contributing)
|
|
82
|
+
Would you like any further adjustments?
|
|
71
83
|
|
|
72
84
|
# Description
|
|
73
85
|
|
|
@@ -121,7 +133,21 @@ Use the attach sub-command in order to start an LLDB shell attached to given pro
|
|
|
121
133
|
hilda attach [-p pid] [-n process-name]
|
|
122
134
|
```
|
|
123
135
|
|
|
124
|
-
|
|
136
|
+
### Launch mode
|
|
137
|
+
|
|
138
|
+
Use the attach sub-command in order to launch given process.
|
|
139
|
+
|
|
140
|
+
```shell
|
|
141
|
+
hilda launch /path/to/executable \
|
|
142
|
+
--argv arg1 --argv arg2 \
|
|
143
|
+
--envp NAME=Alice --envp AGE=30 \
|
|
144
|
+
--stdin /path/to/input.txt \
|
|
145
|
+
--stdout /path/to/output.txt \
|
|
146
|
+
--stderr /path/to/error.txt \
|
|
147
|
+
--wd /path/to/working/directory \
|
|
148
|
+
--flags 0x01 \
|
|
149
|
+
--stop-at-entry
|
|
150
|
+
```
|
|
125
151
|
|
|
126
152
|
### Bare mode
|
|
127
153
|
|
|
@@ -175,6 +201,23 @@ Run the following command:
|
|
|
175
201
|
hilda remote HOSTNAME PORT
|
|
176
202
|
```
|
|
177
203
|
|
|
204
|
+
## Startup Files
|
|
205
|
+
|
|
206
|
+
Each command can accept startup files to execute on start. As opposed to snippets, the startup files can accept Hilda
|
|
207
|
+
syntax.
|
|
208
|
+
|
|
209
|
+
#### Startup File Example
|
|
210
|
+
|
|
211
|
+
```python
|
|
212
|
+
cfg.objc_verbose_monitor = True
|
|
213
|
+
p.bp(ADDRESS)
|
|
214
|
+
p.cont()
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
```shell
|
|
218
|
+
hilda remote HOSTNAME PORT -f startupfile1 -f startupfile2
|
|
219
|
+
```
|
|
220
|
+
|
|
178
221
|
## Usage
|
|
179
222
|
|
|
180
223
|
Upon starting Hilda shell, you are greeted with:
|
|
@@ -325,17 +368,6 @@ Here is a gist of methods you can access from `p`:
|
|
|
325
368
|
evaluate_expression(f'[[{currentDevice} systemName] hasPrefix:@"2"]')
|
|
326
369
|
- `import_module`
|
|
327
370
|
- Import & reload given python module (intended mainly for external snippets)
|
|
328
|
-
- `set_evaluation_unwind`
|
|
329
|
-
- Set whether LLDB will attempt to unwind the stack whenever an expression evaluation error occurs.
|
|
330
|
-
Use unwind() to restore when an error is raised in this case.
|
|
331
|
-
- `get_evaluation_unwind`
|
|
332
|
-
- Get evaluation unwind state.
|
|
333
|
-
When this value is True, LLDB will attempt unwinding the stack on evaluation errors.
|
|
334
|
-
Otherwise, the stack frame will remain the same on errors to help you investigate the error.
|
|
335
|
-
- `set_evaluation_ignore_breakpoints`
|
|
336
|
-
- Set whether to ignore breakpoints while evaluating expressions
|
|
337
|
-
- `get_evaluation_ignore_breakpoints`
|
|
338
|
-
- Get evaluation "ignore-breakpoints" state.
|
|
339
371
|
- `unwind`
|
|
340
372
|
- Unwind the stack (useful when get_evaluation_unwind() == False)
|
|
341
373
|
|
|
@@ -348,6 +380,32 @@ Sometimes accessing the python API can be tiring, so we added some magic functio
|
|
|
348
380
|
- `%fbp <filename> <addressInHex>`
|
|
349
381
|
- Equivalent to: `p.file_symbol(addressInHex, filename).bp()`
|
|
350
382
|
|
|
383
|
+
## Shortcuts
|
|
384
|
+
|
|
385
|
+
- **F7**: Step Into
|
|
386
|
+
- **F8**: Step Over
|
|
387
|
+
- **F9**: Continue
|
|
388
|
+
- **F10**: Stop
|
|
389
|
+
|
|
390
|
+
## Configurables
|
|
391
|
+
|
|
392
|
+
The global `cfg` used to configure various settings for evaluation and monitoring.
|
|
393
|
+
|
|
394
|
+
### Attributes
|
|
395
|
+
|
|
396
|
+
- `evaluation_unwind_on_error`: Whether to unwind on error during evaluation. (Default: `False`)
|
|
397
|
+
- `evaluation_ignore_breakpoints`: Whether to ignore breakpoints during evaluation. (Default: `False`)
|
|
398
|
+
- `nsobject_exclusion`: Whether to exclude `NSObject` during evaluation, reducing IPython autocomplete results. (
|
|
399
|
+
Default: `False`)
|
|
400
|
+
- `objc_verbose_monitor`: When set to `True`, using `monitor()` will automatically print Objective-C method arguments. (
|
|
401
|
+
Default: `False`)
|
|
402
|
+
|
|
403
|
+
### Example Usage
|
|
404
|
+
|
|
405
|
+
```python
|
|
406
|
+
cfg.objc_verbose_monitor = True
|
|
407
|
+
```
|
|
408
|
+
|
|
351
409
|
## UI Configuration
|
|
352
410
|
|
|
353
411
|
Hilda contains minimal UI for examining the target state.
|
|
@@ -705,9 +763,5 @@ This will monitor all XPC related traffic in the given process.
|
|
|
705
763
|
Please run the tests as follows before submitting a PR:
|
|
706
764
|
|
|
707
765
|
```shell
|
|
708
|
-
xcrun python3 -m
|
|
709
|
-
|
|
710
|
-
# wait for lldb shell prompt
|
|
711
|
-
|
|
712
|
-
run_tests
|
|
766
|
+
xcrun python3 -m pytest
|
|
713
767
|
```
|
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
- [Description](#description)
|
|
2
2
|
- [Installation](#installation)
|
|
3
3
|
- [How to use](#how-to-use)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
- [Starting a Hilda shell](#starting-a-hilda-shell)
|
|
5
|
+
- [Attach mode](#attach-mode)
|
|
6
|
+
- [Launch mode](#launch-mode)
|
|
7
|
+
- [Bare mode](#bare-mode)
|
|
8
|
+
- [Remote mode](#remote-mode)
|
|
9
|
+
- [The connected device is connected via network](#the-connected-device-is-connected-via-network)
|
|
10
|
+
- [Startup Files](#startup-files)
|
|
11
|
+
- [Usage](#usage)
|
|
12
|
+
- [Magic functions](#magic-functions)
|
|
13
|
+
- [Shortcuts](#shortcuts)
|
|
14
|
+
- [Configurables](#configurables)
|
|
15
|
+
- [Attributes](#attributes)
|
|
16
|
+
- [Example Usage](#example-usage)
|
|
17
|
+
- [UI Configuration](#ui-configuration)
|
|
18
|
+
- [Symbol objects](#symbol-objects)
|
|
19
|
+
- [Globalized symbols](#globalized-symbols)
|
|
10
20
|
- [Searching for the right symbol](#searching-for-the-right-symbol)
|
|
21
|
+
- [Objective-C Classes](#objective-c-classes)
|
|
22
|
+
- [Objective-C Objects](#objective-c-objects)
|
|
23
|
+
- [Using snippets](#using-snippets)
|
|
24
|
+
- [Contributing](#contributing)
|
|
11
25
|
|
|
12
|
-
|
|
13
|
-
* [Objective-C Objects](#objective-c-objects)
|
|
14
|
-
* [Using snippets](#using-snippets)
|
|
15
|
-
* [Contributing](#contributing)
|
|
26
|
+
Would you like any further adjustments?
|
|
16
27
|
|
|
17
28
|
# Description
|
|
18
29
|
|
|
@@ -66,7 +77,21 @@ Use the attach sub-command in order to start an LLDB shell attached to given pro
|
|
|
66
77
|
hilda attach [-p pid] [-n process-name]
|
|
67
78
|
```
|
|
68
79
|
|
|
69
|
-
|
|
80
|
+
### Launch mode
|
|
81
|
+
|
|
82
|
+
Use the attach sub-command in order to launch given process.
|
|
83
|
+
|
|
84
|
+
```shell
|
|
85
|
+
hilda launch /path/to/executable \
|
|
86
|
+
--argv arg1 --argv arg2 \
|
|
87
|
+
--envp NAME=Alice --envp AGE=30 \
|
|
88
|
+
--stdin /path/to/input.txt \
|
|
89
|
+
--stdout /path/to/output.txt \
|
|
90
|
+
--stderr /path/to/error.txt \
|
|
91
|
+
--wd /path/to/working/directory \
|
|
92
|
+
--flags 0x01 \
|
|
93
|
+
--stop-at-entry
|
|
94
|
+
```
|
|
70
95
|
|
|
71
96
|
### Bare mode
|
|
72
97
|
|
|
@@ -120,6 +145,23 @@ Run the following command:
|
|
|
120
145
|
hilda remote HOSTNAME PORT
|
|
121
146
|
```
|
|
122
147
|
|
|
148
|
+
## Startup Files
|
|
149
|
+
|
|
150
|
+
Each command can accept startup files to execute on start. As opposed to snippets, the startup files can accept Hilda
|
|
151
|
+
syntax.
|
|
152
|
+
|
|
153
|
+
#### Startup File Example
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
cfg.objc_verbose_monitor = True
|
|
157
|
+
p.bp(ADDRESS)
|
|
158
|
+
p.cont()
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
```shell
|
|
162
|
+
hilda remote HOSTNAME PORT -f startupfile1 -f startupfile2
|
|
163
|
+
```
|
|
164
|
+
|
|
123
165
|
## Usage
|
|
124
166
|
|
|
125
167
|
Upon starting Hilda shell, you are greeted with:
|
|
@@ -270,17 +312,6 @@ Here is a gist of methods you can access from `p`:
|
|
|
270
312
|
evaluate_expression(f'[[{currentDevice} systemName] hasPrefix:@"2"]')
|
|
271
313
|
- `import_module`
|
|
272
314
|
- Import & reload given python module (intended mainly for external snippets)
|
|
273
|
-
- `set_evaluation_unwind`
|
|
274
|
-
- Set whether LLDB will attempt to unwind the stack whenever an expression evaluation error occurs.
|
|
275
|
-
Use unwind() to restore when an error is raised in this case.
|
|
276
|
-
- `get_evaluation_unwind`
|
|
277
|
-
- Get evaluation unwind state.
|
|
278
|
-
When this value is True, LLDB will attempt unwinding the stack on evaluation errors.
|
|
279
|
-
Otherwise, the stack frame will remain the same on errors to help you investigate the error.
|
|
280
|
-
- `set_evaluation_ignore_breakpoints`
|
|
281
|
-
- Set whether to ignore breakpoints while evaluating expressions
|
|
282
|
-
- `get_evaluation_ignore_breakpoints`
|
|
283
|
-
- Get evaluation "ignore-breakpoints" state.
|
|
284
315
|
- `unwind`
|
|
285
316
|
- Unwind the stack (useful when get_evaluation_unwind() == False)
|
|
286
317
|
|
|
@@ -293,6 +324,32 @@ Sometimes accessing the python API can be tiring, so we added some magic functio
|
|
|
293
324
|
- `%fbp <filename> <addressInHex>`
|
|
294
325
|
- Equivalent to: `p.file_symbol(addressInHex, filename).bp()`
|
|
295
326
|
|
|
327
|
+
## Shortcuts
|
|
328
|
+
|
|
329
|
+
- **F7**: Step Into
|
|
330
|
+
- **F8**: Step Over
|
|
331
|
+
- **F9**: Continue
|
|
332
|
+
- **F10**: Stop
|
|
333
|
+
|
|
334
|
+
## Configurables
|
|
335
|
+
|
|
336
|
+
The global `cfg` used to configure various settings for evaluation and monitoring.
|
|
337
|
+
|
|
338
|
+
### Attributes
|
|
339
|
+
|
|
340
|
+
- `evaluation_unwind_on_error`: Whether to unwind on error during evaluation. (Default: `False`)
|
|
341
|
+
- `evaluation_ignore_breakpoints`: Whether to ignore breakpoints during evaluation. (Default: `False`)
|
|
342
|
+
- `nsobject_exclusion`: Whether to exclude `NSObject` during evaluation, reducing IPython autocomplete results. (
|
|
343
|
+
Default: `False`)
|
|
344
|
+
- `objc_verbose_monitor`: When set to `True`, using `monitor()` will automatically print Objective-C method arguments. (
|
|
345
|
+
Default: `False`)
|
|
346
|
+
|
|
347
|
+
### Example Usage
|
|
348
|
+
|
|
349
|
+
```python
|
|
350
|
+
cfg.objc_verbose_monitor = True
|
|
351
|
+
```
|
|
352
|
+
|
|
296
353
|
## UI Configuration
|
|
297
354
|
|
|
298
355
|
Hilda contains minimal UI for examining the target state.
|
|
@@ -650,9 +707,5 @@ This will monitor all XPC related traffic in the given process.
|
|
|
650
707
|
Please run the tests as follows before submitting a PR:
|
|
651
708
|
|
|
652
709
|
```shell
|
|
653
|
-
xcrun python3 -m
|
|
654
|
-
|
|
655
|
-
# wait for lldb shell prompt
|
|
656
|
-
|
|
657
|
-
run_tests
|
|
710
|
+
xcrun python3 -m pytest
|
|
658
711
|
```
|
hilda-2.0.0/hilda/cli.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import List, Mapping, Optional
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
import coloredlogs
|
|
7
|
+
|
|
8
|
+
from hilda import launch_lldb
|
|
9
|
+
from hilda._version import version
|
|
10
|
+
|
|
11
|
+
DEFAULT_HILDA_PORT = 1234
|
|
12
|
+
|
|
13
|
+
coloredlogs.install(level=logging.DEBUG)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@click.group()
|
|
17
|
+
def cli():
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
startup_files_option = click.option('-f', '--startup_files', multiple=True, default=None, help='Files to run on start')
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def parse_envp(ctx: click.Context, param: click.Parameter, value: List[str]) -> List[str]:
|
|
25
|
+
env_list = []
|
|
26
|
+
for item in value:
|
|
27
|
+
try:
|
|
28
|
+
key, val = item.split('=', 1)
|
|
29
|
+
env_list.append(f'{key}={val}')
|
|
30
|
+
except ValueError:
|
|
31
|
+
raise click.BadParameter(f'Invalid format for --envp: {item}. Expected KEY=VALUE.')
|
|
32
|
+
return env_list
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@cli.command('remote')
|
|
36
|
+
@click.argument('hostname', default='localhost')
|
|
37
|
+
@click.argument('port', type=click.INT, default=DEFAULT_HILDA_PORT)
|
|
38
|
+
@startup_files_option
|
|
39
|
+
def remote(hostname: str, port: int, startup_files: Optional[List[str]] = None) -> None:
|
|
40
|
+
""" Connect to remote debugserver at given address """
|
|
41
|
+
launch_lldb.remote(hostname, port, startup_files)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@cli.command('attach')
|
|
45
|
+
@click.option('-n', '--name', help='process name to attach')
|
|
46
|
+
@click.option('-p', '--pid', type=click.INT, help='pid to attach')
|
|
47
|
+
@startup_files_option
|
|
48
|
+
def attach(name: str, pid: int, startup_files: Optional[List[str]] = None) -> None:
|
|
49
|
+
""" Attach to given process and start a lldb shell """
|
|
50
|
+
launch_lldb.attach(name=name, pid=pid, startup_files=startup_files)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@cli.command('launch')
|
|
54
|
+
@click.argument('exec_path')
|
|
55
|
+
@click.option('--argv', multiple=True, help='Command line arguments to pass to the process')
|
|
56
|
+
@click.option('--envp', multiple=True, callback=parse_envp, help='Environment variables in the form KEY=VALUE')
|
|
57
|
+
@click.option('--stdin', type=Path, help='Redirect stdin from this file path')
|
|
58
|
+
@click.option('--stdout', type=Path, help='Redirect stdout to this file path')
|
|
59
|
+
@click.option('--stderr', type=Path, help='Redirect stderr to this file path')
|
|
60
|
+
@click.option('--cwd', type=Path, help='Set the working directory for the process')
|
|
61
|
+
@click.option('--flags', type=click.INT, default=0, help='Launch flags (bitmask)')
|
|
62
|
+
@click.option('--stop-at-entry', is_flag=True, help='Stop the process at the entry point')
|
|
63
|
+
@startup_files_option
|
|
64
|
+
def launch(exec_path: str, argv: Optional[List] = None, envp: Optional[Mapping] = None,
|
|
65
|
+
stdin: Optional[Path] = None,
|
|
66
|
+
stdout: Optional[Path] = None, stderr: Optional[Path] = None, cwd: Optional[Path] = None,
|
|
67
|
+
flags: Optional[int] = 0, stop_at_entry: Optional[bool] = False,
|
|
68
|
+
startup_files: Optional[List[str]] = None) -> None:
|
|
69
|
+
""" Attach to given process and start a lldb shell """
|
|
70
|
+
if not argv:
|
|
71
|
+
argv = None
|
|
72
|
+
if not envp:
|
|
73
|
+
envp = None
|
|
74
|
+
launch_lldb.launch(exec_path, argv, envp, stdin, stdout, stderr, cwd, flags, stop_at_entry,
|
|
75
|
+
startup_files)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@cli.command('bare')
|
|
79
|
+
def cli_bare():
|
|
80
|
+
""" Just start a lldb shell """
|
|
81
|
+
commands = [f'command script import {Path(__file__).resolve().parent / "lldb_entrypoint.py"}']
|
|
82
|
+
commands = '\n'.join(commands)
|
|
83
|
+
launch_lldb.execute(f'lldb --one-line "{commands}"')
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@cli.command('version')
|
|
87
|
+
def cli_version():
|
|
88
|
+
"""Show the version information."""
|
|
89
|
+
click.echo(version)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
__all__ = ['HildaException', 'SymbolAbsentError', 'EvaluatingExpressionError', 'CreatingObjectiveCSymbolError',
|
|
2
2
|
'ConvertingToNsObjectError', 'ConvertingFromNSObjectError', 'DisableJetsamMemoryChecksError',
|
|
3
3
|
'GettingObjectiveCClassError', 'AccessingRegisterError', 'AccessingMemoryError',
|
|
4
|
-
'BrokenLocalSymbolsJarError', 'AddingLldbSymbolError']
|
|
4
|
+
'BrokenLocalSymbolsJarError', 'AddingLldbSymbolError', 'LLDBException']
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class HildaException(Exception):
|
|
@@ -9,6 +9,14 @@ class HildaException(Exception):
|
|
|
9
9
|
pass
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
class LLDBException(Exception):
|
|
13
|
+
""" A domain exception for lldb errors. """
|
|
14
|
+
|
|
15
|
+
def __init__(self, message: str):
|
|
16
|
+
super().__init__()
|
|
17
|
+
self.message = message
|
|
18
|
+
|
|
19
|
+
|
|
12
20
|
class SymbolAbsentError(HildaException):
|
|
13
21
|
""" Raise when trying to get a symbol that doesn't exist. """
|
|
14
22
|
pass
|