Try to create a stack tranlator

"Fabio Negrini" <[email protected]>
Newsgroups gmane.comp.lang.delphi.jedi
Message-ID <[email protected]>
Hi,

Im usinf  JEDI components to create information of the stack and then save
it into a text file.
When the Map file is together, the file have all informations (address, unit
name, proc name, line number, etc) but I can't distribute the MAP file for
each version. When the the application don't have the MAP the text file
comes just with the adresses.

So I am trying to create an application which reads the file with the
adresses and, with the MAP file I can translate the adresses to unit names,
proc names, line numbers, etc. But doesn't work because the adresses listed
on the text file are different of their correspondent on the map file.

Source Code...
// Save the stack into a file
// The MAP file is not available
procedure SaveStack;
var
 Stack : TJclStackInfoList;
 Result : TStrings;
begin
  Result := TStringList.Create;
  Stack := TJclStackInfoList.Create(True, 0, nil);
  try
    Stack.AddToStrings(Result);
    Result.SaveToFile('C:\Stack.txt');
  finally
    Stack.Free;
    Result.Free;
  end;
end;

// Translator. The idea is get informations of the MAP file
// memStack is a TMemo...

procedure Translate;
var
  Map : TJclMapScanner;
  Stack : TStrings;
  i : integer;
  Addr : Cardinal;
  function ConverAddress(Hex : string) : Cardinal;
  begin
    Hex := Copy(Hex, Pos('[',Hex)+1 , Pos(']',Hex)-2);
    Result := StrToInt('$'+Hex);
  end;
begin
  memStack.Lines.Clear;
  Map := TJclMapScanner.Create({The MAP File});
  try
    Stack := TStringList.Create();
    try
      Stack.LoadFromFile(C:\Stack.txt); // the file create on SaveStack
      for i := 0 to Stack.Count-1 do
      begin
        Addr := ConverAddress(Stack[i]);
        try
          memStack.Lines.Add(Map.ProcNameFromAddr(Addr));
        except
          on E:Exception do
            memStack.Lines.Add('Invalid Format. '+ E.Message); // when stack
file is invalid
        end
      end;
    finally
      Stack.Free;
    end;
  finally
    Map.Free;
  end;
end;

Thanks for any help!!!

Fabio Negrini


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Rent DVDs Online - Over 14,500 titles.
No Late Fees & Free Shipping.
Try Netflix for FREE!
http://us.click.yahoo.com/vhSowB/XP.FAA/3jkFAA/i7folB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[email protected]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.