PGROUTING  3.2
pgr_assert.cpp File Reference
#include "cpp_common/pgr_assert.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string>
#include <exception>
Include dependency graph for pgr_assert.cpp:

Go to the source code of this file.

Functions

std::string get_backtrace ()
 returns the execution path of the trace More...
 
std::string get_backtrace (const std::string &msg)
 

Function Documentation

◆ get_backtrace() [1/2]

std::string get_backtrace ( )

returns the execution path of the trace

In case of a failed exception the backtrace can be is shown in the error message.

Does not work for windows, please read: http://stackoverflow.com/questions/27639931/can-not-find-execinfo-h-when-setup-malpack

Definition at line 40 of file pgr_assert.cpp.

40  {
41 #ifdef __GLIBC__
42  void *trace[16];
43  int i, trace_size = 0;
44 
45  trace_size = backtrace(trace, 16);
46  char** funcNames = backtrace_symbols(trace, trace_size);
47 
48 
49  std::string message = "\n*** Execution path***\n";
50  for (i = 0; i < trace_size; ++i) {
51  message += "[bt]" + static_cast<std::string>(funcNames[i]) + "\n";
52  }
53 
54  free(funcNames);
55  return message;
56 #else
57  return "";
58 #endif
59 }

Referenced by get_backtrace().

◆ get_backtrace() [2/2]

std::string get_backtrace ( const std::string &  msg)

Definition at line 61 of file pgr_assert.cpp.

61  {
62  return std::string("\n") + msg + "\n" + get_backtrace();
63 }

References get_backtrace().

get_backtrace
std::string get_backtrace()
returns the execution path of the trace
Definition: pgr_assert.cpp:40