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

Fix ABI demangling for the GCC 5.x case. #50

Closed
wants to merge 1 commit into from

Conversation

Jo-Con-El
Copy link

When glog is compiled with gcc-5.2 in cxx11 ABI mode, it barfs about unmangled symbols. This patches it getting inspiration from binutils and demangle.cc itself, although it may be totally wrong or maybe have to use ParseAbiTag in more places. I haven't read the spec for the symbols, though.

Symbols are demangled now as

google::LogDestination::addresses_[cxx11]

This patch makes the demangle unit test pass correctly (as there's no more symbols starting with _Z), so closes #40.

When glog is compiled with gcc-5.2 in cxx11 ABI mode, it barfs about unmangled symbols.  This patches it getting inspiration from binutils and demangle.cc itself, although it may be totally wrong or maybe have to use ParseAbiTag in more places.  I haven't read the spec for the symbols, though.

This patch makes the demangle unit test pass correctly.
@googlebot
Copy link
Collaborator

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@Jo-Con-El
Copy link
Author

Hey, yo!

@googlebot
Copy link
Collaborator

CLAs look good, thanks!

@Jo-Con-El
Copy link
Author

This probably fixes #14 as well.

@ukai
Copy link
Contributor

ukai commented Nov 10, 2015

no unittest?

@vielmetti
Copy link

vielmetti commented Jul 31, 2017

I applied #50 on an aarch64 system with GCC 5.4.0, and all tests related to demangling passed.

@Jo-Con-El
Copy link
Author

Sorry, @ukai. No unittests for now. I made this patch a looong time ago and I'm not affected by this bug anymore. Moreover, I don't have bandwidth at this time to revisit this. :-(

@vielmetti
Copy link

@Jo-Con-El @ukai - where would unit tests go, if they were to exist? I am on a system where this patch matters, and it would be very useful to have it accepted.

@shinh
Copy link
Collaborator

shinh commented Sep 3, 2017

I think you'll want to add symbols to https://github.com/google/glog/blob/master/src/demangle_unittest.txt

@janisz
Copy link

janisz commented Oct 16, 2017

I tried to add a test but it fails

diff --git a/src/demangle_unittest.cc b/src/demangle_unittest.cc
index be48341..c51371a 100644
--- a/src/demangle_unittest.cc
+++ b/src/demangle_unittest.cc
@@ -111,6 +111,8 @@ TEST(Demangle, Clones) {
   EXPECT_STREQ("Foo()", tmp);
   EXPECT_TRUE(Demangle("_ZL3Foov.isra.2.constprop.18", tmp, sizeof(tmp)));
   EXPECT_STREQ("Foo()", tmp);
+  EXPECT_TRUE(Demangle("_Z3fooB5cxx11", tmp, sizeof(tmp)));
+  EXPECT_STREQ("foo[abi:cxx11]", tmp);
   // Invalid (truncated), should not demangle.
   EXPECT_FALSE(Demangle("_ZL3Foov.clo", tmp, sizeof(tmp)));
   // Invalid (.clone. not followed by number), should not demangle.

although it's working in GCC

#include <stdio.h>
#include <stdlib.h>
#include <cxxabi.h>

int main() {
        const char *mangled_name = "_Z3fooB5cxx11";
        char *demangled_name;
        int status = -1;
        demangled_name = abi::__cxa_demangle(mangled_name, NULL, NULL, &status);
        printf("Demangled: %s\n", demangled_name);
        free(demangled_name);
        return 0;
}

@ukai ukai closed this in 5d46e1b Jan 7, 2019
durswd pushed a commit to durswd/glog that referenced this pull request Sep 2, 2019
Support ABI tags after <local-source-name> in demangle.cc.
Update the reference URL.

Fixes google#50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

demangle_unittest.sh fails with GCC 5 (configured --with-default-libstdcxx-abi=new, which is the default)
6 participants