1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:17:35 +00:00

LibDebug/Dwarf: Use dbgln_if() instead of '#if DWARF_DEBUG'

This commit is contained in:
AnotherTest 2021-04-12 22:38:36 +04:30 committed by Andreas Kling
parent 03d705d531
commit 6606d70826

View file

@ -48,9 +48,7 @@ void LineProgram::parse_unit_header()
VERIFY(m_unit_header.version == DWARF_VERSION); VERIFY(m_unit_header.version == DWARF_VERSION);
VERIFY(m_unit_header.opcode_base == SPECIAL_OPCODES_BASE); VERIFY(m_unit_header.opcode_base == SPECIAL_OPCODES_BASE);
#if DWARF_DEBUG dbgln_if(DWARF_DEBUG, "unit length: {}", m_unit_header.length);
dbgln("unit length: {}", m_unit_header.length);
#endif
} }
void LineProgram::parse_source_directories() void LineProgram::parse_source_directories()
@ -60,9 +58,7 @@ void LineProgram::parse_source_directories()
while (m_stream.peek_or_error()) { while (m_stream.peek_or_error()) {
String directory; String directory;
m_stream >> directory; m_stream >> directory;
#if DWARF_DEBUG dbgln_if(DWARF_DEBUG, "directory: {}", directory);
dbgln("directory: {}", directory);
#endif
m_source_directories.append(move(directory)); m_source_directories.append(move(directory));
} }
m_stream.handle_recoverable_error(); m_stream.handle_recoverable_error();
@ -81,9 +77,7 @@ void LineProgram::parse_source_files()
size_t _unused = 0; size_t _unused = 0;
m_stream.read_LEB128_unsigned(_unused); // skip modification time m_stream.read_LEB128_unsigned(_unused); // skip modification time
m_stream.read_LEB128_unsigned(_unused); // skip file size m_stream.read_LEB128_unsigned(_unused); // skip file size
#if DWARF_DEBUG dbgln_if(DWARF_DEBUG, "file: {}, directory index: {}", file_name, directory_index);
dbgln("file: {}, directory index: {}", file_name, directory_index);
#endif
m_source_files.append({ file_name, directory_index }); m_source_files.append({ file_name, directory_index });
} }
m_stream.discard_or_error(1); m_stream.discard_or_error(1);
@ -92,9 +86,7 @@ void LineProgram::parse_source_files()
void LineProgram::append_to_line_info() void LineProgram::append_to_line_info()
{ {
#if DWARF_DEBUG dbgln_if(DWARF_DEBUG, "appending line info: {:p}, {}:{}", m_address, m_source_files[m_file_index].name, m_line);
dbgln("appending line info: {:p}, {}:{}", m_address, m_source_files[m_file_index].name, m_line);
#endif
if (!m_is_statement) if (!m_is_statement)
return; return;
@ -136,22 +128,16 @@ void LineProgram::handle_extended_opcode()
case ExtendedOpcodes::SetAddress: { case ExtendedOpcodes::SetAddress: {
VERIFY(length == sizeof(size_t) + 1); VERIFY(length == sizeof(size_t) + 1);
m_stream >> m_address; m_stream >> m_address;
#if DWARF_DEBUG dbgln_if(DWARF_DEBUG, "SetAddress: {:p}", m_address);
dbgln("SetAddress: {:p}", m_address);
#endif
break; break;
} }
case ExtendedOpcodes::SetDiscriminator: { case ExtendedOpcodes::SetDiscriminator: {
#if DWARF_DEBUG dbgln_if(DWARF_DEBUG, "SetDiscriminator");
dbgln("SetDiscriminator");
#endif
m_stream.discard_or_error(1); m_stream.discard_or_error(1);
break; break;
} }
default: default:
#if DWARF_DEBUG dbgln_if(DWARF_DEBUG, "offset: {:p}", m_stream.offset());
dbgln("offset: {:p}", m_stream.offset());
#endif
VERIFY_NOT_REACHED(); VERIFY_NOT_REACHED();
} }
} }
@ -166,26 +152,20 @@ void LineProgram::handle_standard_opcode(u8 opcode)
size_t operand = 0; size_t operand = 0;
m_stream.read_LEB128_unsigned(operand); m_stream.read_LEB128_unsigned(operand);
size_t delta = operand * m_unit_header.min_instruction_length; size_t delta = operand * m_unit_header.min_instruction_length;
#if DWARF_DEBUG dbgln_if(DWARF_DEBUG, "AdvancePC by: {} to: {:p}", delta, m_address + delta);
dbgln("AdvancePC by: {} to: {:p}", delta, m_address + delta);
#endif
m_address += delta; m_address += delta;
break; break;
} }
case StandardOpcodes::SetFile: { case StandardOpcodes::SetFile: {
size_t new_file_index = 0; size_t new_file_index = 0;
m_stream.read_LEB128_unsigned(new_file_index); m_stream.read_LEB128_unsigned(new_file_index);
#if DWARF_DEBUG dbgln_if(DWARF_DEBUG, "SetFile: new file index: {}", new_file_index);
dbgln("SetFile: new file index: {}", new_file_index);
#endif
m_file_index = new_file_index; m_file_index = new_file_index;
break; break;
} }
case StandardOpcodes::SetColumn: { case StandardOpcodes::SetColumn: {
// not implemented // not implemented
#if DWARF_DEBUG dbgln_if(DWARF_DEBUG, "SetColumn");
dbgln("SetColumn");
#endif
size_t new_column; size_t new_column;
m_stream.read_LEB128_unsigned(new_column); m_stream.read_LEB128_unsigned(new_column);
@ -196,15 +176,11 @@ void LineProgram::handle_standard_opcode(u8 opcode)
m_stream.read_LEB128_signed(line_delta); m_stream.read_LEB128_signed(line_delta);
VERIFY(line_delta >= 0 || m_line >= (size_t)(-line_delta)); VERIFY(line_delta >= 0 || m_line >= (size_t)(-line_delta));
m_line += line_delta; m_line += line_delta;
#if DWARF_DEBUG dbgln_if(DWARF_DEBUG, "AdvanceLine: {}", m_line);
dbgln("AdvanceLine: {}", m_line);
#endif
break; break;
} }
case StandardOpcodes::NegateStatement: { case StandardOpcodes::NegateStatement: {
#if DWARF_DEBUG dbgln_if(DWARF_DEBUG, "NegateStatement");
dbgln("NegateStatement");
#endif
m_is_statement = !m_is_statement; m_is_statement = !m_is_statement;
break; break;
} }
@ -212,24 +188,20 @@ void LineProgram::handle_standard_opcode(u8 opcode)
u8 adjusted_opcode = 255 - SPECIAL_OPCODES_BASE; u8 adjusted_opcode = 255 - SPECIAL_OPCODES_BASE;
ssize_t address_increment = (adjusted_opcode / m_unit_header.line_range) * m_unit_header.min_instruction_length; ssize_t address_increment = (adjusted_opcode / m_unit_header.line_range) * m_unit_header.min_instruction_length;
address_increment *= m_unit_header.min_instruction_length; address_increment *= m_unit_header.min_instruction_length;
#if DWARF_DEBUG dbgln_if(DWARF_DEBUG, "ConstAddPc: advance pc by: {} to: {}", address_increment, (m_address + address_increment));
dbgln("ConstAddPc: advance pc by: {} to: {}", address_increment, (m_address + address_increment));
#endif
m_address += address_increment; m_address += address_increment;
break; break;
} }
case StandardOpcodes::SetIsa: { case StandardOpcodes::SetIsa: {
size_t isa; size_t isa;
m_stream.read_LEB128_unsigned(isa); m_stream.read_LEB128_unsigned(isa);
dbgln("SetIsa: {}", isa); dbgln_if(DWARF_DEBUG, "SetIsa: {}", isa);
break; break;
} }
case StandardOpcodes::FixAdvancePc: { case StandardOpcodes::FixAdvancePc: {
u16 delta = 0; u16 delta = 0;
m_stream >> delta; m_stream >> delta;
#if DWARF_DEBUG dbgln_if(DWARF_DEBUG, "FixAdvancePC by: {} to: {:p}", delta, m_address + delta);
dbgln("FixAdvancePC by: {} to: {:p}", delta, m_address + delta);
#endif
m_address += delta; m_address += delta;
break; break;
} }