source: XIOS3/trunk/src/backtrace.cpp @ 2628

Last change on this file since 2628 was 2593, checked in by jderouillat, 8 months ago

Rename the MemTrack? namespace associated to CppTrace? (conflict with the --memtrack option), waiting for its full integration

  • Property svn:executable set to *
File size: 799 bytes
Line 
1#include <map>
2#include <sstream>
3#include <string>
4#include "backtrace.hpp"
5#include "cpptrace.hpp"
6
7namespace xios
8{
9  namespace MemCppTrack
10  {
11    void backTrace(std::ostringstream& stack, int n)
12    {
13      using namespace cpptrace ;
14      std::vector<stacktrace_frame> stackTrace ;
15      stackTrace = generate_trace(n);
16      for(auto& st : stackTrace)
17      {
18         size_t pos, pos1, pos2 ;
19         pos1 = st.filename.rfind("/src/") ;
20         if (pos1>st.filename.size()) pos1=0 ;
21         pos2 = st.filename.rfind("/extern/") ;
22         if (pos2>st.filename.size()) pos2=0 ;
23
24         pos = pos1 > pos2 ? pos1 : pos2 ;
25
26         std::string file = st.filename.substr(pos,st.filename.size()) ;
27         stack<<st.symbol<<" ==> ."<<file <<" : l"<<st.line<<std::endl ;
28      }
29    }
30  }
31}
Note: See TracBrowser for help on using the repository browser.