Replies: 13 comments 11 replies
-
Hi, thanks for your interest in the library! Unfortunately this may be an issue with cpptrace itself as opposed to a configuration problem. The ideal configuration for mingw is libdwarf+dbghelp, and if that isn't producing symbols that's concerning. One tricky thing here is that the mingw ecosystem is pretty fragmented so while I've tested locally and things work for me it might be broken in another mingw ecosystem. I'm also not familiar with QT or qmake. Would it be possible to send the full cmake output from when you built cpptrace? |
Beta Was this translation helpful? Give feedback.
-
Sure, I am happy to help if this can uncover an issue with cpptrace itself. Just for the record, this is my MINGW64 and gcc versions in MINGW are:
A default cmake call gives me:
Note that in my setup, I am doing a version of the "Local User Installation" process, where I don't do Here's a snippet from my qmake project.
And one more additional info package, if I build only DBGHELP by adding
And if I build only DWARF by adding
Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
I added
The first line looks like a smoking gun to me, but I don't understand where is it coming from. The second line refers to QKeyEvent: an object sent by Qt whenever there are key presses, and KeyboardManager is my class processing key presses. FYI, I crash the app by inputting a numeric code, which makes the app call a function dereferencing a nullptr. This is how I test traces. |
Beta Was this translation helpful? Give feedback.
-
A quick search revealed this error is created in https://github.com/davea42/libdwarf-code/blob/42367fc3195c0dd2cab059e15a87ed33f5f96e49/src/lib/libdwarf/dwarf_peread.c#L379. I'll kindly wait for your help in figuring out how that traces back to cpptrace's usage |
Beta Was this translation helpful? Give feedback.
-
One last addition which may help: I get a warning during
|
Beta Was this translation helpful? Give feedback.
-
If you want to start a Qt project, the online installer is here: https://www.qt.io/download-qt-installer-oss. I am sharing the link because it's not trivial to find. They are pushing their commercial pages mainly, and if you know where to click, you can find the "open source" installer for free use. You will need to make a free account to run the installer. I am using Qt5, they released Qt6 recently, but switching over would require some time, so I stayed at the last release of Qt5. See the attached photos of what I have installed form their installer. After that's done, it takes 2 clicks to open one of their examples, build and execute it. Hope this helps reproducing the issue! |
Beta Was this translation helpful? Give feedback.
-
I think something is broken on your dev branch, and I mean apart from having to change CMakeLists.txt to the newest commit on libdwarf (af6b8f2c380d06c2a6bc592f56592f733047ccab) to make libdwarf-populate succeed. I rebuilt cpptrace by adding |
Beta Was this translation helpful? Give feedback.
-
I think I found something. I had a hunch and rebuilt the binary with the debug info inside the exe, and now the default symbol resolution worked! So the issue now is cpptrace not looking up symbols in an external file linked from the main exe. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the additional info. I'm not sure how anything worked without linking
I'm glad to hear this at least. When the debug symbols weren't in the binary, where were they being put? Do you happen to know if it was using a split dwarf file, possibly with a .dwo extension? |
Beta Was this translation helpful? Give feedback.
-
Yeah, the linking issue is weird, it may be a symptom of cpptrace not finding any symbols to resolve so it doesn't load those libs even lazily? Qt puts the symbols in a file my.exe.debug next to my.exe, and from PE file I uploaded for davea42/libdwarf-code#240 (comment), I can see there's a On a similar note, but a different question, let's say I give someone my.exe only (with the symbols being in the separate .debug file). Then cpptrace makes a trace (that I write into a text file), it will obviously not have symbols, only addresses. Is there an easy way to parse that file back later (e.g. in a minimalistic source) and resolve the symbols, while in the possession of .debug file? I already have such a solution using addr2line, but it would be great to have cpptrace solution as well. |
Beta Was this translation helpful? Give feedback.
-
Libdwarf is what resolves the symbols, so at the very least it has to load libdwarf to know symbols can't be found. The one way it wouldn't go down this path is if something goes wrong with resolving offsets in the .exe file or looking up the module for an address, but if that were happening you wouldn't get symbols in the other case either. So I'm still confused 😅
Yes! That should be possible with cpptrace. If you parse your trace file into an |
Beta Was this translation helpful? Give feedback.
-
Libdwarf is what resolves the symbols, so at the very least it has to load libdwarf to know symbols can't be found. The one way it wouldn't go down this path is if something goes wrong with resolving offsets in the .exe file or looking up the module for an address, but if that were happening you wouldn't get symbols in the other case either. So I'm still confused 😅
Yes! That should be possible with cpptrace. If you parse your trace file into an If it's helpful, the signal safe tracing demo for linux may serve as a good proof of concept as it sends object frames to another process which then resolves symbols for the original process. (the one difference being the use of |
Beta Was this translation helpful? Give feedback.
-
Hi Jeremy,
Could you look into the still open issue with the debug symbols in a
separate file not found by cpptrace?
…On Thu, 16 May 2024 at 05:03, Jeremy Rifkin ***@***.***> wrote:
Sorry I should have clarified, and should probably document this better
somewhere: The two fields you need to populate in the object_frame are
object_path and object_address. The raw_address is the runtime address
including ASLR and whatnot so this number is useless outside the invocation
of the executable it comes from but the object path and object address will
contain all the info needed to resolve the symbol from anywhere. In the
context of addr2line, it's very much addr2line -e $object_path
$object_address. How you serialize these two is up to you, pretty much
anything should work.
—
Reply to this email directly, view it on GitHub
<#118 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADZ2Q7WNBV6KPDXJ54JKOWTZCQOYLAVCNFSM6AAAAABHJX3CZGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TINJSGY2DE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hey,
Longer story incoming for context. TLDR: How to configure cpptrace for my project?
I have a C++ project built on Qt5, deployed to Linux and Windows using the same code-base. I built a quite different stack trace solution on the 2 platforms, because I was using boost/stacktrace on Linux for simplicity, and (since that's useless on Windows) I had a manually built StackWalk64+addr2line solution, which was okay but super ugly (as I am not well versed in this topic).
I recently found cpptrace, and I wanted to give it a go in unifying my stack tracing.
On Linux, it was a super simple cmake build and it worked perfectly with default settings.
However, on Windows I am having mixed results. Qt has its own project setup using "qmake": a twisted, cmake-like beast. In order to build depedencies, I am using MSYS2 (mingw64), which worked good so far. The root of my question comes from the fact that the default dwarf+dbghelp doesn't give me any symbols. I am building cpptrace with
cmake -G "MinGW Makefiles" .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCPPTRACE_BUILD_SHARED=On && mingw32-make -j
, then linking in zlib1 from MSYS and dynamically linking cpptrace and its deps into my project. It compiles and runs but gives me stack lines like:If I switch to addr2line (that my own home-brew was also using) by adding
-DCPPTRACE_GET_SYMBOLS_WITH_ADDR2LINE=On
, I get real symbols from my binary. Strangely, my homebrew was also fetching symbols from outside my binary (like Qt's own DLLs), while cpptrace doesn't get those symbols.The results are the same whether I configure Qt to put debug symbols into a separate file, or inside the main binary.
Can I configure cpptrace any better, or is this the limit for my project? Thanks in advance for any help, much appreciated! :)
Beta Was this translation helpful? Give feedback.
All reactions