symify.pp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. {
  2. $Id$
  3. Copyright (c) 1998 by Peter Vreman
  4. Translate backtrace addresses into file and line info
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. program symify;
  12. uses GDBInt;
  13. var
  14. gdb : tgdbinterface;
  15. procedure processlog(const fn:string);
  16. var
  17. t : text;
  18. hs,s : string;
  19. code : word;
  20. i,
  21. addr : longint;
  22. sym : tsyminfo;
  23. begin
  24. assign(t,fn);
  25. {$I-}
  26. reset(t);
  27. {$I+}
  28. if ioresult<>0 then
  29. exit;
  30. while not eof(t) do
  31. begin
  32. readln(t,s);
  33. i:=pos('0x',s);
  34. if i=3 then
  35. begin
  36. hs:='$'+Copy(s,5,8);
  37. Val(hs,addr,code);
  38. if code=0 then
  39. begin
  40. gdb.GetAddrSymInfo(addr,sym);
  41. Write(Copy(s,1,12));
  42. if assigned(sym.funcname) then
  43. write(' in ',sym.funcname,'+',sym.offset);
  44. if assigned(sym.fname) then
  45. writeln(' ',sym.fname,':',sym.line)
  46. else
  47. writeln;
  48. end
  49. else
  50. writeln(s);
  51. end
  52. else
  53. writeln(s);
  54. end;
  55. close(t);
  56. end;
  57. begin
  58. if paramcount<2 then
  59. begin
  60. writeln('usage: symify <log> <file>');
  61. halt(1);
  62. end;
  63. gdb.init;
  64. writeln('loading ',paramstr(2));
  65. gdb.gdb_command('file '+paramstr(2));
  66. writeln('parsing ',paramstr(1));
  67. processlog(paramstr(1));
  68. gdb.done;
  69. end.
  70. {
  71. $Log$
  72. Revision 1.1 2002-01-29 17:54:49 peter
  73. * splitted to base and extra
  74. Revision 1.2 2000/07/13 11:33:16 michael
  75. + removed logs
  76. }