Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-58046

add demangled name to printStackTrace

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: None

      Description

      This can be helpful for human reading of stack traces in BF tickets, but they tend to be significantly longer than the mangled names. So what though?

      Here's an example.

       
      diff --git a/src/mongo/util/stacktrace_posix.cpp b/src/mongo/util/stacktrace_posix.cpp
      index 7b888f16c8..6476e42a7b 100644
      --- a/src/mongo/util/stacktrace_posix.cpp
      +++ b/src/mongo/util/stacktrace_posix.cpp
      @@ -41,6 +41,7 @@
       #include <iomanip>
       #include <iostream>
       #include <string>
      +#include <cxxabi.h>
       
       #include "mongo/base/init.h"
       #include "mongo/bson/json.h"
      @@ -164,6 +165,13 @@ void appendBacktrace(BSONObjBuilder* obj, IterationIface& iter, const Options& o
               }
               if (const auto& sym = meta.symbol(); sym) {
                   frame.append("s", sym.name());
      +            if (1) {
      +                int status;
      +                char* realname = abi::__cxa_demangle(std::string(sym.name()).c_str(), 0, 0, &status);
      +                if (status == 0)
      +                    frame.append("Cxx", realname);
      +                std::free(realname);
      +            }
                   frame.append("s+", Hex(offsetFromBase(sym.base(), addr)));
               }
           }
      

      {
        "t": {
          "$date": "2021-06-23T18:53:24.158-04:00"
        },
        "s": "I",
        "c": "CONTROL",
        "id": 31380,
        "ctx": "conn12",
        "msg": "BACKTRACE",
        "attr": {
          "bt": {
            "backtrace": [
              {
                "a": "1068C46A1",
                "b": "104C3D000",
                "o": "1C876A1",
                "s": "_ZN5mongo18stack_trace_detail12_GLOBAL__N_119printStackTraceImplERKNS1_7OptionsEPNS_14StackTraceSinkE",
                "Cxx": "mongo::stack_trace_detail::(anonymous namespace)::printStackTraceImpl(mongo::stack_trace_detail::(anonymous namespace)::Options const&, mongo::StackTraceSink*)",
                "s+": "121"
              },
              {
                "a": "1068C5B38",
                "b": "104C3D000",
                "o": "1C88B38",
                "s": "_ZN5mongo15printStackTraceEv",
                "Cxx": "mongo::printStackTrace()",
                "s+": "28"
              },
              {
                "a": "1056663A4",
                "b": "104C3D000",
                "o": "A293A4",
                "s": "_ZN5mongo14CommandHelpers34shouldActivateFailCommandFailPointERKNS_7BSONObjERKNS_15NamespaceStringEPKNS_7CommandEPNS_6ClientE",
                "Cxx": "mongo::CommandHelpers::shouldActivateFailCommandFailPoint(mongo::BSONObj const&, mongo::NamespaceString const&, mongo::Command const*, mongo::Client*)",
                "s+": "6B4"
              },
              {
                "a": "105665C68",
                "b": "104C3D000",
                "o": "A28C68",
                "s": "_ZN5mongo14CommandHelpers34shouldActivateFailCommandFailPointERKNS_7BSONObjEPKNS_17CommandInvocationEPNS_6ClientE",
                "Cxx": "mongo::CommandHelpers::shouldActivateFailCommandFailPoint(mongo::BSONObj const&, mongo::CommandInvocation const*, mongo::Client*)",
                "s+": "78"
              },
              {
                "a": "10566A2A0",
                "b": "104C3D000",
                "o": "A2D2A0",
                "s": "_ZZN5mongo14CommandHelpers28evaluateFailCommandFailPointEPNS_16OperationContextEPKNS_17CommandInvocationEENK4$_19clERKNS_7BSONObjE",
                "Cxx": "mongo::CommandHelpers::evaluateFailCommandFailPoint(mongo::OperationContext*, mongo::CommandInvocation const*)::$_19::operator()(mongo::BSONObj const&) const",
                "s+": "310"
              },
              {
                "a": "105666654",
                "b": "104C3D000",
                "o": "A29654",
                "s": "_ZN5mongo14CommandHelpers28evaluateFailCommandFailPointEPNS_16OperationContextEPKNS_17CommandInvocationE",
                "Cxx": "mongo::CommandHelpers::evaluateFailCommandFailPoint(mongo::OperationContext*, mongo::CommandInvocation const*)",
                "s+": "134"
              },
              {
                "a": "104DFDFE3",
                "b": "104C3D000",
                "o": "1C0FE3",
                "s": "_ZN5mongo12_GLOBAL__N_118ParseAndRunCommand13RunInvocation6_setupEv",
                "Cxx": "mongo::(anonymous namespace)::ParseAndRunCommand::RunInvocation::_setup()",
                "s+": "303"
              },
              {
                "a": "104DFBDCA",
                "b": "104C3D000",
                "o": "1BEDCA",
                "s": "_ZZN5mongo12_GLOBAL__N_118ParseAndRunCommand3runEvENK4$_20clEv",
                "Cxx": "mongo::(anonymous namespace)::ParseAndRunCommand::run()::$_20::operator()() const",
                "s+": "F5A"
              },
              {
                "a": "104DFA7AF",
                "b": "104C3D000",
                "o": "1BD7AF",
                "s": "_ZN5mongo12_GLOBAL__N_118ParseAndRunCommand3runEv",
                "Cxx": "mongo::(anonymous namespace)::ParseAndRunCommand::run()",
                "s+": "3F"
              },
              {
                "a": "104DF364F",
                "b": "104C3D000",
                "o": "1B664F",
                "s": "_ZN5mongo13ClientCommand8_executeEv",
                "Cxx": "mongo::ClientCommand::_execute()",
                "s+": "31F"
              },
              {
                "a": "104DF580F",
                "b": "104C3D000",
                "o": "1B880F",
                "s": "_ZN5mongo13ClientCommand3runEv",
                "Cxx": "mongo::ClientCommand::run()",
                "s+": "3F"
              },
              {
                "a": "104DF66F0",
                "b": "104C3D000",
                "o": "1B96F0",
                "s": "_ZN5mongo8Strategy13clientCommandENSt3__110shared_ptrINS_23RequestExecutionContextEEE",
                "Cxx": "mongo::Strategy::clientCommand(std::__1::shared_ptr<mongo::RequestExecutionContext>)",
                "s+": "E0"
              },
              {
                "a": "104C593F6",
                "b": "104C3D000",
                "o": "1C3F6",
                "s": "_ZN5mongo15CommandOpRunner3runEv",
                "Cxx": "mongo::CommandOpRunner::run()",
                "s+": "46"
              },
              {
                "a": "104C5917D",
                "b": "104C3D000",
                "o": "1C17D",
                "s": "_ZN5mongo13HandleRequest13handleRequestEv",
                "Cxx": "mongo::HandleRequest::handleRequest()",
                "s+": "22D"
              },
              {
                "a": "104C5D665",
                "b": "104C3D000",
                "o": "20665",
                "s": "_ZZN5mongo15unique_functionIFvPNS_14future_details15SharedStateBaseEEE8makeImplIZNS1_10FutureImplINS1_8FakeVoidEE16makeContinuationINS_10DbResponseEZZNOS9_4thenIZNS_13HandleRequest3runEvE3$_4EEDaOT_ENKUlvE_clEvEUlPNS1_15SharedStateImplIS8_EEPNSJ_ISB_EEE_EENS7_ISG_EEOT0_EUlS3_E_EESF_SH_EN12SpecificImpl4callEOS3_",
                "Cxx": "mongo::HandleRequest::run()::$_4 mongo::unique_function<void (mongo::future_details::SharedStateBase*)>::makeImpl<mongo::future_details::FutureImpl<mongo::HandleRequest::run()::$_4&&> mongo::future_details::FutureImpl<mongo::future_details::FakeVoid>::makeContinuation<mongo::DbResponse, auto mongo::future_details::FutureImpl<mongo::future_details::FakeVoid>::then<mongo::HandleRequest::run()::$_4>(mongo::HandleRequest::run()::$_4&&) &&::'lambda'()::operator()() const::'lambda'(mongo::future_details::SharedStateImpl<mongo::future_details::FakeVoid>*, mongo::future_details::SharedStateImpl<mongo::future_details::FakeVoid><mongo::DbResponse>*)>(auto mongo::future_details::FutureImpl<mongo::future_details::FakeVoid>::then<mongo::HandleRequest::run()::$_4>(mongo::HandleRequest::run()::$_4&&) &&::'lambda'()::operator()() const::'lambda'(mongo::future_details::SharedStateImpl<mongo::future_details::FakeVoid>*, mongo::future_details::SharedStateImpl<mongo::future_details::FakeVoid><mongo::DbResponse>*)&&)::'lambda'(mongo::future_details::SharedStateBase*)>('lambda'())::SpecificImpl::call(mongo::future_details::SharedStateBase*&&)",
                "s+": "145"
              },
              {
                "a": "104C5BDDA",
                "b": "104C3D000",
                "o": "1EDDA",
                "s": "_ZN5mongo14future_details15SharedStateBase20transitionToFinishedEv",
                "Cxx": "mongo::future_details::SharedStateBase::transitionToFinished()",
                "s+": "9A"
              },
              {
                "a": "104C5C9D9",
                "b": "104C3D000",
                "o": "1F9D9",
                "s": "_ZZN5mongo15unique_functionIFvPNS_14future_details15SharedStateBaseEEE8makeImplIZNS1_10FutureImplINS1_8FakeVoidEE16makeContinuationIvZZNOS9_4thenIZNS_13HandleRequest3runEvE3$_3EEDaOT_ENKUlvE_clEvEUlPNS1_15SharedStateImplIS8_EESK_E_EENS7_ISF_EEOT0_EUlS3_E_EESE_SG_EN12SpecificImpl4callEOS3_",
                "s+": "E9"
              },
              {
                "a": "104C5BDDA",
                "b": "104C3D000",
                "o": "1EDDA",
                "s": "_ZN5mongo14future_details15SharedStateBase20transitionToFinishedEv",
                "Cxx": "mongo::future_details::SharedStateBase::transitionToFinished()",
                "s+": "9A"
              },
              {
                "a": "104C5A8FA",
                "b": "104C3D000",
                "o": "1D8FA",
                "s": "_ZN5mongo13HandleRequest3runEv",
                "Cxx": "mongo::HandleRequest::run()",
                "s+": "140A"
              },
              {
                "a": "104C5B2F7",
                "b": "104C3D000",
                "o": "1E2F7",
                "s": "_ZN5mongo23ServiceEntryPointMongos13handleRequestEPNS_16OperationContextERKNS_7MessageE",
                "Cxx": "mongo::ServiceEntryPointMongos::handleRequest(mongo::OperationContext*, mongo::Message const&)",
                "s+": "C7"
              },
              {
                "a": "104C93CC7",
                "b": "104C3D000",
                "o": "56CC7",
                "s": "_ZN5mongo9transport19ServiceStateMachine4Impl14processMessageEv",
                "Cxx": "mongo::transport::ServiceStateMachine::Impl::processMessage()",
                "s+": "227"
              },
              {
                "a": "104C9A6AD",
                "b": "104C3D000",
                "o": "5D6AD",
                "s": "_ZZNO5mongo14future_details10FutureImplINS0_8FakeVoidEE4thenIZNS_9transport19ServiceStateMachine4Impl12startNewLoopERKNS_6StatusEE3$_9EEDaOT_ENKUlOS2_E_clESF_",
                "Cxx": "auto mongo::future_details::FutureImpl<mongo::future_details::FakeVoid>::then<mongo::transport::ServiceStateMachine::Impl::startNewLoop(mongo::Status const&)::$_9>(mongo::transport::ServiceStateMachine::Impl::startNewLoop(mongo::Status const&)::$_9&&) &&::'lambda'(mongo::future_details::FakeVoid&&)::operator()('lambda'(mongo::future_details::FakeVoid&&)) const",
                "s+": "2D"
              },
              {
                "a": "104C947DE",
                "b": "104C3D000",
                "o": "577DE",
                "s": "_ZN5mongo9transport19ServiceStateMachine4Impl12startNewLoopERKNS_6StatusE",
                "Cxx": "mongo::transport::ServiceStateMachine::Impl::startNewLoop(mongo::Status const&)",
                "s+": "10E"
              },
              {
                "a": "104C9C95F",
                "b": "104C3D000",
                "o": "5F95F",
                "s": "_ZZN5mongo15unique_functionIFvNS_6StatusEEE8makeImplIZZNS_9transport19ServiceStateMachine4Impl12startNewLoopERKS1_ENK4$_11clES1_EUlS1_E_EEDaOT_EN12SpecificImpl4callEOS1_",
                "Cxx": "auto mongo::unique_function<void (mongo::Status)>::makeImpl<mongo::transport::ServiceStateMachine::Impl::startNewLoop(mongo::Status const&)::$_11::operator()(mongo::Status) const::'lambda'(mongo::Status)>(mongo::transport::ServiceStateMachine::Impl::startNewLoop(mongo::Status const&)::$_11::operator()(mongo::Status) const::'lambda'(mongo::Status)&&)::SpecificImpl::call(mongo::Status&&)",
                "s+": "4F"
              },
              {
                "a": "10621E5DE",
                "b": "104C3D000",
                "o": "15E15DE",
                "s": "_ZZN5mongo15unique_functionIFvNS_6StatusEEE8makeImplIZNS_9transport26ServiceExecutorSynchronous18runOnDataAvailableERKNSt3__110shared_ptrINS5_7SessionEEES3_E3$_5EEDaOT_EN12SpecificImpl4callEOS1_",
                "Cxx": "auto mongo::unique_function<void (mongo::Status)>::makeImpl<mongo::transport::ServiceExecutorSynchronous::runOnDataAvailable(std::__1::shared_ptr<mongo::transport::Session> const&, mongo::unique_function<void (mongo::Status)>)::$_5>(mongo::transport::ServiceExecutorSynchronous::runOnDataAvailable(std::__1::shared_ptr<mongo::transport::Session> const&, mongo::unique_function<void (mongo::Status)>)::$_5&&)::SpecificImpl::call(mongo::Status&&)",
                "s+": "3E"
              },
              {
                "a": "10621AE57",
                "b": "104C3D000",
                "o": "15DDE57",
                "s": "_ZZN5mongo9transport15ServiceExecutor8scheduleENS_15unique_functionIFvNS_6StatusEEEEENUlvE_clEv",
                "Cxx": "mongo::transport::ServiceExecutor::schedule(mongo::unique_function<void (mongo::Status)>)::'lambda'()::operator()()",
                "s+": "37"
              },
              {
                "a": "10621E2D8",
                "b": "104C3D000",
                "o": "15E12D8",
                "s": "_ZZN5mongo15unique_functionIFvvEE8makeImplIZNS_9transport26ServiceExecutorSynchronous12scheduleTaskES2_NS4_15ServiceExecutor13ScheduleFlagsEE3$_4EEDaOT_EN12SpecificImpl4callEv",
                "Cxx": "auto mongo::unique_function<void ()>::makeImpl<mongo::transport::ServiceExecutorSynchronous::scheduleTask(mongo::unique_function<void ()>, mongo::transport::ServiceExecutor::ScheduleFlags)::$_4>(mongo::transport::ServiceExecutorSynchronous::scheduleTask(mongo::unique_function<void ()>, mongo::transport::ServiceExecutor::ScheduleFlags)::$_4&&)::SpecificImpl::call()",
                "s+": "168"
              },
              {
                "a": "10621F008",
                "b": "104C3D000",
                "o": "15E2008",
                "s": "_ZN5mongo12_GLOBAL__N_17runFuncEPv",
                "Cxx": "mongo::(anonymous namespace)::runFunc(void*)",
                "s+": "18"
              },
              {
                "a": "7FFF205FF8FC",
                "b": "7FFF205F9000",
                "o": "68FC",
                "s": "_pthread_start",
                "s+": "E0"
              },
              {
                "a": "7FFF205FB443",
                "b": "7FFF205F9000",
                "o": "2443",
                "s": "thread_start",
                "s+": "F"
              }
            ],
            "processInfo": {
              "mongodbVersion": "5.0.0-alpha0-1193-gfaec09d",
              "gitVersion": "faec09dbc6bb19cf0e2e457c9c11258460be7f11",
              "compiledModules": [
                "enterprise"
              ],
              "uname": {
                "sysname": "Darwin",
                "release": "20.5.0",
                "version": "Darwin Kernel Version 20.5.0: Sat May  8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64",
                "machine": "x86_64"
              },
              "somap": [
                {
                  "path": "/Users/billy/prog/mongodb/mongo/build/install/bin/mongos",
                  "machType": 2,
                  "b": "104C3D000",
                  "vmaddr": "100000000",
                  "buildId": "FE6F77E70D8E34A889947769ED8D96DA"
                },
                {
                  "path": "/usr/lib/system/libsystem_pthread.dylib",
                  "machType": 6,
                  "b": "7FFF205F9000",
                  "vmaddr": "7FFF20308000",
                  "buildId": "17482C9D061E3769AC9EBE1239D33098"
                }
              ]
            }
          }
        }
      }
      

        Attachments

          Activity

            People

            Assignee:
            backlog-server-servicearch Backlog - Service Architecture
            Reporter:
            billy.donahue Billy Donahue
            Participants:
            Votes:
            4 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated: