Skip to content

Commit 82276c6

Browse files
Update Documentation
1 parent 92f31ba commit 82276c6

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

docs/reference-manual/native-image/guides/debug-native-executables-with-python-helper.md

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,20 @@ permalink: /reference-manual/native-image/guides/debug-native-image-process-with
66
---
77
# Debug Native Executables with a Python Helper Script
88

9-
### Debugging with _gdb-debughelpers.py_
10-
9+
Additionally to the [GDB debugging](debug-native-executables-with-gdb.md), you can debug a `native-image` process using a Python helper script, _gdb-debughelpers.py_.
1110
The [GDB Python API](https://sourceware.org/gdb/current/onlinedocs/gdb/Python.html) is used to provide a reasonably good experience for debugging native executables or shared libraries.
1211
It requires GDB with Python support.
1312
The debugging extension is tested against GDB 13.2 and supports the new debuginfo generation introduced in GraalVM for JDK 17 and later.
1413

15-
> Note: The _gdb-debughelpers.py_ file does not work with versions older than version 13.2 of `gdb` or versions older than GraalVM for JDK17.
14+
> Note: The _gdb-debughelpers.py_ file does not work with versions older than version 13.2 of `gdb` or versions older than GraalVM for JDK 17.
1615
17-
The Python script _gdb-debughelpers.py_ can be found in _<GRAALVM\_HOME>/lib/svm/debug_ directory.
16+
The Python script _gdb-debughelpers.py_ can be found in the _<GRAALVM\_HOME>/lib/svm/debug_ directory.
1817
If debuginfo generation is enabled (see [Build a Native Executable with Debug Information](debug-native-executables-with-gdb.md#build-a-native-executable-with-debug-information)), the script is copied to the build directory.
1918
The `native-image` tool adds the debugging section `.debug_gdb_scripts` to the debug info file, which causes GDB to automatically load _gdb-debughelpers.py_ from the current working directory.
2019

2120
For [security reasons](https://sourceware.org/gdb/current/onlinedocs/gdb/Auto_002dloading-safe-path.html)
2221
the first time GDB encounters a native executable or shared library that requests a specific Python file to be loaded it will print a warning:
2322

24-
> Reading symbols from svmbuild/images/<imagename>...
2523
> warning: File "<CWD>/gdb-debughelpers.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
2624
>
2725
> To enable execution of this file add
@@ -40,7 +38,7 @@ To solve this, either add the current working directory to _~/.gdbinit_ as follo
4038

4139
or pass the path as a command line argument to `gdb`:
4240

43-
gdb -iex "set auto-load safe-path <CWD>/gdb-debughelpers.py" <imagename>
41+
gdb -iex "set auto-load safe-path <CWD>/gdb-debughelpers.py" <binary-name>
4442

4543
Both enable GDB to auto-load _gdb-debughelpers.py_ from the current working directory.
4644

@@ -49,117 +47,119 @@ However, it is possible to manually load the script from GDB explicitly with:
4947

5048
(gdb) source gdb-debughelpers.py
5149

52-
53-
#### SVM Pretty Printing Support
50+
## Pretty Printing Support
5451

5552
Loading _gdb-debughelpers.py_ registers a new pretty printer to GDB, which adds an extra level of convenience for debugging native executables or shared libraries.
5653
This pretty printer handles the printing of Java Objects, Arrays, Strings, and Enums for debugging native executables or shared libraries.
5754
If the Java application uses `@CStruct` and `@CPointer` annotations to access C data structures, the pretty printer will also try to print them as if they were Java data structures.
58-
If the C data structures cannot be printed by the SVM pretty printer, printing is done by GDB.
55+
If the C data structures cannot be printed by the pretty printer, printing is performed by GDB.
5956

60-
The pretty printer also supports printing of the primitive value instead of a Java Object for boxed primitives.
57+
The pretty printer also prints of the primitive value of a boxed primitive (instead of a Java Object).
6158

6259
Whenever printing is done via the `p` alias of the `print` command the pretty printer intercepts that call to perform type casts to the respective runtime types of Java Objects.
6360
This also applies for auto-completion when using the `p` alias.
6461
This means that if the static type is different to the runtime type, the `print` command uses the static type, which leaves the user to discover the runtime type and typecast it.
6562
Additionally, the `p` alias understands Java field and array access and function calls for Java Objects.
6663

67-
##### Limitations
64+
#### Limitations
6865

6966
The `print` command still uses its default implementation, as there is no way to overwrite it, while still keeping the capability of the default `print` command.
7067
Overriding would cause printing non-Java Objects to not work properly.
71-
Therefore, only the `p` alias for the `print` command is overwritten by the SVM pretty printer, such that the user can still make use of the default GDB `print` command.
68+
Therefore, only the `p` alias for the `print` command is overwritten by the pretty printer, such that the user can still make use of the default GDB `print` command.
7269

70+
### Options to Control the Pretty Printer Behavior
7371

74-
#### Options to Control the Behavior of the SVM Pretty Printer
75-
76-
In addition to the enhanced `p` alias, _gdb-debughelpers.py_ introduces some GDB parameters to customize the behavior of the SVM Pretty Printer.
72+
In addition to the enhanced `p` alias, _gdb-debughelpers.py_ introduces some GDB parameters to customize the behavior of the pretty printer.
7773
Parameters in GDB can be controlled with `set <param> <value>` and `show <param>` commands, and thus integrate with GDB's customization options.
7874

79-
* ##### svm-print on/off
75+
* #### svm-print on/off
8076

81-
Use this command to enable/disable the SVM Pretty Printer.
77+
Use this command to enable/disable the pretty printer.
8278
This also resets the `print` command alias `p` to its default behavior.
83-
Alternatively SVM pretty printing can be suppressed with the
79+
Alternatively pretty printing can be suppressed with the
8480
[`raw` printing option of GDB's `print` command](https://sourceware.org/gdb/current/onlinedocs/gdb/Output-Formats.html):
8581

8682
(gdb) show svm-print
8783
The current value of 'svm-print' is "on".
84+
8885
(gdb) print str
8986
$1 = "string"
87+
9088
(gdb) print/r str
9189
$2 = (java.lang.String *) 0x7ffff689d2d0
92-
(gdb) set svm-print off
90+
91+
(gdb) set svm-print off
9392
1 printer disabled
9493
1 of 2 printers enabled
9594

9695
(gdb) print str
9796
$3 = (java.lang.String *) 0x7ffff689d2d0
9897

99-
* ##### svm-print-string-limit &lt;int&gt;
98+
* #### svm-print-string-limit &lt;int&gt;
10099

101100
Customizes the maximum length for pretty printing a Java String.
102101
The default value is `200`.
103102
Set to `-1` or `unlimited` for unlimited printing of a Java String.
104103
This does not change the limit for a C String, which can be controlled with GDB's `set print characters` command.
105104

106-
* ##### svm-print-element-limit &lt;int&gt;
105+
* #### svm-print-element-limit &lt;int&gt;
107106

108107
Customizes the maximum number of elements for pretty printing a Java Array, ArrayList, and HashMap.
109108
The default value is `10`.
110109
Set to `-1` or `unlimited` to print an unlimited number of elements.
111110
This does not change the limit for a C array, which can be controlled with GDB's `set print elements` command.
112111
However, GDB's parameter `print elements` is the upper bound for `svm-print-element-limit`.
113112

114-
* ##### svm-print-field-limit &lt;int&gt;
113+
* #### svm-print-field-limit &lt;int&gt;
115114

116115
Customizes the maximum number of elements for pretty printing fields of a Java Object.
117116
The default value is `50`.
118117
Set to `-1` or `unlimited` to print an unlimited number of fields.
119118
GDB's parameter `print elements` is the upper bound for `svm-print-field-limit`.
120119

121-
* ##### svm-print-depth-limit &lt;int&gt;
120+
* #### svm-print-depth-limit &lt;int&gt;
122121

123-
Customizes the maximum depth of recursive svm pretty printing.
122+
Customizes the maximum depth of recursive pretty printing.
124123
The default value is `1`.
125124
The children of direct children are printed (a sane default to make contents of boxed values visible).
126125
Set to `-1` or `unlimited` to print unlimited depth.
127126
GDB's parameter `print max-depth` is the upper bound for `svm-print-depth-limit`.
128127

129-
* ##### svm-use-hlrep on/off
128+
* #### svm-use-hlrep on/off
130129

131-
Use this command to enable/disable pretty printing for higher level representations.
130+
Enables/disables pretty printing for higher level representations.
132131
It provides a more data-oriented view on some Java data structures with a known internal structure such as Lists or Maps.
133132
Currently supports ArrayList and HashMap.
134133

135-
* ##### svm-infer-generics &lt;int&gt;
134+
* #### svm-infer-generics &lt;int&gt;
136135

137136
Customizes the number of elements taken into account to infer the generic type of higher level representations.
138137
The default value is `10`.
139-
Set to `0` to not infer generic types and `-1` or `unlimited` to infer the generic type with all elements.
138+
Set to `0` to not infer generic types and `-1` or `unlimited` to infer the generic type of all elements.
140139

141-
* ##### svm-print-address absolute/on/off
140+
* #### svm-print-address absolute/on/off
142141

143-
Use this command to enable/disable printing of addresses in addition to regular pretty printing.
142+
Enables/disables printing of addresses in addition to regular pretty printing.
144143
When `absolute` mode is used even compressed references are shown as absolute addresses.
145144
Printing addresses is disabled by default.
146145

147-
* ##### svm-print-static-fields on/off
146+
* #### svm-print-static-fields on/off
148147

149-
Per default static field members are not shown during pretty printing of Java objects.
150-
This command customizes this behavior.
148+
Enables/disables printing of static fields for a Java Object.
149+
Printing static fields is disabled by default.
151150

152-
* ##### svm-complete-static-variables on/off
151+
* #### svm-complete-static-variables on/off
153152

154-
Per default auto-completion for static fields is enabled for the enhanced `p` alias.
155-
This command enables/disables completion for static field members.
153+
Enables/disables auto-completion of static field members for the enhanced `p` alias.
154+
Auto-completion of static fields is enabled by default.
156155

157-
* ##### svm-selfref-check on/off
156+
* #### svm-selfref-check on/off
158157

159-
To avoid endless recursion in pretty printing a self-referential data structure _gdb-debughelpers.py_ detects such cases and prevents further expansion.
158+
Enables/disables self-reference checks for data structures.
159+
The pretty printer detects a self-referential data structure and prevents further expansion to avoid endless recursion.
160+
Self-reference checks are enabled by default.
160161
For testing, this feature can be temporary disabled (usually you wouldn't want to do this).
161162

162-
163163
### Related Documentation
164164

165165
* [Debug Info Feature](../DebugInfo.md)

0 commit comments

Comments
 (0)