PGROUTING  2.6-dev
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

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 26 of file pgr_assert.cpp.

Referenced by get_backtrace().

26  {
27 #ifdef __GLIBC__
28  void *trace[16];
29  int i, trace_size = 0;
30 
31  trace_size = backtrace(trace, 16);
32  char** funcNames = backtrace_symbols(trace, trace_size);
33 
34 
35  std::string message = "\n*** Execution path***\n";
36  for (i = 0; i < trace_size; ++i) {
37  message += "[bt]" + static_cast<std::string>(funcNames[i]) + "\n";
38  }
39 
40  free(funcNames);
41  return message;
42 #else
43  return "";
44 #endif
45 }

Here is the caller graph for this function:

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

Definition at line 47 of file pgr_assert.cpp.

References get_backtrace().

47  {
48  return std::string("\n") + msg + "\n" + get_backtrace();
49 }
std::string get_backtrace()
returns the execution path of the trace
Definition: pgr_assert.cpp:26

Here is the call graph for this function: