Re-enable warnings

This commit is contained in:
Jeremy 2023-11-08 23:59:48 -05:00
parent 4c1c42c61d
commit 259d596f76
No known key found for this signature in database
GPG Key ID: BE03111EB7ED6E2E
3 changed files with 18 additions and 10 deletions

View File

@ -208,6 +208,14 @@ target_include_directories(
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/cpptrace/> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/cpptrace/>
) )
target_compile_options(
${target_name}
PRIVATE
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Werror=return-type -Wundef>
$<$<CXX_COMPILER_ID:GNU>:-Wuseless-cast>
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX /permissive->
)
# ---- Generate Build Info Headers ---- # ---- Generate Build Info Headers ----
# used in export header generated below # used in export header generated below

View File

@ -26,6 +26,7 @@ namespace libdwarf {
[[noreturn]] void handle_dwarf_error(Dwarf_Debug dbg, Dwarf_Error error) { [[noreturn]] void handle_dwarf_error(Dwarf_Debug dbg, Dwarf_Error error) {
Dwarf_Unsigned ev = dwarf_errno(error); Dwarf_Unsigned ev = dwarf_errno(error);
char* msg = dwarf_errmsg(error); char* msg = dwarf_errmsg(error);
(void)dbg;
// dwarf_dealloc_error(dbg, error); // dwarf_dealloc_error(dbg, error);
throw std::runtime_error(stringf("Cpptrace dwarf error %u %s\n", ev, msg)); throw std::runtime_error(stringf("Cpptrace dwarf error %u %s\n", ev, msg));
} }

View File

@ -71,6 +71,7 @@ namespace libdwarf {
Dwarf_Line line; Dwarf_Line line;
optional<std::string> path; optional<std::string> path;
optional<unsigned> line_number; optional<unsigned> line_number;
line_entry(Dwarf_Addr low, Dwarf_Line line) : low(low), line(line) {}
}; };
struct line_table_info { struct line_table_info {
@ -282,7 +283,6 @@ namespace libdwarf {
std::string subprogram_symbol( std::string subprogram_symbol(
const die_object& die, const die_object& die,
Dwarf_Addr pc,
Dwarf_Half dwversion Dwarf_Half dwversion
) { ) {
ASSERT(die.get_tag() == DW_TAG_subprogram || die.get_tag() == DW_TAG_inlined_subroutine); ASSERT(die.get_tag() == DW_TAG_subprogram || die.get_tag() == DW_TAG_inlined_subroutine);
@ -299,10 +299,10 @@ namespace libdwarf {
} else { } else {
if(die.has_attr(DW_AT_specification)) { if(die.has_attr(DW_AT_specification)) {
die_object spec = die.resolve_reference_attribute(DW_AT_specification); die_object spec = die.resolve_reference_attribute(DW_AT_specification);
return subprogram_symbol(spec, 0, dwversion); return subprogram_symbol(spec, dwversion);
} else if(die.has_attr(DW_AT_abstract_origin)) { } else if(die.has_attr(DW_AT_abstract_origin)) {
die_object spec = die.resolve_reference_attribute(DW_AT_abstract_origin); die_object spec = die.resolve_reference_attribute(DW_AT_abstract_origin);
return subprogram_symbol(spec, 0, dwversion); return subprogram_symbol(spec, dwversion);
} }
} }
return ""; return "";
@ -314,7 +314,7 @@ namespace libdwarf {
char** dw_srcfiles; char** dw_srcfiles;
Dwarf_Signed dw_filecount; Dwarf_Signed dw_filecount;
VERIFY(wrap(dwarf_srcfiles, cu_die.get(), &dw_srcfiles, &dw_filecount) == DW_DLV_OK); VERIFY(wrap(dwarf_srcfiles, cu_die.get(), &dw_srcfiles, &dw_filecount) == DW_DLV_OK);
if(file_i < dw_filecount) { if(Dwarf_Signed(file_i) < dw_filecount) {
filename = dw_srcfiles[file_i - 1]; filename = dw_srcfiles[file_i - 1];
} }
dwarf_dealloc(cu_die.dbg, dw_srcfiles, DW_DLA_LIST); dwarf_dealloc(cu_die.dbg, dw_srcfiles, DW_DLA_LIST);
@ -329,7 +329,7 @@ namespace libdwarf {
} }
char** dw_srcfiles = it->second.first; char** dw_srcfiles = it->second.first;
Dwarf_Signed dw_filecount = it->second.second; Dwarf_Signed dw_filecount = it->second.second;
if(file_i < dw_filecount) { if(Dwarf_Signed(file_i) < dw_filecount) {
filename = dw_srcfiles[file_i - 1]; filename = dw_srcfiles[file_i - 1];
} }
} }
@ -346,11 +346,11 @@ namespace libdwarf {
ASSERT(die.get_tag() == DW_TAG_subprogram || die.get_tag() == DW_TAG_inlined_subroutine); ASSERT(die.get_tag() == DW_TAG_subprogram || die.get_tag() == DW_TAG_inlined_subroutine);
auto child = die.get_child(); auto child = die.get_child();
if(child) { if(child) {
if(pc) walk_die_list( walk_die_list(
child, child,
[this, &cu_die, pc, dwversion, &inlines] (const die_object& die) { [this, &cu_die, pc, dwversion, &inlines] (const die_object& die) {
if(die.get_tag() == DW_TAG_inlined_subroutine && die.pc_in_die(dwversion, pc)) { if(die.get_tag() == DW_TAG_inlined_subroutine && die.pc_in_die(dwversion, pc)) {
const auto name = subprogram_symbol(die, pc, dwversion); const auto name = subprogram_symbol(die, dwversion);
const auto file_i = die.get_unsigned_attribute(DW_AT_call_file); const auto file_i = die.get_unsigned_attribute(DW_AT_call_file);
std::string file = file_i ? resolve_filename(cu_die, file_i.unwrap()) : ""; std::string file = file_i ? resolve_filename(cu_die, file_i.unwrap()) : "";
const auto line = die.get_unsigned_attribute(DW_AT_call_line); const auto line = die.get_unsigned_attribute(DW_AT_call_line);
@ -379,7 +379,7 @@ namespace libdwarf {
std::vector<stacktrace_frame>& inlines std::vector<stacktrace_frame>& inlines
) { ) {
ASSERT(die.get_tag() == DW_TAG_subprogram); ASSERT(die.get_tag() == DW_TAG_subprogram);
const auto name = subprogram_symbol(die, pc, dwversion); const auto name = subprogram_symbol(die, dwversion);
get_inlines_info(cu_die, die, pc, dwversion, inlines); get_inlines_info(cu_die, die, pc, dwversion, inlines);
return name; return name;
} }
@ -588,7 +588,6 @@ namespace libdwarf {
) == DW_DLV_OK ) == DW_DLV_OK
); );
Dwarf_Addr last_pc = 0;
// TODO: Make any attempt to note PC ranges? Handle line end sequence? // TODO: Make any attempt to note PC ranges? Handle line end sequence?
for(int i = 0; i < line_count; i++) { for(int i = 0; i < line_count; i++) {
Dwarf_Line line = line_buffer[i]; Dwarf_Line line = line_buffer[i];
@ -624,7 +623,7 @@ namespace libdwarf {
// } // }
line_entries.push_back({ line_entries.push_back({
low_addr, low_addr,
line // j - 1 line
}); });
i = j - 1; i = j - 1;
} }