symify.pp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 2000-07-13 06:33:58 michael
  73. + Initial import
  74. Revision 1.1 1999/11/24 23:36:33 peter
  75. * moved to packages dir
  76. Revision 1.2 1999/11/09 22:59:07 pierre
  77. + function name and offset
  78. Revision 1.1 1999/05/22 13:43:00 peter
  79. * moved
  80. Revision 1.1 1998/10/07 15:57:38 peter
  81. * initial version
  82. Revision 1.1 1998/10/07 15:48:20 peter
  83. * initial version
  84. }