浏览代码

* Encode properties in Dwarf-debug information, in a format specific for FPC (A dwarf-extension)

Joost van der Sluis 3 年之前
父节点
当前提交
6623ccd624
共有 6 个文件被更改,包括 448 次插入117 次删除
  1. 411 113
      compiler/dbgdwarf.pas
  2. 10 1
      compiler/dbgdwarfconst.pas
  3. 9 2
      compiler/globtype.pas
  4. 5 1
      compiler/symdef.pas
  5. 9 0
      compiler/symsym.pas
  6. 4 0
      compiler/utils/ppuutils/ppudump.pp

文件差异内容过多而无法显示
+ 411 - 113
compiler/dbgdwarf.pas


+ 10 - 1
compiler/dbgdwarfconst.pas

@@ -81,6 +81,10 @@ type
     DW_TAG_function_template := $4102,DW_TAG_class_template := $4103,
 
     DW_TAG_GNU_BINCL := $4104,DW_TAG_GNU_EINCL := $4105,
+
+    { FPC specific extensions }
+    DW_TAG_FPC_property := $4230,
+
     { Extensions for UPC.  See: http://upc.gwu.edu/~upc.   }
     DW_TAG_upc_shared_type := $8765,DW_TAG_upc_strict_type := $8766,
     DW_TAG_upc_relaxed_type := $8767,
@@ -214,7 +218,12 @@ type
     DW_AT_APPLE_optimized := $3fe1,
     DW_AT_APPLE_flags := $3fe2,
     DW_AT_APPLE_major_runtime_vers := $3fe5,
-    DW_AT_APPLE_runtime_class := $3fe6
+    DW_AT_APPLE_runtime_class := $3fe6,
+
+    { FPC specific extensions }
+    DW_AT_FPC_property_read := $3230,
+    DW_AT_FPC_property_write := $3231,
+    DW_AT_FPC_property_stored := $3232
   );
 {$pop}
 

+ 9 - 2
compiler/globtype.pas

@@ -269,7 +269,14 @@ interface
           { though, they support and use dwarf debug information in the }
           { final executable file, they expect LINNUM records in the    }
           { object modules for the line number information.             }
-          ds_dwarf_omf_linnum
+          ds_dwarf_omf_linnum,
+          { use a self-defined dwarf-extension to add Pascal-property   }
+          { information. With this parameter set the properties are     }
+          { encoded in this format. The limited default property-debug  }
+          { information is not generated.                               }
+          { the dwarf-information of this extension should be ignored   }
+          { by debuggers that do not support it                         }
+          ds_dwarf_properties
        );
        tdebugswitches = set of tdebugswitch;
 
@@ -446,7 +453,7 @@ interface
        );
 
        DebugSwitchStr : array[tdebugswitch] of string[22] = ('',
-         'DWARFSETS','STABSABSINCLUDES','DWARFMETHODCLASSPREFIX','DWARFCPP','DWARFOMFLINNUM');
+         'DWARFSETS','STABSABSINCLUDES','DWARFMETHODCLASSPREFIX','DWARFCPP','DWARFOMFLINNUM', 'DWARFPROPERTIES');
 
        TargetSwitchStr : array[ttargetswitch] of ttargetswitchinfo = (
          (name: '';                    hasvalue: false; isglobal: true ; define: ''),

+ 5 - 1
compiler/symdef.pas

@@ -885,6 +885,7 @@ interface
             a routine that has to be internally generated by the compiler }
           synthetickind: tsynthetickind;
           visibility   : tvisibility;
+          dwarfoffset  : asizeint;
 {$ifndef DISABLE_FAST_OVERLOAD_PATCH}
           seenmarker : pointer; // used for filtering in tcandidate
 {$endif}
@@ -6443,6 +6444,7 @@ implementation
          inlininginfo:=nil;
          deprecatedmsg:=nil;
          genericdecltokenbuf:=nil;
