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

Add helper demangle function for 3rd party tools #16295

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

Conversation

ryuukk
Copy link
Contributor

@ryuukk ryuukk commented Mar 6, 2024

Example of tools that'd benefit it:

https://github.com/KDAB/hotspot

Their build script is unnecessarily complex: https://github.com/KDAB/hotspot/blob/6f9f958c4ff68b3c94ccca0fa3c2d86c46c9185f/scripts/appimage/Dockerfile#L88-L98

Instead, i propose to add this function into druntime, so the tool can directly consume it

Making the whole process much easier:

-    loadDemangleLib(QStringLiteral("d_demangle"), "demangle_symbol", QByteArrayLiteral("_D"));
+    loadDemangleLib(QStringLiteral("phobos2"), "__d_demangle", QByteArrayLiteral("_D"));

https://github.com/KDAB/perfparser/blob/f38363858a56e1dc3b33b998e5a0f6c7046b8993/app/demangler.cpp#L40

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @ryuukk! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#16295"

druntime/src/core/demangle.d Outdated Show resolved Hide resolved
druntime/src/core/demangle.d Show resolved Hide resolved
druntime/src/core/demangle.d Outdated Show resolved Hide resolved
druntime/src/core/demangle.d Outdated Show resolved Hide resolved
druntime/src/core/demangle.d Outdated Show resolved Hide resolved
@dkorpel
Copy link
Contributor

dkorpel commented Mar 7, 2024

Their build script is unnecessarily complex

The linked to script clones a repository containing a thin C-api wrapper around std.demangle. I think it's a good idea to provide a C-api directly in druntime, it just needs a test because I don't think it works in its current form.

return 0;

memcpy(buffer, demangled.ptr, demangled.length);
buffer[demangled.length] = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an out-of-bounds write if bufferLength == demangled.length

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants