mirror of
https://github.com/QuasarApp/backward-cpp.git
synced 2025-04-30 04:14:30 +00:00
few modification for pedantic compliance with C++98 and C++11
This commit is contained in:
parent
9f2ee49512
commit
2bb696b8e2
@ -28,8 +28,7 @@ project(backward CXX)
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic-errors")
|
||||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
38
backward.hpp
38
backward.hpp
@ -162,6 +162,7 @@
|
|||||||
#ifdef __CLANG_UNWIND_H
|
#ifdef __CLANG_UNWIND_H
|
||||||
// In fact, this function still comes from libgcc (on my different linux boxes,
|
// In fact, this function still comes from libgcc (on my different linux boxes,
|
||||||
// clang links against libgcc).
|
// clang links against libgcc).
|
||||||
|
# include <inttypes.h>
|
||||||
extern "C" uintptr_t _Unwind_GetIPInfo(_Unwind_Context*, int*);
|
extern "C" uintptr_t _Unwind_GetIPInfo(_Unwind_Context*, int*);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -390,7 +391,7 @@ public:
|
|||||||
|
|
||||||
struct Trace {
|
struct Trace {
|
||||||
void* addr;
|
void* addr;
|
||||||
size_t idx;
|
unsigned idx;
|
||||||
|
|
||||||
Trace():
|
Trace():
|
||||||
addr(0), idx(0) {}
|
addr(0), idx(0) {}
|
||||||
@ -475,8 +476,8 @@ struct ResolvedTrace: public TraceWithLocals {
|
|||||||
struct SourceLoc {
|
struct SourceLoc {
|
||||||
std::string function;
|
std::string function;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
size_t line;
|
unsigned line;
|
||||||
size_t col;
|
unsigned col;
|
||||||
|
|
||||||
SourceLoc(): line(0), col(0) {}
|
SourceLoc(): line(0), col(0) {}
|
||||||
|
|
||||||
@ -527,7 +528,7 @@ public:
|
|||||||
Trace operator[](size_t) { return Trace(); }
|
Trace operator[](size_t) { return Trace(); }
|
||||||
size_t load_here(size_t=0) { return 0; }
|
size_t load_here(size_t=0) { return 0; }
|
||||||
size_t load_from(void*, size_t=0) { return 0; }
|
size_t load_from(void*, size_t=0) { return 0; }
|
||||||
size_t thread_id() const { return 0; }
|
unsigned thread_id() const { return 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef BACKWARD_SYSTEM_LINUX
|
#ifdef BACKWARD_SYSTEM_LINUX
|
||||||
@ -536,7 +537,7 @@ class StackTraceLinuxImplBase {
|
|||||||
public:
|
public:
|
||||||
StackTraceLinuxImplBase(): _thread_id(0), _skip(0) {}
|
StackTraceLinuxImplBase(): _thread_id(0), _skip(0) {}
|
||||||
|
|
||||||
size_t thread_id() const {
|
unsigned thread_id() const {
|
||||||
return _thread_id;
|
return _thread_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1057,7 +1058,7 @@ private:
|
|||||||
bfd_symtab_t dynamic_symtab;
|
bfd_symtab_t dynamic_symtab;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef typename details::hashtable<std::string, bfd_fileobject>::type
|
typedef details::hashtable<std::string, bfd_fileobject>::type
|
||||||
fobj_bfd_map_t;
|
fobj_bfd_map_t;
|
||||||
fobj_bfd_map_t _fobj_bfd_map;
|
fobj_bfd_map_t _fobj_bfd_map;
|
||||||
|
|
||||||
@ -1070,7 +1071,7 @@ private:
|
|||||||
_bfd_loaded = true;
|
_bfd_loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename fobj_bfd_map_t::iterator it =
|
fobj_bfd_map_t::iterator it =
|
||||||
_fobj_bfd_map.find(filename_object);
|
_fobj_bfd_map.find(filename_object);
|
||||||
if (it != _fobj_bfd_map.end()) {
|
if (it != _fobj_bfd_map.end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
@ -1428,16 +1429,23 @@ private:
|
|||||||
struct inliners_search_cb {
|
struct inliners_search_cb {
|
||||||
void operator()(Dwarf_Die* die) {
|
void operator()(Dwarf_Die* die) {
|
||||||
switch (dwarf_tag(die)) {
|
switch (dwarf_tag(die)) {
|
||||||
|
const char* name;
|
||||||
case DW_TAG_subprogram:
|
case DW_TAG_subprogram:
|
||||||
trace.source.function = dwarf_diename(die)?:"";
|
if ((name = dwarf_diename(die))) {
|
||||||
|
trace.source.function = name;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DW_TAG_inlined_subroutine:
|
case DW_TAG_inlined_subroutine:
|
||||||
ResolvedTrace::SourceLoc sloc;
|
ResolvedTrace::SourceLoc sloc;
|
||||||
Dwarf_Attribute attr_mem;
|
Dwarf_Attribute attr_mem;
|
||||||
|
|
||||||
sloc.function = dwarf_diename(die)?:"";
|
if ((name = dwarf_diename(die))) {
|
||||||
sloc.filename = die_call_file(die)?:"";
|
trace.source.function = name;
|
||||||
|
}
|
||||||
|
if ((name = die_call_file(die))) {
|
||||||
|
sloc.filename = name;
|
||||||
|
}
|
||||||
|
|
||||||
Dwarf_Word line = 0, col = 0;
|
Dwarf_Word line = 0, col = 0;
|
||||||
dwarf_formudata(dwarf_attr(die, DW_AT_call_line,
|
dwarf_formudata(dwarf_attr(die, DW_AT_call_line,
|
||||||
@ -1859,14 +1867,14 @@ public:
|
|||||||
|
|
||||||
fprintf(os, "Stack trace (most recent call last)");
|
fprintf(os, "Stack trace (most recent call last)");
|
||||||
if (st.thread_id()) {
|
if (st.thread_id()) {
|
||||||
fprintf(os, " in thread %zi:\n", st.thread_id());
|
fprintf(os, " in thread %u:\n", st.thread_id());
|
||||||
} else {
|
} else {
|
||||||
fprintf(os, ":\n");
|
fprintf(os, ":\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
_resolver.load_stacktrace(st);
|
_resolver.load_stacktrace(st);
|
||||||
for (size_t trace_idx = st.size(); trace_idx > 0; --trace_idx) {
|
for (unsigned trace_idx = st.size(); trace_idx > 0; --trace_idx) {
|
||||||
fprintf(os, "#%-2zi", trace_idx);
|
fprintf(os, "#%-2u", trace_idx);
|
||||||
bool already_indented = true;
|
bool already_indented = true;
|
||||||
const ResolvedTrace trace = _resolver.resolve(st[trace_idx-1]);
|
const ResolvedTrace trace = _resolver.resolve(st[trace_idx-1]);
|
||||||
|
|
||||||
@ -1942,8 +1950,8 @@ private:
|
|||||||
void print_source_loc(FILE* os, const char* indent,
|
void print_source_loc(FILE* os, const char* indent,
|
||||||
const ResolvedTrace::SourceLoc& source_loc,
|
const ResolvedTrace::SourceLoc& source_loc,
|
||||||
void* addr=0) {
|
void* addr=0) {
|
||||||
fprintf(os, "%sSource \"%s\", line %zi, in %s",
|
fprintf(os, "%sSource \"%s\", line %i, in %s",
|
||||||
indent, source_loc.filename.c_str(), source_loc.line,
|
indent, source_loc.filename.c_str(), (int)source_loc.line,
|
||||||
source_loc.function.c_str());
|
source_loc.function.c_str());
|
||||||
|
|
||||||
if (address and addr != 0) {
|
if (address and addr != 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user