-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
stacktrace #2502
stacktrace #2502
Conversation
I pushed two commits:
|
More strict check for initialization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly nits! Otherwise, this looks good :)
Co-authored-by: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com>
Co-authored-by: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com>
Co-authored-by: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved! If you want, you can also change to using resize
if you like.
@StephanTLavavej - I have not fully researched |
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
I have pushed an additional commit to fix the internal test harness. |
Thanks for implementing this major C++23 feature! 😻 🎉 ✨ |
@AlexGuteniev , @StephanTLavavej , it looked like there was a doc ask here. What are the details? |
#2779 documnent limits in my take on limits. Still want that to be reviewed by maintainers first |
Co-authored-by: Adam Bucior <35536269+AdamBucior@users.noreply.github.com> Co-authored-by: Daniel Marshall <xandan@gmail.com> Co-authored-by: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com> Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
Resolves #1447
Thanks @cbezault for suggestion to use
<DbgEng.h>
, @fsb4000 for making sure it works on Windows 7, @ben-craig for pointing out that<DbgEng.h>
does not look in a path next to the module by default.Before going forward with this, here are some open issues:
1. API family, thread safety, COM apartments safety
There are three API families, neither of which seems fully good:
DbgHelp
The classic one. Every function has the following remark:
This seem to exclude DbgHelp -- even though we can use locks internally, user may call the function bypassing the lock
On the good part, it does not have COM dependency.
DbgEng
<DbgEng.h>
API is COM-like, but full COM. So still no COM dependency.There's a problem with picking a
.pdb
next to image -- see below.Also I've seen under a debugger that it uses
<DbgHelp>
underneath with locks. This means it is not thread safe too -- the client code may use DbgHelp directly.There's a concert that the interfaces are documented as single-threaded and not usable via another thread. For now the problem is not seen, but if it is a problem, can be fixed by thread-local storage, also not caching these interfaces can be investigated.
DIA SDK
Uses COM. The usual usage of COM with
CoInitialize[Ex]
is problematic in STL - there are two incompatible COM modes, and if STL choices one, it will break programs which wants another (possibly in a subtle way).There's information that
NoRegCoCreate
function can be used to avoid the need ofCoInitialize[Ex]
. I haven't tried yet. It is not a documented function, but it exists in DIA SDK headers (DIA SDK\include\diacreate.h
) with a comment description.DIA SDK is not a Windows component, but it is redistributable: https://docs.microsoft.com/en-us/visualstudio/releases/2022/redistribution#dia-sdk
4. Roll own .pdb parsing
Tedious, but full control over thread and COM safety.
If we are to go this route, probably should make a separate open source library that can be reused elsewhere (Boost.Stacktrace, libc++
std::stacktrace
, LLVM ASan stack trace)5. Use helper process
With this, DbgHelp will work fine. Though this won't be efficient
2. Looking up for
.pdb
next to imageAs @ben-craig pointed out, seems like DbgEng does not work well when having
.pdb
in not exact path where it is expected. So having a.pdb
next to EXE / DLL, but not in the same folder as where it was originally created makes symbol lookup failure.Currently I have a workaround,
module_symbols_load_from_module_dir
function, but it is considered very harmful. The problems are:Storing previous search dir and restoring it later will eliminate the former problem by making the later problem worse.
Apparently, with DbgHelp looking up next to image is done by default, and its
SymSetOptions
hasSYMOPT_IGNORE_IMAGEDIR
option to explicitly disable this. But DbgEng symbol does not list it among its options.Current resolution: use the workaround. Though I'd be more happy documenting the limitation and options to bypass it (like
/PDBALTPATH:%_PDB%
as @sylveon suggested).3. Dll main safety
I cache pointers to
<DbgEng.h>
interfaces, removing them inatexit
. for a DLL this is effectively in aDllMain
. Though it is not safe to do most of thing inDllMain
, I guess there are no other options. Not caching would be too inefficient, I think.Need confirmation whether it is the way to go.
Current resolution: ignore the potential problem.
Information format
I made the following:
description
is liketrace!f1+0x8a
. This includes module name, function name, offset within function (hex). No params, as they are hard to get. The paper does not ask for module name and offset within function, but I think these are essential. Note that<DbgEng.h>
also provides module name by default, so it actually takes some effort to strip it.source_file
andsource_line
are obvious. Don't trim full path from source file if it is provided.stacktrace_entry
isfile(line): description
to be compatible with Visual Studio usual output. Don't report offset within line (source_column
) as the paper does not ask for it, and it is not very essential.\n
and prepended byn>
to number entries starting from 0.@ben-craig points to Boost.Stacktrace has a different format, notably:
#
symbol for entries umberingfile.cpp:3
format of line numberingThis is similar to ASan output, like this:
The drawback is that IDE does not understand this format when trying to click on entry. There's DevCom-1660805 for that. If it is taken, then probably this format is better.
Network symbols
Symbols can be loaded from network. Typically it is Microsoft Symbols Server, but could be any location where
_NT_SYMBOL_PATH
points to.Should we load over network by default? Only when
_NT_SYMBOL_PATH
is likeSRV*c:\temp\WinSymbols*http://msdl.microsoft.com/download/symbols;
? Or avoid network locations at all?The primary concerns are: