Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][GR-48384] Update GDB debugging support for Native Image with svmhelpers.py #8886

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

graalvmbot
Copy link
Collaborator

No description provided.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label May 7, 2024

##### Limitations

The `print` still uses its default implementation, as there is no way to overwrite it, while still keeping the capability of the default `print` command.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be: The print command still uses ...

Copy link
Collaborator

@zakkak zakkak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's very interesting, thanks @dominikmascherbauer!

I know this is still WIP, but I added a few comments for your consideration.


The pretty printer also supports printing of the primitive value instead of a Java Object for boxed primitives.

Whenever printing is done via the `p` (alias for `print`) the pretty printer intercepts that call to perform type casts to the respective runtime types of Java Objects.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Whenever printing is done via the `p` (alias for `print`) the pretty printer intercepts that call to perform type casts to the respective runtime types of Java Objects.
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.


Whenever printing is done via the `p` (alias for `print`) the pretty printer intercepts that call to perform type casts to the respective runtime types of Java Objects.
This also applies for auto-completion when using the `p` command.
This means, if the static type is different to the runtime type, `print` uses the static types, which leaves finding out the runtime types and type casting to the user.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This means, if the static type is different to the runtime type, `print` uses the static types, which leaves finding out the runtime types and type casting to the user.
This means that if the static type is different to the runtime type, the `print` command uses the static types, which leaves finding out the runtime types and type casting to the user.

The pretty printer also supports printing of the primitive value instead of a Java Object for boxed primitives.

Whenever printing is done via the `p` (alias for `print`) the pretty printer intercepts that call to perform type casts to the respective runtime types of Java Objects.
This also applies for auto-completion when using the `p` command.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This also applies for auto-completion when using the `p` command.
This also applies for auto-completion when using the `p` alias.

Whenever printing is done via the `p` (alias for `print`) the pretty printer intercepts that call to perform type casts to the respective runtime types of Java Objects.
This also applies for auto-completion when using the `p` command.
This means, if the static type is different to the runtime type, `print` uses the static types, which leaves finding out the runtime types and type casting to the user.
Additionally, the `p` command understands Java field and array access and function calls for Java Objects.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Additionally, the `p` command understands Java field and array access and function calls for Java Objects.
Additionally, the `p` alias understands Java field and array access and function calls for Java Objects.


#### Options for controlling the behavior of the SVM Pretty Printer

In addition to the enhanced `p` command `svmhelpers.py` introduces some GDB parameters to customize the behavior of the SVM Pretty Printer.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In addition to the enhanced `p` command `svmhelpers.py` introduces some GDB parameters to customize the behavior of the SVM Pretty Printer.
In addition to the enhanced `p` alias, `svmhelpers.py` introduces some GDB parameters to customize the behavior of the SVM Pretty Printer.

* ##### svm-print-string-limit <int>

Allows to customize the maximum length for pretty printing Java Strings.
The default value is 200, set to -1 or _unlimited_ for unlimited printing of Java Strings.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think wrapping the values in backtickes will make this more readable

Suggested change
The default value is 200, set to -1 or _unlimited_ for unlimited printing of Java Strings.
The default value is `200`, set to `-1` or `_unlimited_` for unlimited printing of Java Strings.

If you agree please apply to the rest of the options as well.

svmhelpers_py = join(mx.dependency('com.oracle.svm.hosted.image.debug').output_dir(), 'svmhelpers.py')

test_python_source_dir = join(test_source_path, 'com', 'oracle', 'svm', 'test', 'debug', 'helper')
gdb_utils_py = join(test_python_source_dir, 'gdb_util.py')
Copy link
Collaborator

@zakkak zakkak May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this come from? Should it maybe be:

Suggested change
gdb_utils_py = join(test_python_source_dir, 'gdb_util.py')
gdb_utils_py = join(test_python_source_dir, 'gdb_helper.py')

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out, it's not needed here anymore, I forgot to remove it.
gdb_helper is now imported directly in the testscripts like that:

# add test directory to path to allow import of gdb_helper.py
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__))))

from gdb_helper import *

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants