Browse Source

--- Merging r18209 into '.':
U rtl/objpas/objpas.pp
A tests/webtbs/tw19977.pp
--- Merging r18217 into '.':
U packages/fcl-passrc/src/pparser.pp
--- Merging r18224 into '.':
U rtl/linux/i386/si_c21.inc
--- Merging r18231 into '.':
U rtl/inc/heaptrc.pp
--- Merging r18940 into '.':
U packages/winunits-jedi/src/jwawintype.pas

# revisions: 18209,18217,18224,18231,18940
------------------------------------------------------------------------
r18209 | florian | 2011-08-14 21:00:07 +0200 (Sun, 14 Aug 2011) | 2 lines
Changed paths:
M /trunk/rtl/objpas/objpas.pp
A /trunk/tests/webtbs/tw19977.pp

* *Dir(<ansistring>) functions need to check io result as well, resolves #19977

------------------------------------------------------------------------
------------------------------------------------------------------------
r18217 | sekelsenmat | 2011-08-16 12:42:18 +0200 (Tue, 16 Aug 2011) | 1 line
Changed paths:
M /trunk/packages/fcl-passrc/src/pparser.pp

fcl-passrc: Improves a lot the default exception message for parsing errors
------------------------------------------------------------------------
------------------------------------------------------------------------
r18224 | florian | 2011-08-16 20:45:39 +0200 (Tue, 16 Aug 2011) | 2 lines
Changed paths:
M /trunk/rtl/linux/i386/si_c21.inc

* fix got loading si_c32, resolves #19520 (still uses the call/pop approach because it is faster on modern CPUs)

------------------------------------------------------------------------
------------------------------------------------------------------------
r18231 | florian | 2011-08-16 22:47:15 +0200 (Tue, 16 Aug 2011) | 2 lines
Changed paths:
M /trunk/rtl/inc/heaptrc.pp

+ patch from Benito van der Zander to enable heaptrc to dump leaked or faulty memory blocks (function disabled by default), resolves #19691

------------------------------------------------------------------------
------------------------------------------------------------------------
r18940 | marco | 2011-09-02 10:01:30 +0200 (Fri, 02 Sep 2011) | 2 lines
Changed paths:
M /trunk/packages/winunits-jedi/src/jwawintype.pas

* Typo fix, reported by Basil, Mantis #20131

------------------------------------------------------------------------

git-svn-id: branches/fixes_2_6@19016 -

marco 14 years ago
parent
commit
497846a156

+ 1 - 0
.gitattributes

@@ -11705,6 +11705,7 @@ tests/webtbs/tw19548.pp svneol=native#text/pascal
 tests/webtbs/tw1964.pp svneol=native#text/plain
 tests/webtbs/tw19700.pp svneol=native#text/plain
 tests/webtbs/tw1996.pp svneol=native#text/plain
+tests/webtbs/tw19977.pp svneol=native#text/pascal
 tests/webtbs/tw2001.pp svneol=native#text/plain
 tests/webtbs/tw2002.pp svneol=native#text/plain
 tests/webtbs/tw2004.pp svneol=native#text/plain

+ 3 - 2
packages/fcl-passrc/src/pparser.pp

@@ -27,7 +27,7 @@ resourcestring
   SErrNoSourceGiven = 'No source file specified';
   SErrMultipleSourceFiles = 'Please specify only one source file';
   SParserError = 'Error';
-  SParserErrorAtToken = '%s at token "%s"';
+  SParserErrorAtToken = '%s at token "%s" in file %s at line %d column %d';
   SParserUngetTokenError = 'Internal error: Cannot unget more tokens, history buffer is full';
   SParserExpectTokenError = 'Expected "%s"';
   SParserExpectedCommaRBracket = 'Expected "," or ")"';
@@ -240,7 +240,8 @@ end;
 
 procedure TPasParser.ParseExc(const Msg: String);
 begin
