Browse Source

+ parse the openwatcom dwarf extension DW_LNE_SET_SEGMENT and also track segment
data in the dwarf state machine on i8086

git-svn-id: trunk@39049 -

nickysn 7 years ago
parent
commit
0ca05f042b
1 changed files with 29 additions and 0 deletions
  1. 29 0
      rtl/inc/lnfodwrf.pp

+ 29 - 0
rtl/inc/lnfodwrf.pp

@@ -96,6 +96,11 @@ const
   DW_LNE_END_SEQUENCE = 1;
   DW_LNE_END_SEQUENCE = 1;
   DW_LNE_SET_ADDRESS = 2;
   DW_LNE_SET_ADDRESS = 2;
   DW_LNE_DEFINE_FILE = 3;
   DW_LNE_DEFINE_FILE = 3;
+{$ifdef CPUI8086}
+  { non-standard Open Watcom extension; might conflict with future versions of
+    the DWARF standard }
+  DW_LNE_SET_SEGMENT = 4;
+{$endif CPUI8086}
   { Standard opcodes }
   { Standard opcodes }
   DW_LNS_COPY = 1;
   DW_LNS_COPY = 1;
   DW_LNS_ADVANCE_PC = 2;
   DW_LNS_ADVANCE_PC = 2;
@@ -139,6 +144,9 @@ type
   { state record for the line info state machine }
   { state record for the line info state machine }
   TMachineState = record
   TMachineState = record
     address : QWord;
     address : QWord;
+{$ifdef CPUI8086}
+    segment : Word;
+{$endif CPUI8086}
     file_id : DWord;
     file_id : DWord;
     line : QWord;
     line : QWord;
     column : DWord;
     column : DWord;
@@ -449,6 +457,15 @@ begin
 end;
 end;
 
 
 
 
+{$ifdef CPUI8086}
+{ Reads a segment from the current input stream }
+function ReadSegment() : Word;
+begin
+  ReadNext(ReadSegment, sizeof(ReadSegment));
+end;
+{$endif CPUI8086}
+
+
 { Reads a zero-terminated string from the current input stream. If the
 { Reads a zero-terminated string from the current input stream. If the
   string is larger than 255 chars (maximum allowed number of elements in
   string is larger than 255 chars (maximum allowed number of elements in
   a ShortString, excess characters will be chopped off. }
   a ShortString, excess characters will be chopped off. }
@@ -510,6 +527,9 @@ procedure InitStateRegisters(var state : TMachineState; const aIs_Stmt : Bool8);
 begin
 begin
   with state do begin
   with state do begin
     address := 0;
     address := 0;
+{$ifdef CPUI8086}
+    segment := 0;
+{$endif CPUI8086}
     file_id := 1;
     file_id := 1;
     line := 1;
     line := 1;
     column := 0;
     column := 0;
@@ -721,6 +741,12 @@ begin
             state.address := ReadAddress();
             state.address := ReadAddress();
             DEBUG_WRITELN('DW_LNE_SET_ADDRESS (', hexstr(state.address, sizeof(state.address)*2), ')');
             DEBUG_WRITELN('DW_LNE_SET_ADDRESS (', hexstr(state.address, sizeof(state.address)*2), ')');
           end;
           end;
+{$ifdef CPUI8086}
+          DW_LNE_SET_SEGMENT : begin
+            state.segment := ReadSegment();
+            DEBUG_WRITELN('DW_LNE_SET_SEGMENT (', hexstr(state.segment, sizeof(state.segment)*2), ')');
+          end;
+{$endif CPUI8086}
           DW_LNE_DEFINE_FILE : begin
           DW_LNE_DEFINE_FILE : begin
             {$ifdef DEBUG_DWARF_PARSER}s := {$endif}ReadString();
             {$ifdef DEBUG_DWARF_PARSER}s := {$endif}ReadString();
             SkipLEB128();
             SkipLEB128();
@@ -811,6 +837,9 @@ begin
 
 
     if (state.append_row) then begin
     if (state.append_row) then begin
       DEBUG_WRITELN('Current state : address = ', hexstr(state.address, sizeof(state.address) * 2),
       DEBUG_WRITELN('Current state : address = ', hexstr(state.address, sizeof(state.address) * 2),
+{$ifdef CPUI8086}
+      DEBUG_COMMENT ' segment = ', hexstr(state.segment, sizeof(state.segment) * 2),
+{$endif CPUI8086}
       DEBUG_COMMENT ' file_id = ', state.file_id, ' line = ', state.line, ' column = ', state.column,
       DEBUG_COMMENT ' file_id = ', state.file_id, ' line = ', state.line, ' column = ', state.column,
       DEBUG_COMMENT  ' is_stmt = ', state.is_stmt, ' basic_block = ', state.basic_block,
       DEBUG_COMMENT  ' is_stmt = ', state.is_stmt, ' basic_block = ', state.basic_block,
       DEBUG_COMMENT  ' end_sequence = ', state.end_sequence, ' prolouge_end = ', state.prolouge_end,
       DEBUG_COMMENT  ' end_sequence = ', state.end_sequence, ' prolouge_end = ', state.prolouge_end,