pierre пре 25 година
родитељ
комит
f1bd579bf4
6 измењених фајлова са 123 додато и 81 уклоњено
  1. 17 20
      compiler/pmodules.pas
  2. 10 1
      compiler/symconst.pas
  3. 54 46
      compiler/symdef.inc
  4. 6 3
      compiler/symdefh.inc
  5. 28 6
      compiler/symsym.inc
  6. 8 5
      compiler/symtable.pas

+ 17 - 20
compiler/pmodules.pas

@@ -845,27 +845,22 @@ unit pmodules;
                 end;
               hp:=pused_unit(hp^.next);
            end;
-         if current_module^.in_implementation then
+         if current_module^.in_implementation and
+            assigned(current_module^.localsymtable) then
            begin
-              if assigned(current_module^.localsymtable) then
-                begin
-                   { all types }
-                   punitsymtable(current_module^.localsymtable)^.concattypestabto(debuglist);
-                   { and all local symbols}
-                   punitsymtable(current_module^.localsymtable)^.concatstabto(debuglist);
-                end;
+              { all types }
+              punitsymtable(current_module^.localsymtable)^.concattypestabto(debuglist);
+              { and all local symbols}
+              punitsymtable(current_module^.localsymtable)^.concatstabto(debuglist);
            end
-         else
+         else if assigned(current_module^.globalsymtable) then
            begin
-              if assigned(current_module^.globalsymtable) then
-                begin
-                   { all types }
-                   punitsymtable(current_module^.globalsymtable)^.concattypestabto(debuglist);
-                   { and all local symbols}
-                   punitsymtable(current_module^.globalsymtable)^.concatstabto(debuglist);
-                end;
+              { all types }
+              punitsymtable(current_module^.globalsymtable)^.concattypestabto(debuglist);
+              { and all local symbols}
+              punitsymtable(current_module^.globalsymtable)^.concatstabto(debuglist);
            end;
-        end;
+       end;
 {$Else GDB}
        begin
        end;
@@ -1707,10 +1702,12 @@ unit pmodules;
 end.
 {
   $Log$
-  Revision 1.3  2000-07-13 12:08:26  michael
+  Revision 1.4  2000-08-21 11:27:44  pierre
+   * fix the stabs problems
+
+  Revision 1.3  2000/07/13 12:08:26  michael
   + patched to 1.1.0 with former 1.09patch from peter
 
   Revision 1.2  2000/07/13 11:32:45  michael
   + removed logs
-
-}
+}

+ 10 - 1
compiler/symconst.pas

@@ -252,6 +252,12 @@ type
     constresourcestring
   );
 
+{$ifdef GDB}
+  tdefstabstatus = (
+    not_written,
+    being_written,
+    written);
+{$endif GDB}
 
 const
   { relevant options for assigning a proc or a procvar to a procvar }
@@ -277,7 +283,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.5  2000-08-06 19:39:28  peter
+  Revision 1.6  2000-08-21 11:27:44  pierre
+   * fix the stabs problems
+
+  Revision 1.5  2000/08/06 19:39:28  peter
     * default parameters working !
 
   Revision 1.4  2000/08/05 13:25:06  peter

+ 54 - 46
compiler/symdef.inc

@@ -49,7 +49,7 @@
          has_rtti:=false;
          has_inittable:=false;
 {$ifdef GDB}
-         is_def_stab_written := false;
+         is_def_stab_written := not_written;
          globalnb := 0;
 {$endif GDB}
          if assigned(lastglobaldef) then
@@ -79,7 +79,7 @@
          has_rtti:=false;
          has_inittable:=false;
 {$ifdef GDB}
-         is_def_stab_written := false;
+         is_def_stab_written := not_written;
          globalnb := 0;
 {$endif GDB}
          if assigned(lastglobaldef) then
@@ -253,7 +253,7 @@
            {set even if debuglist is not defined}
            if assigned(typesym) then
              typesym^.isusedinstab := true;