+         dwarfoffset:=-1;
          if cs_opt_fastmath in current_settings.optimizerswitches then
            include(implprocoptions, pio_fastmath);
       end;
@@ -6506,6 +6508,7 @@ implementation
              inlininginfo:=nil;
              funcretsym:=nil;
            end;
+         dwarfoffset:=ppufile.getasizeint;
 
          aliasnames:=TCmdStrList.create;
          { count alias names }
@@ -6678,7 +6681,7 @@ implementation
              ppufile.putderef(funcretsymderef);
              ppufile.putset(tppuset4(inlininginfo^.flags));
            end;
-
+         ppufile.putasizeint(dwarfoffset);
          { count alias names }
          aliasnamescount:=0;
          item:=TCmdStrListItem(aliasnames.first);
@@ -7048,6 +7051,7 @@ implementation
         tprocdef(result).import_nr:=import_nr;
         tprocdef(result).extnumber:=$ffff;
         tprocdef(result).visibility:=visibility;
+        tprocdef(result).dwarfoffset:=dwarfoffset;
         { we need a separate implementation for the copied def }
         tprocdef(result).forwarddef:=true;
         tprocdef(result).interfacedef:=true;

+ 9 - 0
compiler/symsym.pas

@@ -225,6 +225,7 @@ interface
           { offset in record/object, for bitpacked fields the offset is
             given in bit, else in bytes }
           fieldoffset   : asizeint;
+          dwarfoffset   : asizeint;
 {$ifdef llvm}
           { the llvm version of the record does not support variants,   }
           { so the llvm equivalent field may not be at the exact same   }
@@ -2011,6 +2012,7 @@ implementation
       begin
          inherited create(fieldvarsym,n,vsp,def,vopts);
          fieldoffset:=-1;
+         dwarfoffset:=-1;
       end;
 
 
@@ -2018,6 +2020,8 @@ implementation
       begin
          inherited ppuload(fieldvarsym,ppufile);
          fieldoffset:=ppufile.getasizeint;
+         if visibility<>vis_hidden then
+           dwarfoffset:=ppufile.getasizeint;
          if (vo_has_mangledname in varoptions) then
            externalname:=ppufile.getpshortstring
          else
@@ -2030,6 +2034,11 @@ implementation
       begin
          inherited ppuwrite(ppufile);
          ppufile.putasizeint(fieldoffset);
+         if visibility<>vis_hidden then
+           { no reason to store an offset of -1 for all hidden fields }
+           ppufile.putasizeint(dwarfoffset)
+         else if dwarfoffset>-1 then
+           Internalerror(2022030601);
          if (vo_has_mangledname in varoptions) then
            ppufile.putstring(externalname^);
          writeentry(ppufile,ibfieldvarsym);

+ 4 - 0
compiler/utils/ppuutils/ppudump.pp

@@ -1762,6 +1762,7 @@ begin
       vis_public: Def.Visibility:=dvPublic;
       vis_published: Def.Visibility:=dvPublished;
       vis_protected, vis_strictprotected: Def.Visibility:=dvProtected;
+      vis_hidden: Def.Visibility:=dvHidden;
       else Def.Visibility:=dvPrivate;
     end;
   writeln(Visibility2Str(i));
@@ -3861,6 +3862,8 @@ begin
              def:=TPpuFieldDef.Create(ParentDef);
              readabstractvarsym('Field Variable symbol ',varoptions,TPpuVarDef(def));
              writeln([space,'      Address : ',getasizeint]);
+             if Def.Visibility<>dvHidden then
+               writeln([space,' Dwarf Offset : ',getasizeint]);
              if vo_has_mangledname in varoptions then
                writeln([space,' Mangled name : ',getstring]);
            end;
@@ -4332,6 +4335,7 @@ begin
                 readderef('');
                 readprocinfooptions(space);
               end;
+             writeln([space,'     Dwarf offset : ',ppufile.getasizeint]);
              b:=ppufile.getbyte;
              if b<>0 then
                begin

部分文件因为文件数量过多而无法显示