Skip to content

Commit 05a7015

Browse files
committed
spell check, add a table of contents and few other stylistic improvements to user manual
1 parent 25d87f8 commit 05a7015

File tree

1 file changed

+73
-36
lines changed

1 file changed

+73
-36
lines changed

documentation/Manual.md

Lines changed: 73 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,47 @@ Terms in **bold** can be found in the Glossary section. Strings `highlighted` re
66

77
`BNDP_ROOT` refers to the path where the debugger is installed.
88

9-
## Table of Contents
9+
# Table of contents
10+
11+
1. [Introduction](#introduction)
12+
2. [Installation](#installation)
13+
- [Host Requirements](#host-requirements)
14+
- [Plugin Acquisition and Installation](#plugin-acquisition-and-installation)
15+
- [Platform Specific Considerations](#platform-specific-considerations)
16+
* [Android Phones](#android-phones)
17+
* [MacOS](#macos)
18+
3. [Use](#use)
19+
- [GUI Mode](#gui-mode)
20+
- [Headless Mode](#headless-mode)
21+
- [Automated Tests](#automated-tests)
22+
* [Build Environment Requirements](#build-environment-requirements)
23+
* [Build Steps](#build-steps)
24+
* [Python Requirements](#python-requirements)
25+
* [Running](#running)
26+
4. [Design](#design)
27+
- [Overview](#overview)
28+
- [Standard Backends](#standard-backends)
29+
- [DebugAdapter and its Subclasses](#debugadapter-and-its-subclasses)
30+
- [UI: DebugProcessView](#ui-debugprocessview)
31+
5. [API](#api)
32+
- [DebugAdapter Methods](#debugadapter-methods)
33+
* [Initialization Methods](#initialization-methods)
34+
* [Session Start/Stop Methods](#session-startstop-methods)
35+
* [Target Info Methods](#target-info-methods)
36+
* [Thread Methods](#thread-methods)
37+
* [Breakpoint Methods](#breakpoint-methods)
38+
* [Register Methods](#register-methods)
39+
* [Memory Methods](#memory-methods)
40+
* [Execution Control Methods](#execution-control-methods)
41+
- [Subclassing DebugAdapter](#subclassing-debugadapter)
42+
- [GDB vs. LLDB](#gdb-vs-lldb)
43+
- [Troubleshooting new GDB Backends](#troubleshooting-new-gdb-backends)
44+
* [General Tips](#general-tips)
45+
* [Network Monitoring](#network-monitoring)
46+
* [Executing Backends Manually](#executing-backends-manually)
47+
* [Executing Client Manually](#executing-client-manually)
48+
6. [Glossary](#glossary)
1049

11-
[toc]
1250
# Introduction
1351

1452
Binary Ninja Debugger Plugin (**BNDP**) is a plugin for Binary Ninja implementing debug functionality. It can be used from within the GUI or outside (headless). It officially supports 64-bit Windows, Linux, and MacOS targets. Its extensible design makes it easily adapted to other platforms.
@@ -27,7 +65,7 @@ Binary Ninja Debugger Plugin (**BNDP**) is a plugin for Binary Ninja implementin
2765

2866
## Plugin Acquisition and Installation
2967

30-
BNDP is a python package and is acquired via github (http://github.com/vector35/debugger), by the Plugin Manager from within Binary Ninja, or by ordinary file and directory copying.
68+
BNDP is a python package and is acquired via GitHub (http://github.com/vector35/debugger), by the Plugin Manager from within Binary Ninja, or by ordinary file and directory copying.
3169

3270
It must be placed in the Binary Ninja plugin path, which varies based on platform. Please refer to [Using Plugins](https://docs.binary.ninja/getting-started.html#using-plugins) section within the [Getting Started Guide](https://docs.binary.ninja/getting-started.html) in the [Binary Ninja User Documentation](https://docs.binary.ninja/).
3371

@@ -62,17 +100,17 @@ A view with debugger-related menu items will appear:
62100

63101
![](./resources/gui2.png)
64102

65-
Click the dropdown menu arrow near `Run` for additional settings. Click `Run` to execute the target. The other buttons will activate if the target is initialized successfully. Buttons `Resume`, `Step Into`, etc. work as expected. To set a breakpoint, select an address, right click, choose Debugger, then `Toggle Breakpoint`.
103+
Click the drop-down menu arrow near `Run` for additional settings. Click `Run` to execute the target. The other buttons will activate if the target is initialized successfully. Buttons `Resume`, `Step Into`, etc. work as expected. To set a breakpoint, select an address, right click, choose Debugger, then `Toggle Breakpoint`.
66104

67105
![](./resources/gui3.png)
68106

69-
The same step is used to clear the breakpoint. To view modules, registers, etc. select `View` from the applicatation's main menu and then the desired view:
107+
The same step is used to clear the breakpoint. To view modules, registers, etc. select `View` from the application's main menu and then the desired view:
70108

71109
![](./resources/gui4.png)
72110

73111
## Headless Mode
74112

75-
The API attempts to hide target details behing a uniform interface called DebugAdapter. Start by importing the parent DebugAdapter and the appropriate child for your platform and creating an instance:
113+
The API attempts to hide target details behind a uniform interface called DebugAdapter. Start by importing the parent DebugAdapter and the appropriate child for your platform and creating an instance:
76114

77115
```python
78116
from debugger import DebugAdapter, lldb
@@ -147,7 +185,7 @@ BNDP is a convenient means to interact with various debugger **backends**. It do
147185

148186
The backends vary considerably, so a large part of BNDP's task is to present a unified interface by which these backends can be used.
149187

150-
This is achieved using debug **adapters**, named so because they adapt whatever ideosyncracies a backend has to the ideal interface we envision in `DebugAdapter.py`. Each adaptation of a backend is a subclass of `DebugAdapter`, for example `DebugAdapterGdb` and `DebugAdapterLLDB` communicate with gdb and lldb backends, respectively.
188+
This is achieved using debug **adapters**, named so because they adapt whatever idiosyncrasies a backend has to the ideal interface we envision in `DebugAdapter.py`. Each adaptation of a backend is a subclass of `DebugAdapter`, for example `DebugAdapterGdb` and `DebugAdapterLLDB` communicate with gdb and lldb backends, respectively.
151189

152190
## Standard Backends
153191

@@ -179,7 +217,7 @@ Higher level operations like "step over" are provided by some backends (like **d
179217

180218
# API
181219

182-
Prerequisite reading: "Design" section
220+
Prerequisite reading: [Design](#Design)
183221

184222
The API is centered around the `DebugAdapter` class. You can subclass it to interface with a new **backend**.
185223

@@ -212,7 +250,7 @@ These functions start and end a session. A session can be started by executing a
212250

213251
### Target Info Methods
214252

215-
Acquire the target's architecture, execution path, process ID, and load address. Note that these are not always applicable for certain targets. For example, pid does not make sense when connected to a full system BOCHS emulation.
253+
Acquire the target's architecture, execution path, process ID, and load address. Note that these are not always applicable for certain targets. For example, PID does not make sense when connected to a full system BOCHS emulation.
216254

217255
```
218256
def target_arch(self)
@@ -223,14 +261,14 @@ Acquire the target's architecture, execution path, process ID, and load address.
223261

224262
See `BNDP_ROOT/DebugAdapter.py`.
225263

226-
### Thread Methods
264+
### Thread Methods
227265
```
228266
def thread_list(self):
229267
def thread_selected(self):
230268
def thread_select(self, tidx):
231269
```
232270

233-
### Breakpoint Methods
271+
### Breakpoint Methods
234272
```
235273
def breakpoint_set(self, address)
236274
def breakpoint_clear(self, address)
@@ -261,7 +299,7 @@ See `BNDP_ROOT/DebugAdapter.py`.
261299

262300
## Subclassing DebugAdapter
263301

264-
The DebugAdapter wants to present a general debug interface, hiding the ideosyncracies of whatever **backend** it is connected to. Often you will have to "shape" the behavior of the backend to aim for this ideal.
302+
The DebugAdapter wants to present a general debug interface, hiding the idiosyncrasies of whatever **backend** it is connected to. Often you will have to "shape" the behavior of the backend to aim for this ideal.
265303

266304
For example, in Windows, setting a breakpoint always succeeds, no matter the address. It's only at the next go/step/step that bad addresses will raise a write exception because that's when the engine actually writes the 0xCC byte. But the designed behavior of `breakpoint_set()` in DebugAdapter is to write immediately, and provide instant response to the caller if the breakpoint wasn't set correctly. So a `WriteProcessMemory()` is used as a probe, and if it succeeds, the adapter pretends the breakpoint is as good as set.
267305

@@ -273,13 +311,10 @@ The stubs implemented by gdbserver and debugserver will not step over an address
273311

274312
The following differences were noted during development and are not an exhaustive list:
275313

276-
lldb has single reg reads with 'p' packet, but in gdb registers must be read in group with 'g' packet.
277-
278-
lldb can have its registers polled with 'qRegisterInfo' packet, but gdb uses only XML target description.
279-
280-
lldb has single reg writes with 'P' packet, gdb doesn't, and registers must be written in group with 'G' packet.
281-
282-
lldb can list solibs and executable image with 'jGetLoadedDynamicLibrariesInfos' packet, gdb still looks to /proc/pid/maps.
314+
- lldb has single reg reads with 'p' packet, but in gdb registers must be read in group with 'g' packet.
315+
- lldb can have its registers polled with 'qRegisterInfo' packet, but gdb uses only XML target description.
316+
- lldb has single reg writes with 'P' packet, gdb doesn't, and registers must be written in group with 'G' packet.
317+
- lldb can list `so` libs and executable image with 'jGetLoadedDynamicLibrariesInfos' packet, gdb still looks to /proc/pid/maps.
283318

284319
## Troubleshooting new GDB Backends
285320

@@ -289,31 +324,33 @@ Prove functionality first with `BNDP_ROOT/cli.py` then with the GUI.
289324

290325
### Network Monitoring
291326

292-
For gdbserver and debugserver, monitoring packets can be indispensible.
327+
For gdbserver and debugserver, monitoring packets can be indispensable.
293328

294-
Use tcpdump: `tcpdump -i lo0 -A -s0 'port 31337'`.
295-
Use `./tools/sniffrsp.py` to monitor traffic between you and gdbserver/debugserver.
296-
Use wireshark.
329+
- Use tcpdump: `tcpdump -i lo0 -A -s0 'port 31337'`
330+
- Use `./tools/sniffrsp.py` to monitor traffic between you and gdbserver/debugserver
331+
- Use wireshark
297332

298333
### Executing Backends Manually
299334

300-
`$ debugserver localhost:31337 ./testbins/asmtest`
301-
302-
`$ gdbserver --once --no-startup-with-shell localhost:31337 ./testbins/asmtest`
303-
304-
`mame -v coleco -video soft -cart /path/to/DACMAN.ROM -window -nomax -resolution 560x432 -debugger gdbstub -debug
335+
```
336+
$ debugserver localhost:31337 ./testbins/asmtest
337+
$ gdbserver --once --no-startup-with-shell localhost:31337 ./testbins/asmtest
338+
mame -v coleco -video soft -cart /path/to/DACMAN.ROM -window -nomax -resolution 560x432 -debugger gdbstub -debug
339+
```
305340

306341
### Executing Client Manually
307342

308-
Monitoring, then mimicing behavior from working tools is often faster than starting at the docs:
343+
Monitoring, then mimicking behavior from working tools is often faster than starting at the docs:
309344

310-
`(lldb) process connect connect://localhost:31337`
345+
```
346+
(lldb) process connect connect://localhost:31337
347+
```
311348

312349
# Glossary
313350

314-
**backend** - This is the code that is actually instrumenting (eg: writing breakpoint bytes, setting the trap flag) in targets. Examples are Microsoft's [debugger engine](https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-engine-overview), gdbserver, debugserver, or MAME.
315-
316-
**BNDP** - Binary Ninja Debugger Plugin
317-
318-
**dbgeng** - Microsoft's [debugger engine](https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-engine-overview).
319-
351+
- *backend*
352+
This is the code that is actually instrumenting (eg: writing breakpoint bytes, setting the trap flag) in targets. Examples are Microsoft's [debugger engine](https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-engine-overview), gdbserver, debugserver, or MAME.
353+
- *BNDP*
354+
Binary Ninja Debugger Plugin
355+
- *dbgeng*
356+
Microsoft's [debugger engine](https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-engine-overview).

0 commit comments

Comments
 (0)