-           if assigned(debuglist) and not is_def_stab_written then
+           if assigned(debuglist) and (is_def_stab_written = not_written) then
              concatstabto(debuglist);
         end;
       if not (cs_gdb_dbx in aktglobalswitches) then
@@ -321,7 +321,7 @@
      var stab_str : pchar;
     begin
     if ((typesym = nil) or typesym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
-      and not is_def_stab_written then
+      and (is_def_stab_written = not_written) then
       begin
       If cs_gdb_dbx in aktglobalswitches then
         begin
@@ -335,15 +335,16 @@
                  punitsymtable(typesym^.owner)^.dbx_count_ok)  then
                 begin
                    {with DBX we get the definition from the other objects }
-                   is_def_stab_written := true;
+                   is_def_stab_written := written;
                    exit;
                 end;
              end;
         end;
       { to avoid infinite loops }
-      is_def_stab_written := true;
+      is_def_stab_written := being_written;
       stab_str := allstabstring;
       asmlist^.concat(new(pai_stabs,init(stab_str)));
+      is_def_stab_written := written;
       end;
     end;
 {$endif GDB}
@@ -1390,7 +1391,7 @@
       begin
       { most file defs are unnamed !!! }
       if ((typesym = nil) or typesym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
-         not is_def_stab_written then
+         (is_def_stab_written  = not_written) then
         begin
         if assigned(typedfiletype.def) then forcestabto(asmlist,typedfiletype.def);
         inherited concatstabto(asmlist);
@@ -1510,43 +1511,47 @@
         exit;
 
       if ( (typesym=nil) or typesym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
-         not is_def_stab_written then
+         (is_def_stab_written = not_written) then
         begin
-        if assigned(pointertype.def) then
-          if pointertype.def^.deftype in [recorddef,objectdef] then
-            begin
-            is_def_stab_written := true;
+          is_def_stab_written := being_written;
+        if assigned(pointertype.def) and
+           (pointertype.def^.deftype in [recorddef,objectdef]) then
+          begin
             nb:=pointertype.def^.numberstring;
             {to avoid infinite recursion in record with next-like fields }
-            is_def_stab_written := false;
-            if not pointertype.def^.is_def_stab_written then
+            if pointertype.def^.is_def_stab_written = being_written then
               begin
-              if assigned(pointertype.def^.typesym) then
-                begin
-                if assigned(typesym) then
-                  begin
-                     st := typesym^.name;
-                     sym_line_no:=typesym^.fileinfo.line;
-                  end
-                else
+                if assigned(pointertype.def^.typesym) then
                   begin
-                     st := ' ';
-                     sym_line_no:=0;
-                  end;
-                st := '"'+st+':t'+numberstring+'=*'+nb
-                      +'=xs'+pointertype.def^.typesym^.name+':",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0';
-                asmlist^.concat(new(pai_stabs,init(strpnew(st))));
-                end;
-              end else inherited concatstabto(asmlist);
-            is_def_stab_written := true;
-            end else
-            begin
-            { p =^p1; p1=^p problem }
-            is_def_stab_written := true;
-            forcestabto(asmlist,pointertype.def);
-            is_def_stab_written := false;
+                    if assigned(typesym) then
+                      begin
+                         st := typesym^.name;
+                         sym_line_no:=typesym^.fileinfo.line;
+                      end
+                    else
+                      begin
+                         st := ' ';
+                         sym_line_no:=0;
+                      end;
+                    st := '"'+st+':t'+numberstring+'=*'+nb
+                          +'=xs'+pointertype.def^.typesym^.name+':",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0';
+                    asmlist^.concat(new(pai_stabs,init(strpnew(st))));
+                    end;
+              end
+            else
+              begin
+                is_def_stab_written := not_written;
+                inherited concatstabto(asmlist);
+              end;
+            is_def_stab_written := written;
+          end
+        else
+          begin
+            if assigned(pointertype.def) then
+              forcestabto(asmlist,pointertype.def);
+            is_def_stab_written := not_written;
             inherited concatstabto(asmlist);
-            end;
+          end;
         end;
       end;
 {$endif GDB}
@@ -1707,7 +1712,7 @@
     procedure tsetdef.concatstabto(asmlist : paasmoutput);
       begin
       if ( not assigned(typesym) or typesym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
-          not is_def_stab_written then
+          (is_def_stab_written = not_written) then
         begin
           if assigned(elementtype.def) then
             forcestabto(asmlist,elementtype.def);
@@ -1913,7 +1918,7 @@
     procedure tarraydef.concatstabto(asmlist : paasmoutput);
       begin
       if (not assigned(typesym) or typesym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
-        and not is_def_stab_written then
+        and (is_def_stab_written = not_written) then
         begin
         {when array are inserted they have no definition yet !!}
         if assigned(elementtype.def) then
@@ -2220,7 +2225,7 @@
     procedure trecorddef.concatstabto(asmlist : paasmoutput);
       begin
         if (not assigned(typesym) or typesym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches)) and
-           (not is_def_stab_written) then
+           (is_def_stab_written = not_written)  then
           inherited concatstabto(asmlist);
       end;
 
@@ -2586,7 +2591,7 @@
     procedure tabstractprocdef.concatstabto(asmlist : paasmoutput);
       begin
          if (not assigned(typesym) or typesym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
-            and not is_def_stab_written then
+            and (is_def_stab_written = not_written)  then
            begin
               if assigned(rettype.def) then forcestabto(asmlist,rettype.def);
               inherited concatstabto(asmlist);
@@ -3274,9 +3279,9 @@ Const local_symtable_index : longint = $8001;
     procedure tprocvardef.concatstabto(asmlist : paasmoutput);
       begin
          if ( not assigned(typesym) or typesym^.isusedinstab or (cs_gdb_dbx in aktglobalswitches))
-           and not is_def_stab_written then
+           and (is_def_stab_written = not_written)  then
            inherited concatstabto(asmlist);
-         is_def_stab_written:=true;
+         is_def_stab_written:=written;
       end;
 {$endif GDB}
 
@@ -3745,7 +3750,7 @@ Const local_symtable_index : longint = $8001;
                      end;
                    para := pparaitem(para^.next);
                    end;
-                ipd^.is_def_stab_written := true;
+                ipd^.is_def_stab_written := written;
                 { here 2A must be changed for private and protected }
                 { 0 is private 1 protected and 2 public }
                 if (sp_private in psym(p)^.symoptions) then sp:='0'
@@ -4252,7 +4257,10 @@ Const local_symtable_index : longint = $8001;
 
 {
   $Log$
-  Revision 1.11  2000-08-16 18:33:54  peter
+  Revision 1.12  2000-08-21 11:27:44  pierre
+   * fix the stabs problems
+
+  Revision 1.11  2000/08/16 18:33:54  peter
     * splitted namedobjectitem.next into indexnext and listnext so it
       can be used in both lists
     * don't allow "word = word" type definitions (merged)

+ 6 - 3
compiler/symdefh.inc

@@ -40,7 +40,7 @@
           previousglobal : pdef;
 {$ifdef GDB}
           globalnb       : word;
-          is_def_stab_written : boolean;
+          is_def_stab_written : tdefstabstatus;
 {$endif GDB}
           constructor init;
           constructor load;
@@ -548,7 +548,10 @@
 
 {
   $Log$
-  Revision 1.7  2000-08-06 19:39:28  peter
+  Revision 1.8  2000-08-21 11:27:44  pierre
+   * fix the stabs problems
+
+  Revision 1.7  2000/08/06 19:39:28  peter
     * default parameters working !
 
   Revision 1.6  2000/08/06 14:17:15  peter
@@ -573,4 +576,4 @@
   Revision 1.2  2000/07/13 11:32:49  michael
   + removed logs
 
-}
+}

+ 28 - 6
compiler/symsym.inc

@@ -395,7 +395,7 @@
            end;
       end;
 
-      
+
     procedure tprocsym.check_forward;
       var
          pd : pprocdef;
@@ -613,9 +613,12 @@
       isstabwritten := true;
       if assigned(definition^.parast) then
         definition^.parast^.concatstabto(asmlist);
-      if assigned(definition^.localst) then
+      { local type defs and vars should not be written
+        inside the main proc stab }
+      if assigned(definition^.localst) and
+         (lexlevel>main_program_level) then
         definition^.localst^.concatstabto(asmlist);
-      definition^.is_def_stab_written := true;
+      definition^.is_def_stab_written := written;
     end;
 {$endif GDB}
 
@@ -1692,7 +1695,15 @@
                begin
                   l1:=readlong;
                   l2:=readlong;
-                  value:=int64(l1)+(int64(l2) shl 32);
+{$ifopt R+}
+  {$define Range_check_on}
+{$endif opt R+}
+{$R- needed here }
+                  value:=qword(l1)+(int64(l2) shl 32);
+{$ifdef Range_check_on}
+  {$R+}
+  {$undef Range_check_on}
+{$endif Range_check_on}
                end
              else
                value:=readlong;
@@ -1707,7 +1718,15 @@
                  begin
                     l1:=readlong;
                     l2:=readlong;
-                    value:=int64(l1)+(int64(l2) shl 32);
+{$ifopt R+}
+  {$define Range_check_on}
+{$endif opt R+}
+{$R- needed here }
+                    value:=qword(l1)+(int64(l2) shl 32);
+{$ifdef Range_check_on}
+  {$R+}
+  {$undef Range_check_on}
+{$endif Range_check_on}
                  end
                else
                  value:=readlong;
@@ -2189,7 +2208,10 @@
 
 {
   $Log$
-  Revision 1.5  2000-08-16 13:06:07  florian
+  Revision 1.6  2000-08-21 11:27:44  pierre
+   * fix the stabs problems
+
+  Revision 1.5  2000/08/16 13:06:07  florian
     + support of 64 bit integer constants
 
   Revision 1.4  2000/08/13 12:54:56  peter

+ 8 - 5
compiler/symtable.pas

@@ -1225,7 +1225,7 @@ implementation
 
     procedure forcestabto(asmlist : paasmoutput; pd : pdef);
       begin
-        if not pd^.is_def_stab_written then
+        if pd^.is_def_stab_written = not_written then
          begin
            if assigned(pd^.typesym) then
             pd^.typesym^.isusedinstab := true;
@@ -2034,7 +2034,7 @@ implementation
                (symtabletype in [globalsymtable,staticsymtable]) then
               begin
                 ptypesym(sym)^.isusedinstab := true;
-                sym^.concatstabto(debuglist);
+                {sym^.concatstabto(debuglist);}
               end;
 {$endif GDB}
           end;
@@ -2679,7 +2679,7 @@ implementation
 {$ifdef GDB}
             if assigned(def^.typesym) then
               def^.typesym^.isusedinstab:=false;
-            def^.is_def_stab_written:=false;
+            def^.is_def_stab_written:=not_written;
 {$endif GDB}
             {if not current_module^.in_implementation then}
               begin
@@ -2993,7 +2993,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.5  2000-08-20 14:58:41  peter
+  Revision 1.6  2000-08-21 11:27:45  pierre
+   * fix the stabs problems
+
+  Revision 1.5  2000/08/20 14:58:41  peter
     * give fatal if objfpc/delphi mode things are found (merged)
 
   Revision 1.4  2000/08/16 18:33:54  peter
@@ -3008,4 +3011,4 @@ end.
   Revision 1.2  2000/07/13 11:32:50  michael
   + removed logs
 
-}
+}