-  raise EParserError.Create(Format(SParserErrorAtToken, [Msg, CurTokenName]) {$ifdef addlocation}+' ('+inttostr(scanner.currow)+' '+inttostr(scanner.curcolumn)+')'{$endif},
+  raise EParserError.Create(Format(SParserErrorAtToken, [Msg, CurTokenName, Scanner.CurFilename, Scanner.CurRow, Scanner.CurColumn])
+    {$ifdef addlocation}+' ('+inttostr(scanner.currow)+' '+inttostr(scanner.curcolumn)+')'{$endif},
     Scanner.CurFilename, Scanner.CurRow, Scanner.CurColumn);
 end;
 

+ 2 - 2
packages/winunits-jedi/src/jwawintype.pas

@@ -201,8 +201,8 @@ type
   {$EXTERNALSYM LPUWSTR}
   PUWSTR = {$IFDEF USE_DELPHI_TYPES} Windows.LPWSTR {$ELSE} PWideChar {$ENDIF};
   {$EXTERNALSYM PUWSTR}
-  LCPUWSTR = {$IFDEF USE_DELPHI_TYPES} Windows.LPWSTR {$ELSE} PWideChar {$ENDIF};
-  {$EXTERNALSYM LCPUWSTR}
+  LPCUWSTR = {$IFDEF USE_DELPHI_TYPES} Windows.LPWSTR {$ELSE} PWideChar {$ENDIF};
+  {$EXTERNALSYM LPCUWSTR}
   PCUWSTR = {$IFDEF USE_DELPHI_TYPES} Windows.LPWSTR {$ELSE} PWideChar {$ENDIF};
   {$EXTERNALSYM PCUWSTR}
 

+ 44 - 0
rtl/inc/heaptrc.pp

@@ -80,6 +80,9 @@ const
     this allows to test for writing into that part }
   usecrc : boolean = true;
 
+  printleakedblock: boolean = false;
+  printfaultyblock: boolean = false;
+  maxprintedblocklength: integer = 128;
 
 implementation
 
@@ -255,14 +258,50 @@ function InternalFreeMemSize(loc_info: pheap_info; p: pointer; pp: pheap_mem_inf
   size: ptruint; release_todo_lock: boolean): ptruint; forward;
 function TraceFreeMem(p: pointer): ptruint; forward;
 
+procedure printhex(p : pointer; const size : PtrUInt; var ptext : text);
+var s: PtrUInt;
+ i: Integer;
+begin
+  s := size;
+  if s > maxprintedblocklength then
+    s := maxprintedblocklength;
+
+  for i:=0 to s-1 do
+    write(ptext, hexstr(pbyte(p + i)^,2));
+
+  if size > maxprintedblocklength then
+    writeln(ptext,'.. - ')
+  else
+    writeln(ptext, ' - ');
+
+  for i:=0 to s-1 do
+    if pchar(p + sizeof(theap_mem_info) + i)^ < ' ' then
+      write(ptext, ' ')
+    else
+      write(ptext, pchar(p + i)^);
+
+  if size > maxprintedblocklength then
+    writeln(ptext,'..')
+  else
+    writeln(ptext);
+end;
+
 procedure call_stack(pp : pheap_mem_info;var ptext : text);
 var
   i  : ptruint;
+  s: PtrUInt;
 begin
   writeln(ptext,'Call trace for block $',hexstr(pointer(pp)+sizeof(theap_mem_info)),' size ',pp^.size);
+  if printleakedblock then
+    begin
+      write(ptext, 'Block content: ');
+      printhex(pointer(pp) + sizeof(theap_mem_info), pp^.size, ptext);
+    end;
+
   for i:=1 to tracesize do
    if pp^.calls[i]<>nil then
      writeln(ptext,BackTraceStrFunc(pp^.calls[i]));
+
   { the check is done to be sure that the procvar is not overwritten }
   if assigned(pp^.extra_info) and
      (pp^.extra_info^.check=$12345678) and
@@ -303,6 +342,11 @@ procedure dump_error(p : pheap_mem_info;var ptext : text);
 begin
   Writeln(ptext,'Marked memory at $',HexStr(pointer(p)+sizeof(theap_mem_info)),' invalid');
   Writeln(ptext,'Wrong signature $',hexstr(p^.sig,8),' instead of ',hexstr(calculate_sig(p),8));
