Skip to content

P0881R7 <stacktrace> #1447

Closed
Closed

Description

P0881R7 <stacktrace>
P2301R1 Add A pmr Alias For std::stacktrace

Feature-test macro:

#define __cpp_lib_stacktrace 202011L

Casey Carter (@CaseyCarter)'s internal VS-PR-339694 has taught the IDE to recognize this as a C++ header.

Activity

  1. changed the title [-]P0881R7 <stacktrace>[/-] [+]P0881R7 `<stacktrace>`[/+] on Jun 9, 2021
  2. miscco commented on Jun 30, 2021

    @miscco
    Contributor

    Does this require compiler support and should it be marked as blocked until compiler support is ready?

  3. leha-bot commented on Jul 7, 2021

    @leha-bot

    As I understood, no, we could just links to imghelp.dll and use its StackWalk() API.
    I have a very draft WIP implementation for it :)

  4. AlexGuteniev commented on Jul 20, 2021

    @AlexGuteniev
    Contributor

    There's an alternative -- CaptureStackBackTrace. It is faster than StackWalk, but it is not a part of complete API family.

    There's also IDiaStackWalker::getEnumFrames2, but it is the same as StackWalk (apparently one is a wrapper on another).

  5. AlexGuteniev commented on Jul 20, 2021

    @AlexGuteniev
    Contributor

    There's a caveat. Documentation of StackWalk64 and friends contains the following:

    All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more than one thread to this function.

    I'm not sure how to address this properly in <stacktrace>

  6. leha-bot commented on Jul 20, 2021

    @leha-bot

    CaptureStackBackTrace

    Thanks, Alex, completely forgot about this kernrl32 function, would try it later.

  7. AlexGuteniev commented on Jul 23, 2021

    @AlexGuteniev
    Contributor

    Alex (@leha-bot) , are you planning to submit a PR ?
    I'm interested in this feature.

  8. leha-bot commented on Jul 24, 2021

    @leha-bot

    Yes, as a proposal co-author :)

  9. AlexGuteniev commented on Jul 24, 2021

    @AlexGuteniev
    Contributor

    Wow)

  10. SuperWig commented on Jul 25, 2021

    @SuperWig
    Contributor

    Would it make sense to mark this issue as work in progress in that case?

  11. StephanTLavavej commented on Aug 8, 2021

    @StephanTLavavej
    MemberAuthor

    Sure, I've labeled this as "work in progress" and moved it to the Investigating column.

    (Guess who's catching up on half-month-old notifications?)

  12. StephanTLavavej commented on Oct 5, 2021

    @StephanTLavavej
    MemberAuthor

    I've updated this issue to mention the patch paper P2301R1 "Add A pmr Alias For std::stacktrace" which was just accepted, with no changes to the feature-test macro.

  13. 5 remaining items

  14. AlexGuteniev commented on Feb 2, 2022

    @AlexGuteniev
    Contributor

    stacktrace would also benefit from using const char*. And from adding column

  15. KindDragon commented on Feb 2, 2022

    @KindDragon

    I'm wondering why doesn't stacktrace use source_location, and why doesn't it provide column

    Hi, Antony Polukhin (@apolukhin). Do you know why?

  16. apolukhin commented on Feb 2, 2022

    @apolukhin

    I'm wondering why doesn't stacktrace use source_location, and why doesn't it provide column

    This is due to platform divergence. As it is stated in P0881R7: "Unfortunately this is a necessarity on some platforms, where getting source line requires allocating or where source file name returned into a storage provided by user."

  17. AlexGuteniev commented on Feb 2, 2022

    @AlexGuteniev
    Contributor

    "Unfortunately this is a necessarity on some platforms, where getting source line requires allocating or where source file name returned into a storage provided by user."

    I see. Although this could have been addressed by making the std::string internal to stacktrace_entry, it would have required extra member to hold the buffer.

    Why no source_column anyway? At least in Windows it is available for free.

  18. apolukhin commented on Feb 2, 2022

    @apolukhin

    Why no source_column anyway? At least in Windows it is available for free.

    Most popular solutions for non-Windows platforms do not provide a source_column(). At the moment std::stacktrace is a minimal subset of abilities of all platforms, so the column is missing. This could be changed later, the addition seems quite simple for C++ standardization.

  19. AlexGuteniev commented on Feb 7, 2022

    @AlexGuteniev
    Contributor

    Antony Polukhin (@apolukhin) , should std::stacktrace load symbols from the Internet?

  20. apolukhin commented on Feb 9, 2022

    @apolukhin

    Antony Polukhin (@apolukhin) , should std::stacktrace load symbols from the Internet?

    It may. It is a question of "quality of implementation" and user needs. Some of the users would love such a feature. For others opening a socket in their application may be a showstopper.

    IMO the feature is a very good one if there is a switch to disable it.

  21. AlexGuteniev commented on Feb 9, 2022

    @AlexGuteniev
    Contributor

    I see, I also think so, the question is the default then. I was thinking a good default would be to use module names, export names, names from .pdbs, but don't go to http/https symbols servers for them.

    Also I would like the configuration to be runtime, using a global or static function member setter for a thread-local variable (I wouldn't like passing extra parameters to getters, or, especially, to << operators)

  22. jonwil commented on Feb 9, 2022

    @jonwil

    How would std::stacktrace retrieve symbols from PDB files?
    And if the symbols it retrieves are C++ mangled names, how would it demangle those names?
    Would this functionality rely on the msdia library for PDB reading?

  23. AlexGuteniev commented on Feb 9, 2022

    @AlexGuteniev
    Contributor

    How would std::stacktrace retrieve symbols from PDB files?

    An open question I guess.
    My PR currently uses DbgEng, but lists main alternatives and their drawback as the first question to decide upon.

  24. AlexGuteniev commented on Jun 10, 2022

    @AlexGuteniev
    Contributor

    How would std::stacktrace retrieve symbols from PDB files? And if the symbols it retrieves are C++ mangled names, how would it demangle those names? Would this functionality rely on the msdia library for PDB reading?

    See #2779

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cxx23fixed

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions