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

Failure to compile with clang++ (undeclared identifier '_Unwind_GetIPInfo') #2

Closed
prg318 opened this issue Mar 15, 2013 · 2 comments
Closed
Assignees

Comments

@prg318
Copy link

prg318 commented Mar 15, 2013

I noticed this comment on HN (https://news.ycombinator.com/item?id=5381414) and did not see an Issue filed. I'm experiencing a similar issue when compiling my project (FCEUX) with clang++ and backward-cpp. I'm using "libdw" and passing "-DBACKWARD_HAS_DW=1" to the compiler. I receive the following error when compiling with clang++:

clang++ -o src/utils/backward.o -c -Wall -Wno-write-strings -Wno-sign-compare -Isrc/lua/src -DBACKWARD_HAS_DW=1 -DHAVE_ASPRINTF -pthread -D_GTK -DLUA_USE_LINUX -DOPENGL -g -DHAVE_GD -D_GNU_SOURCE=1 -D_REENTRANT -D_GTK2 -D_S9XLUA_H -DPSS_STYLE=1 -DLSB_FIRST -DFRAMESKIP -D_DEBUG -DCREATE_AVI -I/usr/include/SDL -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libdrm -I/usr/include/libpng15 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 src/utils/backward.cpp
In file included from src/utils/backward.cpp:26:
src/utils/backward.hpp:595:18: error: use of undeclared identifier '_Unwind_GetIPInfo'
                uintptr_t ip = _Unwind_GetIPInfo(ctx, &ip_before_instruction);
                               ^
1 error generated.
scons: *** [src/utils/backward.o] Error 1
scons: building terminated because of errors.

When compiling with "-DBACKWARD_HAS_BACKTRACE=1" in addition to "-DBACKWARD_HAS_DW=1", as suggested in your reply to the HN comment, everything works as per usual. In addition, when compiling with g++, the "-DBACKWARD_HAS_BACKTRACE=1" is not required and everything works as suspected.

I'm testing with Arch Linux (64 bit fwiw). If you need any additional information, feel free to let me know. Thanks again for this really great/useful open source contribution!

@ghost ghost assigned bombela Mar 15, 2013
@maleadt
Copy link

maleadt commented Mar 15, 2013

Changing to _Unwind_GetIP(ctx) makes it work, but I guess that can make for less accurate traces.

@bombela
Copy link
Owner

bombela commented Mar 15, 2013

Yep, exactly. Basically the tricks is that a trace address is where the code should come back after a call. So what you do, is decrementing one byte from the address so it somewhat falls into the boundaries of the previous instruction, which is usually the initial call that created the new stack frame.

In the case of a signal, the trace address is in fact the address of the bad instruction (for example a segfault), thus you dont want to decrement this one.

_Unwind_GetIPInfo gives you just that, this extra information.

I think if you declare _Unwind_GetIPInfo it will work. The function exists but is not declared in the unwind headers.

Note that it is possible to use libdw to do what unwind does, but unwind already does the job, and it is somewhat a little bit more portable (it abstracts away the format of the debug info).

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

No branches or pull requests

3 participants