+  if printfaultyblock then
+    begin
+      write(ptext, 'Block content: ');
+      printhex(pointer(p) + sizeof(theap_mem_info), p^.size, ptext);
+    end;
   dump_stack(ptext,get_caller_frame(get_frame));
 end;
 

+ 5 - 5
rtl/linux/i386/si_c21.inc

@@ -71,7 +71,7 @@ asm
 	call .Lpiclab
 .Lpiclab:
         popl  %ebx
-        addl  $_GLOBAL_OFFSET_TABLE_,%ebx
+        addl  $_GLOBAL_OFFSET_TABLE_+1,%ebx
 
 	movl  dlexitproc@GOT(%ebx),%ecx
 	movl  %edx,(%ecx)
@@ -100,7 +100,7 @@ asm
         call  .Lpiclab2
 .Lpiclab2:
         popl  %ebx
-        addl  $_GLOBAL_OFFSET_TABLE_,%ebx
+        addl  $_GLOBAL_OFFSET_TABLE_+1,%ebx
 	movl  initialstkptr@GOT(%ebx),%ebx
   	movl  %esp,(%ebx)
 	popl  %ebx
@@ -139,7 +139,7 @@ asm
         call  .Lpiclab
 .Lpiclab:
         popl  %ebx
-        addl  $_GLOBAL_OFFSET_TABLE_,%ebx
+        addl  $_GLOBAL_OFFSET_TABLE_+1,%ebx
         movl  dlexitproc@GOT(%ebx),%eax
         movl  (%eax),%eax
   {$else FPC_PIC}
@@ -155,7 +155,7 @@ asm
   call    .Lpiclab2
 .Lpiclab2:
   popl    %ebx
-  addl    $_GLOBAL_OFFSET_TABLE_,%ebx
+  addl    $_GLOBAL_OFFSET_TABLE_+1,%ebx
   movl    ExitCode@GOT(%ebx),%ebx
  {$if sizeof(ExitCode)=2}
   movzwl  (%ebx),%ebx
@@ -177,7 +177,7 @@ asm
   call    .Lpiclab3
 .Lpiclab3:
   popl    %ebx
-  addl    $_GLOBAL_OFFSET_TABLE_,%ebx
+  addl    $_GLOBAL_OFFSET_TABLE_+1,%ebx
   movl    ExitCode@GOT(%ebx),%ebx
  {$if sizeof(ExitCode)=2}
   movzwl  (%ebx),%ebx

+ 3 - 3
rtl/objpas/objpas.pp

@@ -249,17 +249,17 @@ end;
 
 
 {$ifdef FPC_HAS_FEATURE_FILEIO}
-Procedure MkDir(const s:ansistring);
+Procedure MkDir(const s:ansistring);[IOCheck];
 begin
   mkdirpchar(pchar(s),length(s));
 end;
 
-Procedure RmDir(const s:ansistring);
+Procedure RmDir(const s:ansistring);[IOCheck];
 begin
   RmDirpchar(pchar(s),length(s));
 end;
 
-Procedure ChDir(const s:ansistring);
+Procedure ChDir(const s:ansistring);[IOCheck];
 begin
   ChDirpchar(pchar(s),length(s));
 end;

+ 27 - 0
tests/webtbs/tw19977.pp

@@ -0,0 +1,27 @@
+{$mode objfpc}{$H+}
+{$I+}
+
+uses SysUtils;
+
+const
+  NotExistingDir = {$ifdef UNIX} '/not_existing_directory_kambi_test' {$endif}
+                   {$ifdef MSWINDOWS} 'c:/not_existing_directory_kambi_test' {$endif}
+                   {$ifdef GO32V2} 'c:/not_existing_directory_kambi_test' {$endif};
+begin
+  try
+    ChDir(NotExistingDir);
+    Assert(false, 'ChDir to ' + NotExistingDir + ' didn''t raise an exception');
+  except
+    on E: EInOutError do Writeln('Ok, ChDir raised exception');
+  end;
+
+  try
+    Writeln('We are somewhere after ChDir');
+  except
+    on E: EInOutError do 
+      begin
+        Writeln('Ups, Writeln raised exception');
+        halt(1);
+      end;
+  end;
+end.