Skip to content

Commit 52a1550

Browse files
committed
Merge remote-tracking branch 'origin/GP-326_d-millar_how_to_add_a_debugger--SQUASHED'
2 parents 989eb74 + d5df1c1 commit 52a1550

File tree

28 files changed

+4816
-1
lines changed

28 files changed

+4816
-1
lines changed

Ghidra/Debug/Debugger-agent-drgn/Module.manifest

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Debugger-agent-drgn
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* ###
2+
* IP: GHIDRA
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
apply from: "$rootProject.projectDir/gradle/distributableGhidraModule.gradle"
17+
apply from: "$rootProject.projectDir/gradle/hasPythonPackage.gradle"
18+
19+
apply plugin: 'eclipse'
20+
eclipse.project.name = 'Debug Debugger-agent-drgn'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
##VERSION: 2.0
2+
##MODULE IP: Apache License 2.0
3+
##MODULE IP: Apache License 2.0 with LLVM Exceptions
4+
Module.manifest||GHIDRA||||END|
5+
README.md||GHIDRA||||END|
6+
build.gradle||GHIDRA||||END|
7+
src/main/py/LICENSE||GHIDRA||||END|
8+
src/main/py/MANIFEST.in||GHIDRA||||END|
9+
src/main/py/README.md||GHIDRA||||END|
10+
src/main/py/pyproject.toml||GHIDRA||||END|
11+
src/main/py/src/ghidradrgn/schema.xml||GHIDRA||||END|
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
## ###
3+
# IP: GHIDRA
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
##
17+
#@title drgn-core
18+
#@desc <html><body width="300px">
19+
#@desc <h3>Launch with <tt>drgn-core</tt></h3>
20+
#@desc <p>
21+
#@desc This will attach to an existing core dump using <tt>drgn</tt>.
22+
#@desc For setup instructions, press <b>F1</b>.
23+
#@desc </p>
24+
#@desc </body></html>
25+
#@menu-group drgn
26+
#@icon icon.debugger
27+
#@help TraceRmiLauncherServicePlugin#drgn-core
28+
#@env OPT_TARGET_IMG:file!="" "Core dump" "The target core dump"
29+
30+
export OPT_TARGET_KIND="coredump"
31+
drgn -c "$OPT_TARGET_IMG" ../support/local-drgn.py
32+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
## ###
3+
# IP: GHIDRA
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
##
17+
#@title drgn-kernel
18+
#@desc <html><body width="300px">
19+
#@desc <h3>Launch with <tt>drgn-kernel</tt></h3>
20+
#@desc <p>
21+
#@desc This will attach to the local machine's kernel using <tt>drgn</tt>.
22+
#@desc For setup instructions, press <b>F1</b>.
23+
#@desc </p>
24+
#@desc </body></html>
25+
#@menu-group drgn
26+
#@icon icon.debugger
27+
#@help TraceRmiLauncherServicePlugin#drgn-kernel
28+
29+
export OPT_TARGET_KIND="kernel"
30+
sudo -E drgn ../support/local-drgn.py
31+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
## ###
3+
# IP: GHIDRA
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
##
17+
#@title drgn
18+
#@desc <html><body width="300px">
19+
#@desc <h3>Launch with <tt>drgn</tt></h3>
20+
#@desc <p>
21+
#@desc This will attach to a target running on the local machine using <tt>drgn</tt>.
22+
#@desc For setup instructions, press <b>F1</b>.
23+
#@desc </p>
24+
#@desc </body></html>
25+
#@menu-group drgn
26+
#@icon icon.debugger
27+
#@help TraceRmiLauncherServicePlugin#drgn
28+
#@env OPT_TARGET_PID:int=44068 "PID" "The target's process id"
29+
30+
export OPT_TARGET_KIND="user"
31+
# sudo -E drgn -p "$OPT_TARGET_PID" ../support/local-drgn.py
32+
# or 'echo 0 > /proc/sys/kernel/yama/ptrace_scope'
33+
drgn -p "$OPT_TARGET_PID" ../support/local-drgn.py
34+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
## ###
2+
# IP: GHIDRA
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
##
16+
17+
# From drgn:
18+
# EASY-INSTALL-ENTRY-SCRIPT: 'drgn==0.0.24','console_scripts','drgn'
19+
import os
20+
import re
21+
import sys
22+
23+
import drgn.cli
24+
25+
home = os.getenv('GHIDRA_HOME')
26+
27+
if os.path.isdir(f'{home}/ghidra/.git'):
28+
sys.path.append(
29+
f'{home}/ghidra/Ghidra/Debug/Debugger-agent-drgn/build/pypkg/src')
30+
sys.path.append(
31+
f'{home}/ghidra/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src')
32+
elif os.path.isdir(f'{home}/.git'):
33+
sys.path.append(
34+
f'{home}/Ghidra/Debug/Debugger-agent-drgn/build/pypkg/src')
35+
sys.path.append(
36+
f'{home}/Ghidra/Debug/Debugger-rmi-trace/build/pypkg/src')
37+
else:
38+
sys.path.append(
39+
f'{home}/Ghidra/Debug/Debugger-agent-drgn/pypkg/src')
40+
sys.path.append(f'{home}/Ghidra/Debug/Debugger-rmi-trace/pypkg/src')
41+
42+
43+
def main():
44+
from ghidradrgn import commands as cmd
45+
cmd.ghidra_trace_connect(address=os.getenv('GHIDRA_TRACE_RMI_ADDR'))
46+
cmd.ghidra_trace_create(start_trace=True)
47+
cmd.ghidra_trace_txstart()
48+
cmd.ghidra_trace_put_all()
49+
cmd.ghidra_trace_txcommit()
50+
cmd.ghidra_trace_activate()
51+
drgn.cli.run_interactive(cmd.prog)
52+
53+
54+
if __name__ == '__main__':
55+
main()
56+
57+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Licensed under the Apache License, Version 2.0 (the "License");
2+
you may not use this file except in compliance with the License.
3+
You may obtain a copy of the License at
4+
5+
http://www.apache.org/licenses/LICENSE-2.0
6+
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include src/ghidradrgn/schema.xml

0 commit comments

Comments
 (0)