Browse Source

* move stab number reset to dbgstabs

git-svn-id: trunk@1442 -
peter 20 years ago
parent
commit
6e60c8a92b
3 changed files with 48 additions and 15 deletions
  1. 29 4
      compiler/dbgstabs.pas
  2. 17 11
      compiler/symdef.pas
  3. 2 0
      compiler/symtype.pas

+ 29 - 4
compiler/dbgstabs.pas

@@ -36,6 +36,7 @@ interface
       private
         writing_def_stabs  : boolean;
         global_stab_number : word;
+        defnumberlist      : tlist;
         { tsym writing }
         function  sym_var_value(const s:string;arg:pointer):string;
         function  sym_stabstr_evaluate(sym:tsym;const s:string;const vars:array of string):Pchar;
@@ -263,6 +264,9 @@ implementation
             if is_class(def) then
               inc(global_stab_number);
             def.stab_number:=global_stab_number;
+            if global_stab_number>=defnumberlist.count then
+              defnumberlist.count:=global_stab_number+250;
+            defnumberlist[global_stab_number]:=def;
           end;
         result:=tostr(def.stab_number);
       end;
@@ -329,7 +333,7 @@ implementation
                                      tostr(tfieldvarsym(p).fieldoffset*8),tostr(varsize*8)]);
             if state^.stabsize+strlen(newrec)>=state^.staballoc-256 then
               begin
-                inc(state^.staballoc,memsizeinc);
+                inc(state^.staballoc,strlen(newrec)+64);
                 reallocmem(state^.stabstring,state^.staballoc);
               end;
             strcopy(state^.stabstring+state^.stabsize,newrec);
@@ -420,7 +424,7 @@ implementation
            inc(state^.stabsize,strlen(newrec));
            if state^.stabsize>=state^.staballoc-256 then
              begin
-                inc(state^.staballoc,memsizeinc);
+                inc(state^.staballoc,strlen(newrec)+64);
                 reallocmem(state^.stabstring,state^.staballoc);
              end;
            strcopy(state^.stabstring+olds,newrec);
@@ -825,7 +829,8 @@ implementation
               insertdef(list,u8inttype.def);
               insertdef(list,cchartype.def);
             end;
-          classrefdef,
+          classrefdef :
+            insertdef(list,pvmttype.def);
           pointerdef :
             insertdef(list,tpointerdef(def).pointertype.def);
           setdef :
@@ -1234,7 +1239,12 @@ implementation
           begin
             case sym.consttyp of
               conststring:
-                st:='s'''+backspace_quote(octal_quote(strpas(pchar(sym.value.valueptr)),[#0..#9,#11,#12,#14..#31,'''']),['"','\',#10,#13])+'''';
+                begin
+                  if sym.value.len<200 then
+                    st:='s'''+backspace_quote(octal_quote(strpas(pchar(sym.value.valueptr)),[#0..#9,#11,#12,#14..#31,'''']),['"','\',#10,#13])+''''
+                  else
+                    st:='<constant string too long>';
+                end;
               constord:
                 st:='i'+tostr(sym.value.valueord);
               constpointer:
@@ -1384,11 +1394,13 @@ implementation
         stabstypelist : taasmoutput;
         storefilepos  : tfileposinfo;
         st : tsymtable;
+        i  : longint;
       begin
         storefilepos:=aktfilepos;
         aktfilepos:=current_module.mainfilepos;
 
         global_stab_number:=0;
+        defnumberlist:=tlist.create;
         stabsvarlist:=taasmoutput.create;
         stabstypelist:=taasmoutput.create;
 
@@ -1424,6 +1436,19 @@ implementation
         asmlist[al_stabs].concatlist(stabstypelist);
         asmlist[al_stabs].concatlist(stabsvarlist);
 
+        { reset stab numbers }
+        for i:=0 to defnumberlist.count-1 do
+          begin
+            if assigned(defnumberlist[i]) then
+              begin
+                tdef(defnumberlist[i]).stab_number:=0;
+                tdef(defnumberlist[i]).stab_state:=stab_state_unused;
+              end;
+          end;
+
+        defnumberlist.free;
+        defnumberlist:=nil;
+
         stabsvarlist.free;
         stabstypelist.free;
         aktfilepos:=storefilepos;

+ 17 - 11
compiler/symdef.pas

@@ -65,7 +65,7 @@ interface
 {$endif}
           constructor create;
           constructor ppuloaddef(ppufile:tcompilerppufile);
-          procedure reset;
+          procedure reset;virtual;
           function getcopy : tstoreddef;virtual;
           procedure ppuwritedef(ppufile:tcompilerppufile);
           procedure ppuwrite(ppufile:tcompilerppufile);virtual;abstract;
@@ -170,6 +170,7 @@ interface
           procedure generate_field_rtti(sym : tnamedindexitem;arg:pointer);
        public
           symtable : tsymtable;
+          procedure reset;override;
           function  getsymtable(t:tgetsymtable):tsymtable;override;
        end;
 
@@ -513,6 +514,7 @@ interface
           procedure buildderefimpl;override;
           procedure deref;override;
           procedure derefimpl;override;
+          procedure reset;override;
           function  getsymtable(t:tgetsymtable):tsymtable;override;
           function gettypename : string;override;
           function  mangledname : string;
@@ -892,8 +894,6 @@ implementation
 {$endif}
          if registerdef then
            symtablestack.registerdef(self);
-         stab_state:=stab_state_unused;
-         stab_number:=0;
          fillchar(localrttilab,sizeof(localrttilab),0);
       end;
 
@@ -904,8 +904,6 @@ implementation
 {$ifdef EXTDEBUG}
          fillchar(fileinfo,sizeof(fileinfo),0);
 {$endif}
-         stab_state:=stab_state_unused;
-         stab_number:=0;
          fillchar(localrttilab,sizeof(localrttilab),0);
       { load }
          indexnr:=ppufile.getword;
@@ -920,18 +918,12 @@ implementation
 
     procedure Tstoreddef.reset;
       begin
-        stab_state:=stab_state_unused;
         if assigned(rttitablesym) then
           trttisym(rttitablesym).lab := nil;
         if assigned(inittablesym) then
           trttisym(inittablesym).lab := nil;
         localrttilab[initrtti]:=nil;
         localrttilab[fullrtti]:=nil;
-        if deftype=procdef then
-          begin
-            tprocdef(self).procstarttai:=nil;
-            tprocdef(self).procendtai:=nil;
-          end;
       end;
 
 
@@ -2644,6 +2636,12 @@ implementation
       end;
 
 
+    procedure tabstractrecorddef.reset;
+      begin
+        tstoredsymtable(symtable).reset_all_defs;
+      end;
+
+
     procedure tabstractrecorddef.count_field_rtti(sym : tnamedindexitem;arg:pointer);
       begin
          if (FRTTIType=fullrtti) or
@@ -3354,6 +3352,14 @@ implementation
       end;
 
 
+    procedure tprocdef.reset;
+      begin
+        inherited reset;
+        procstarttai:=nil;
+        procendtai:=nil;
+      end;
+
+
     procedure tprocdef.insert_localst;
       begin
          localst:=tlocalsymtable.create(parast.symtablelevel);

+ 2 - 0
compiler/symtype.pas

@@ -244,6 +244,8 @@ implementation
          owner := nil;
          typesym := nil;
          defoptions:=[];
+         stab_state:=stab_state_unused;
+         stab_number:=0;
       end;