⛏️ index : haiku.git

author David Karoly <karolyd577@gmail.com> 2023-08-30 14:08:24.0 +02:00:00
committer waddlesplash <waddlesplash@gmail.com> 2023-10-07 19:41:07.0 +00:00:00
commit
c1ca5e5feb095e7285c2fc50243d4e28309a3ad0 [patch]
tree
17cae811e24f8636770458a2c465da5edef9c41c
parent
dca65c878fdfacac7c975fac1e90b8a40278f430
download
c1ca5e5feb095e7285c2fc50243d4e28309a3ad0.tar.gz

Debugger: implement parsing for v4 line-info

Differences between DWARF v3/v4 for line-info:
- added new field maxOpsPerInstruction
  this new field will typically have the value of 1
  unless VLIW architecture is being used
  (which is not the case for Haiku)
- state machine contains a new field op_index
  it has any relevance only when maxOpsPerInstruction > 1
  i.e. on VLIW architectures
- added new operation DW_LNE_set_discriminator
  this is already implemented in LineNumberProgram.cpp

This implementation just reads maxOpsPerInstruction and
checks that it is set to 1, which is what we expect on
all architectures currently supported by Haiku.

Change-Id: I14755d615a0e2b3a5177928c4d8f9014940a5fcf
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6876
Reviewed-by: Rene Gollent <rene@gollent.com>
(cherry picked from commit 3f2464f759bbb21f49e8abf5bad429ba7d344952)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7017
Reviewed-by: waddlesplash <waddlesplash@gmail.com>

Diff

 src/kits/debugger/dwarf/DwarfFile.cpp | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/kits/debugger/dwarf/DwarfFile.cpp b/src/kits/debugger/dwarf/DwarfFile.cpp
index 5ccac82..f07dafa 100644
--- a/src/kits/debugger/dwarf/DwarfFile.cpp
+++ b/src/kits/debugger/dwarf/DwarfFile.cpp
@@ -1779,7 +1779,7 @@
	// version (uhalf)
	uint16 version = dataReader.Read<uint16>(0);

	if (version != 2 && version != 3) {
	if (version < 2 || version > 4) {
		WARNING("DwarfFile::_ParseLineInfo(\"%s\"): unsupported "
			"version %d\n", fName, version);
		return B_UNSUPPORTED;
@@ -1796,6 +1796,18 @@
	// minimum instruction length
	uint8 minInstructionLength = dataReader.Read<uint8>(0);

	uint8 maxOpsPerInstruction;
	if (version >= 4)
		maxOpsPerInstruction = dataReader.Read<uint8>(0);
	else
		maxOpsPerInstruction = 1;

	if (maxOpsPerInstruction != 1) {
		WARNING("DwarfFile::_ParseLineInfo(\"%s\"): unsupported "
			"maxOpsPerInstruction %u\n", fName, maxOpsPerInstruction);
		return B_UNSUPPORTED;
	}

	// default is statement
	bool defaultIsStatement = dataReader.Read<uint8>(0) != 0;

@@ -1819,6 +1831,8 @@
	TRACE_LINES("  version:              %u\n", version);
	TRACE_LINES("  headerLength:         %" B_PRIu64 "\n", headerLength);
	TRACE_LINES("  minInstructionLength: %u\n", minInstructionLength);
	if (version >= 4)
		TRACE_LINES("  maxOpsPerInstruction: %u\n", maxOpsPerInstruction);
	TRACE_LINES("  defaultIsStatement:   %d\n", defaultIsStatement);
	TRACE_LINES("  lineBase:             %d\n", lineBase);
	TRACE_LINES("  lineRange:            %u\n", lineRange);