gdbint.pas 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. {
  2. $Id$
  3. Fake GDBInt unit
  4. **********************************************************************}
  5. unit GDBInt;
  6. interface
  7. type
  8. psyminfo=^tsyminfo;
  9. tsyminfo=record
  10. address : longint;
  11. fname : pchar;
  12. line : longint;
  13. funcname : pchar;
  14. end;
  15. tframeentry = object
  16. file_name : pchar;
  17. function_name : pchar;
  18. args : pchar;
  19. line_number : longint;
  20. address : longint;
  21. constructor init;
  22. destructor done;
  23. procedure reset;
  24. procedure clear;
  25. end;
  26. pframeentry=^tframeentry;
  27. ppframeentry=^pframeentry;
  28. tgdbbuffer=object
  29. buf : pchar;
  30. size,
  31. idx : longint;
  32. constructor Init;
  33. destructor Done;
  34. procedure Reset;
  35. procedure Resize(nsize : longint);
  36. procedure Append(p:pchar);
  37. end;
  38. PGDBInterface=^TGDBInterface;
  39. TGDBInterface=object
  40. gdberrorbuf,
  41. gdboutputbuf : tgdbbuffer;
  42. command_level,
  43. got_error,
  44. reset_command,
  45. call_reset,
  46. Debuggee_started : boolean;
  47. { frames and frame info while recording a frame }
  48. frames : ppframeentry;
  49. frame_size,
  50. frame_count : longint;
  51. record_frames,
  52. frame_begin_seen : boolean;
  53. stop_breakpoint_number,
  54. current_address,
  55. current_line_number,
  56. signal_start,
  57. signal_end,
  58. error_start,
  59. error_end,
  60. function_start,
  61. function_end,
  62. args_start,
  63. args_end,
  64. file_start,
  65. file_end,
  66. line_start,
  67. line_end : longint;
  68. { breakpoint }
  69. last_breakpoint_number,
  70. last_breakpoint_address,
  71. last_breakpoint_line : longint;
  72. last_breakpoint_file : pchar;
  73. invalid_breakpoint_line : boolean;
  74. constructor Init;
  75. destructor Done;
  76. procedure clear_frames;
  77. { Highlevel }
  78. user_screen_shown,
  79. switch_to_user : boolean;
  80. { functions }
  81. function error:boolean;
  82. function error_num:longint;
  83. { Hooks }
  84. procedure DoSelectSourceline(const fn:string;line:longint);virtual;
  85. procedure DoStartSession;virtual;
  86. procedure DoBreakSession;virtual;
  87. procedure DoEndSession(code:longint);virtual;
  88. procedure DoDebuggerScreen;virtual;
  89. procedure DoUserScreen;virtual;
  90. function AllowQuit : boolean;virtual;
  91. end;
  92. function GDBVersion : string;
  93. var
  94. curr_gdb : pgdbinterface;
  95. const
  96. use_gdb_file : boolean = false;
  97. var
  98. gdb_file : text;
  99. implementation
  100. uses
  101. strings;
  102. constructor TGDBInterface.Init;
  103. begin
  104. end;
  105. destructor TGDBInterface.Done;
  106. begin
  107. end;
  108. function tgdbinterface.error:boolean;
  109. begin
  110. error:=false;
  111. end;
  112. function tgdbinterface.error_num:longint;
  113. begin
  114. error_num:=0;
  115. end;
  116. procedure TGDBInterface.Clear_Frames;
  117. begin
  118. end;
  119. procedure TGDBInterface.DoSelectSourceline(const fn:string;line:longint);
  120. begin
  121. end;
  122. procedure TGDBInterface.DoStartSession;
  123. begin
  124. end;
  125. procedure TGDBInterface.DoBreakSession;
  126. begin
  127. end;
  128. procedure TGDBInterface.DoEndSession(code:longint);
  129. begin
  130. end;
  131. procedure TGDBInterface.DoDebuggerScreen;
  132. begin
  133. end;
  134. procedure TGDBInterface.DoUserScreen;
  135. begin
  136. end;
  137. function tgdbinterface.AllowQuit : boolean;
  138. begin
  139. AllowQuit:=true;
  140. end;
  141. function GDBVersion : string;
  142. begin
  143. GDBVersion:='Fake GDB';
  144. end;
  145. {*****************************************************************************
  146. TFrameEntry
  147. *****************************************************************************}
  148. constructor tframeentry.init;
  149. begin
  150. Reset;
  151. end;
  152. destructor tframeentry.done;
  153. begin
  154. Clear;
  155. end;
  156. procedure tframeentry.reset;
  157. begin
  158. file_name:=nil;
  159. function_name:=nil;
  160. args:=nil;
  161. line_number:=0;
  162. address:=0;
  163. end;
  164. procedure tframeentry.clear;
  165. begin
  166. if assigned(file_name) then
  167. strdispose(file_name);
  168. if assigned(function_name) then
  169. strdispose(function_name);
  170. if assigned(args) then
  171. strdispose(args);
  172. reset;
  173. end;
  174. {*****************************************************************************
  175. tgdbbuffer
  176. *****************************************************************************}
  177. const
  178. blocksize=2048;
  179. constructor tgdbbuffer.init;
  180. begin
  181. Buf:=nil;
  182. Size:=0;
  183. Resize(blocksize);
  184. Reset;
  185. end;
  186. destructor tgdbbuffer.done;
  187. begin
  188. if assigned(buf) then
  189. freemem(buf,size);
  190. end;
  191. procedure tgdbbuffer.reset;
  192. begin
  193. idx:=0;
  194. Buf[0]:=#0;
  195. end;
  196. procedure tgdbbuffer.append(p:pchar);
  197. var
  198. len : longint;
  199. begin
  200. if not assigned(p) then
  201. exit;
  202. len:=Strlen(p);
  203. if len+idx>size then
  204. Resize(len+idx);
  205. Move(p^,buf[idx],len);
  206. inc(idx,len);
  207. buf[idx]:=#0;
  208. end;
  209. procedure tgdbbuffer.resize(nsize : longint);
  210. var
  211. np : pchar;
  212. begin
  213. nsize:=((nsize+blocksize-1) div blocksize)*blocksize;
  214. getmem(np,nsize);
  215. move(buf^,np^,size);
  216. freemem(buf,size);
  217. buf:=np;
  218. size:=nsize;
  219. end;
  220. end.
  221. {
  222. $Log$
  223. Revision 1.5 1999-09-10 08:44:20 peter
  224. * updated
  225. Revision 1.4 1999/08/17 13:25:17 peter
  226. * updates with the compiler browcol
  227. Revision 1.3 1999/07/13 11:25:57 peter
  228. * fixed typo in gdbversion
  229. Revision 1.2 1999/07/12 13:08:20 pierre
  230. + added GDBVersion function
  231. * tries to intercept quit command from GDB Window
  232. + AllowQuit method
  233. Revision 1.1 1999/02/16 10:44:15 peter
  234. * updated
  235. }