فهرست منبع

* Check of memory ranges under OS/2 added to HeapTrc

git-svn-id: trunk@1735 -
Tomas Hajny 20 سال پیش
والد
کامیت
349d7108ce
3فایلهای تغییر یافته به همراه26 افزوده شده و 0 حذف شده
  1. 6 0
      rtl/emx/system.pas
  2. 18 0
      rtl/inc/heaptrc.pp
  3. 2 0
      rtl/os2/system.pas

+ 6 - 0
rtl/emx/system.pas

@@ -104,6 +104,7 @@ var
 (* 3 .. Presentation Manager OS/2 session  *)
 (* 4 .. detached (background) OS/2 process *)
   ApplicationType: cardinal;
+  StackTop : PtrUInt;
 
 
 procedure SetDefaultOS2FileType (FType: ShortString);
@@ -526,6 +527,8 @@ begin
             begin
                 stackbottom:=pointer(heap_brk);     {In DOS mode, heap_brk is
                                                      also the stack bottom.}
+                StackTop := StackBottom + InitialStkLen;
+{$WARNING To be checked/corrected!}
                 ApplicationType := 1;   (* Running under DOS. *)
                 IsConsole := true;
                 ProcessID := 1;
@@ -535,6 +538,7 @@ begin
             begin
                 DosGetInfoBlocks (@TIB, @PIB);
                 StackBottom := pointer (TIB^.Stack);
+                StackTop := PtrUInt (TIB^.StackLimit);
                 Environment := pointer (PIB^.Env);
                 ApplicationType := PIB^.ProcType;
                 ProcessID := PIB^.PID;
@@ -545,6 +549,8 @@ begin
             begin
                 stackbottom:=nil;   {Not sure how to get it, but seems to be
                                      always zero.}
+                StackTop := StackBottom + InitialStkLen;
+{$WARNING To be checked/corrected!}
                 ApplicationType := 1;   (* Running under DOS. *)
                 IsConsole := true;
                 ProcessID := 1;

+ 18 - 0
rtl/inc/heaptrc.pp

@@ -747,6 +747,14 @@ var
    eend : ptruint; external name '_end';
 {$endif}
 
+{$ifdef os2}
+(* Currently still EMX based - possibly to be changed in the future. *)
+var
+   etext: ptruint; external name '_etext';
+   edata : ptruint; external name '_edata';
+   eend : ptruint; external name '_end';
+{$endif}
+
 {$ifdef windows}
 var
    sdata : ptruint; external name '__data_start__';
@@ -805,6 +813,16 @@ begin
     goto _exit;
 {$endif windows}
 
+{$IFDEF OS2}
+  { inside stack ? }
+  if (PtrUInt (P) > PtrUInt (Get_Frame)) and
+     (PtrUInt (P) < StackTop) then
+    goto _exit;
+  { inside data or bss ? }
+  if (PtrUInt (P) >= PtrUInt (@etext)) and (PtrUInt (P) < PtrUInt (@eend)) then
+    goto _exit;
+{$ENDIF OS2}
+
 {$ifdef linux}
   { inside stack ? }
   if (ptruint(p)>ptruint(get_frame)) and

+ 2 - 0
rtl/os2/system.pas

@@ -133,6 +133,7 @@ var
 (* for all threads, so the setting isn't declared as a threadvar and       *)
 (* should be only changed at the beginning of the main thread if needed.   *)
   UseHighMem: boolean;
+  StackTop : PtrUInt;
 
 
 
@@ -705,6 +706,7 @@ begin
     FileHandleCount := GetFileHandleCount;
     DosGetInfoBlocks (@TIB, @PIB);
     StackBottom := TIB^.Stack;
+    StackTop := PtrUInt (TIB^.StackLimit);
 
     {Set type of application}
     ApplicationType := PIB^.ProcType;