PGROUTING
3.2
pgr_assert.cpp
Go to the documentation of this file.
1
/*PGR-GNU*****************************************************************
2
3
FILE: pgr_assert.cpp
4
5
Copyright 2015~ Vicky Vergara <
[email protected]
>
6
Copyright 2014 Stephen Woodbridge <
[email protected]
>
7
Mail:
[email protected]
8
9
------
10
11
This program is free software; you can redistribute it and/or modify
12
it under the terms of the GNU General Public License as published by
13
the Free Software Foundation; either version 2 of the License, or
14
(at your option) any later version.
15
16
This program is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
GNU General Public License for more details.
20
21
You should have received a copy of the GNU General Public License
22
along with this program; if not, write to the Free Software
23
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
25
********************************************************************PGR-GNU*/
26
#include "
cpp_common/pgr_assert.h
"
27
28
#include <stdio.h>
29
#include <stdlib.h>
30
#include <stddef.h>
31
32
#ifdef __GLIBC__
33
#include <execinfo.h>
34
#endif
35
36
#include <string>
37
#include <exception>
38
39
40
std::string
get_backtrace
() {
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
}
60
61
std::string
get_backtrace
(
const
std::string &msg) {
62
return
std::string(
"\n"
) + msg +
"\n"
+
get_backtrace
();
63
}
64
65
66
67
const
char
*
AssertFailedException::what
()
const
throw() {
68
return
str
.c_str();
69
}
70
71
AssertFailedException::AssertFailedException
(std::string msg) :
72
str(msg) {}
73
AssertFailedException::what
virtual const char * what() const
Definition:
pgr_assert.cpp:67
AssertFailedException::str
const std::string str
Holds what() we got as message.
Definition:
pgr_assert.h:141
get_backtrace
std::string get_backtrace()
returns the execution path of the trace
Definition:
pgr_assert.cpp:40
pgr_assert.h
An assert functionality that uses C++ throw().
AssertFailedException::AssertFailedException
AssertFailedException(std::string msg)
Definition:
pgr_assert.cpp:71
src
common
pgr_assert.cpp
Generated on Tue May 25 2021 15:09:48 for PGROUTING by
1.8.17