瀏覽代碼

fixed debuginfo for variables in staticsymtable

peter 21 年之前
父節點
當前提交
f4a7c3d444
共有 4 個文件被更改,包括 46 次插入20 次删除
  1. 10 5
      compiler/ncgutil.pas
  2. 9 7
      compiler/pmodules.pas
  3. 7 4
      compiler/symdef.pas
  4. 20 4
      compiler/symsym.pas

+ 10 - 5
compiler/ncgutil.pas

@@ -1795,6 +1795,9 @@ implementation
         { insert cut for smartlinking or alignment }
         maybe_new_object_file(curconstSegment);
         new_section(curconstSegment,sec_rodata,lower(sym.mangledname),const_align(l));
+{$ifdef GDB}
+        sym.concatstabto(curconstSegment);
+{$endif GDB}
         if (sym.owner.symtabletype=globalsymtable) or
            maybe_smartlink_symbol or
            (assigned(current_procinfo) and
@@ -1820,6 +1823,9 @@ implementation
         varalign:=var_align(l);
         maybe_new_object_file(bssSegment);
         new_section(bssSegment,sec_bss,lower(sym.mangledname),varalign);
+{$ifdef GDB}
+        sym.concatstabto(bssSegment);
+{$endif GDB}
         if (sym.owner.symtabletype=globalsymtable) or
            maybe_smartlink_symbol or
            DLLSource or
@@ -1931,11 +1937,7 @@ implementation
                                   if not(cs_create_pic in aktmoduleswitches) and
                                      not(vo_is_dll_var in varoptions) and
                                      not(vo_is_thread_var in varoptions) then
-{$ifndef macos}
-                                    reference_reset_symbol(localloc.reference,objectlibrary.newasmsymbol(mangledname,AB_EXTERNAL,AT_NONE),0);
-{$else}
                                     reference_reset_symbol(localloc.reference,objectlibrary.newasmsymbol(mangledname,AB_EXTERNAL,AT_DATA),0);
-{$endif macos}
                                 end;
                               else
                                 internalerror(200410103);
@@ -2207,7 +2209,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.234  2004-10-31 21:45:03  peter
+  Revision 1.235  2004-11-04 17:09:54  peter
+  fixed debuginfo for variables in staticsymtable
+
+  Revision 1.234  2004/10/31 21:45:03  peter
     * generic tlocation
     * move tlocation to cgutils
 

+ 9 - 7
compiler/pmodules.pas

@@ -625,14 +625,17 @@ implementation
           end
         else
           debugList.concat(tai_symbol.Createname_global(make_mangledname('DEBUGINFO',current_module.localsymtable,''),AT_DATA,0));
-        { first write all global/local symbols to a temp list. This will flag
-          all required tdefs. Afterwards this list will be added }
+        { first write all global/local symbols again to a temp list. This will flag
+          all required tdefs. After that the temp list can be removed since the debuginfo is already
+          written to the stabs when the variables/consts were written }
+{$warning Hack to get all needed types}
         vardebuglist:=taasmoutput.create;
         new_section(vardebuglist,sec_data,'',0);
         if assigned(current_module.globalsymtable) then
           tglobalsymtable(current_module.globalsymtable).concatstabto(vardebuglist);
         if assigned(current_module.localsymtable) then
           tstaticsymtable(current_module.localsymtable).concatstabto(vardebuglist);
+        vardebuglist.free;
         { reset unit type info flag }
         reset_unit_type_info;
         { write used types from the used units }
@@ -642,10 +645,6 @@ implementation
           tglobalsymtable(current_module.globalsymtable).concattypestabto(debuglist);
         if assigned(current_module.localsymtable) then
           tstaticsymtable(current_module.localsymtable).concattypestabto(debuglist);
-        { now all defs have a type in the debuglist, we now can add the vardebuglist since
-          all references to defs can be solved }
-        debuglist.concatlist(vardebuglist);
-        vardebuglist.free;
         { include files }
         if (cs_gdb_dbx in aktglobalswitches) then
           begin
@@ -1512,7 +1511,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.169  2004-10-31 15:29:39  olle
+  Revision 1.170  2004-11-04 17:09:54  peter
+  fixed debuginfo for variables in staticsymtable
+
+  Revision 1.169  2004/10/31 15:29:39  olle
     + All sections get names in macos
 
   Revision 1.168  2004/10/26 15:11:01  peter

+ 7 - 4
compiler/symdef.pas

@@ -4219,12 +4219,12 @@ implementation
         asmList.concat(Tai_stabs.Create(stabstring));
         if not(po_external in procoptions) then
           begin
-            tstoredsymtable(parast).concatstabto(asmlist);
+            tparasymtable(parast).concatstabto(asmlist);
             { local type defs and vars should not be written
               inside the main proc stab }
             if assigned(localst) and
-               (localst.symtablelevel>main_program_level) then
-              tstoredsymtable(localst).concatstabto(asmlist);
+               (localst.symtabletype=localsymtable) then
+              tlocalsymtable(localst).concatstabto(asmlist);
           end;
         stab_state:=stab_state_written;
       end;
@@ -6218,7 +6218,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.264  2004-11-03 09:46:34  florian
+  Revision 1.265  2004-11-04 17:09:54  peter
+  fixed debuginfo for variables in staticsymtable
+
+  Revision 1.264  2004/11/03 09:46:34  florian
     * fixed writing of para locations for procedures with explicit locations for parameters
 
   Revision 1.263  2004/11/01 23:30:11  peter

+ 20 - 4
compiler/symsym.pas

@@ -36,7 +36,7 @@ interface
        ppu,
        cclasses,symnot,
        { aasm }
-       aasmbase,
+       aasmbase,aasmtai,
        cpuinfo,cpubase,cgbase,cgutils,parabase
        ;
 
@@ -52,6 +52,7 @@ interface
 {$ifdef GDB}
           function  get_var_value(const s:string):string;
           function  stabstr_evaluate(const s:string;vars:array of string):Pchar;
+          procedure concatstabto(asmlist : taasmoutput);
 {$endif GDB}
           function  mangledname : string;
           procedure generate_mangledname;virtual;abstract;
@@ -305,7 +306,6 @@ interface
 implementation
 
     uses
-//       strings,
        { global }
        verbose,
        { target }
@@ -315,7 +315,9 @@ implementation
        { tree }
        node,
        { aasm }
-//       aasmcpu,
+{$ifdef gdb}
+       gdb,
+{$endif gdb}
        { codegen }
        paramgr,cresstr,
        procinfo
@@ -393,8 +395,19 @@ implementation
     begin
       stabstr_evaluate:=string_evaluate(s,@get_var_value,vars);
     end;
+
+
+    procedure tstoredsym.concatstabto(asmlist : taasmoutput);
+      var
+        stabstr : Pchar;
+      begin
+        stabstr:=stabstring;
+        if stabstr<>nil then
+          asmlist.concat(Tai_stabs.create(stabstr));
+      end;
 {$endif GDB}
 
+
     function tstoredsym.mangledname : string;
 
     begin
@@ -2251,7 +2264,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.189  2004-10-31 21:45:03  peter
+  Revision 1.190  2004-11-04 17:09:54  peter
+  fixed debuginfo for variables in staticsymtable
+
+  Revision 1.189  2004/10/31 21:45:03  peter
     * generic tlocation
     * move tlocation to cgutils