Browse Source

* Bugfix on constant strings stab generation. Never worked and still
doesn't work for unknown reasons.

daniel 21 years ago
parent
commit
3dfde8c397
2 changed files with 28 additions and 4 deletions
  1. 21 1
      compiler/cutils.pas
  2. 7 3
      compiler/symsym.pas

+ 21 - 1
compiler/cutils.pas

@@ -34,6 +34,7 @@ interface
     type
        pstring = ^string;
        get_var_value_proc=function(const s:string):string of object;
+       Tcharset=set of char;
 
 
     {# Returns the minimal value between @var(a) and @var(b) }
@@ -73,6 +74,7 @@ interface
        exponent value is returned in power.
     }
     function ispowerof2(value : int64;var power : longint) : boolean;
+    function backspace_quote(const s:string;const qchars:Tcharset):string;
     function maybequoted(const s:string):string;
     function CompareText(S1, S2: string): longint;
 
@@ -610,6 +612,20 @@ uses
       end;
 
 
+    function backspace_quote(const s:string;const qchars:Tcharset):string;
+
+    var i:byte;
+
+    begin
+      backspace_quote:='';
+      for i:=1 to length(s) do
+        begin
+          if s[i] in qchars then
+            backspace_quote:=backspace_quote+'\';
+          backspace_quote:=backspace_quote+s[i];
+        end;
+    end;
+
     function maybequoted(const s:string):string;
       var
         s1 : string;
@@ -1104,7 +1120,11 @@ initialization
 end.
 {
   $Log$
-  Revision 1.33  2004-01-25 13:18:59  daniel
+  Revision 1.34  2004-01-26 22:08:20  daniel
+    * Bugfix on constant strings stab generation. Never worked and still
+      doesn't work for unknown reasons.
+
+  Revision 1.33  2004/01/25 13:18:59  daniel
     * Made varags parameter constant
 
   Revision 1.32  2004/01/25 11:33:48  daniel

+ 7 - 3
compiler/symsym.pas

@@ -2150,7 +2150,7 @@ implementation
       {even GDB v4.16 only now 'i' 'r' and 'e' !!!}
       case consttyp of
         conststring:
-          st:='s'''+strpas(pchar(value.valueptr))+'''';
+          st:='s'''+backspace_quote(strpas(pchar(value.valueptr)),['''','"','\'])+'''';
         constbool,
         constint,
         constord,
@@ -2171,7 +2171,7 @@ implementation
           { sets are not recognized by GDB}
           {***}
       end;
-      stabstring:=stabstr_evaluate('"${name}:c=$1",${N_FUNCTION},0,${line},0',[st]);
+      stabstring:=stabstr_evaluate('"${name}:c=$1",${N_FUNCTION},0,${line},0;',[st]);
     end;
 {$endif GDB}
 
@@ -2547,7 +2547,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.145  2004-01-26 16:12:28  daniel
+  Revision 1.146  2004-01-26 22:08:20  daniel
+    * Bugfix on constant strings stab generation. Never worked and still
+      doesn't work for unknown reasons.
+
+  Revision 1.145  2004/01/26 16:12:28  daniel
     * reginfo now also only allocated during register allocation
     * third round of gdb cleanups: kick out most of concatstabto