gdbint.pas 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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. { Highlevel }
  75. user_screen_shown,
  76. switch_to_user : boolean;
  77. constructor Init;
  78. destructor Done;
  79. procedure clear_frames;
  80. { functions }
  81. function error:boolean;
  82. function error_num:longint;
  83. function get_current_frame : longint;
  84. function set_current_frame(level : longint) : boolean;
  85. procedure DebuggerScreen;
  86. procedure UserScreen;
  87. { Hooks }
  88. procedure DoSelectSourceline(const fn:string;line:longint);virtual;
  89. procedure DoStartSession;virtual;
  90. procedure DoBreakSession;virtual;
  91. procedure DoEndSession(code:longint);virtual;
  92. procedure DoDebuggerScreen;virtual;
  93. procedure DoUserScreen;virtual;
  94. function AllowQuit : boolean;virtual;
  95. end;
  96. function GDBVersion : string;
  97. var
  98. curr_gdb : pgdbinterface;
  99. const
  100. use_gdb_file : boolean = false;
  101. var
  102. gdb_file : text;
  103. implementation
  104. uses
  105. strings;
  106. constructor TGDBInterface.Init;
  107. begin
  108. end;
  109. destructor TGDBInterface.Done;
  110. begin
  111. end;
  112. function tgdbinterface.error:boolean;
  113. begin
  114. error:=false;
  115. end;
  116. function tgdbinterface.error_num:longint;
  117. begin
  118. error_num:=0;
  119. end;
  120. function TGDBInterface.get_current_frame : longint;
  121. begin
  122. get_current_frame:=0;
  123. end;
  124. function TGDBInterface.set_current_frame(level : longint) : boolean;
  125. begin
  126. set_current_frame:=true;
  127. end;
  128. procedure TGDBInterface.Clear_Frames;
  129. begin
  130. end;
  131. procedure TGDBInterface.DebuggerScreen;
  132. begin
  133. end;
  134. procedure TGDBInterface.UserScreen;
  135. begin
  136. end;
  137. procedure TGDBInterface.DoSelectSourceline(const fn:string;line:longint);
  138. begin
  139. end;
  140. procedure TGDBInterface.DoStartSession;
  141. begin
  142. end;
  143. procedure TGDBInterface.DoBreakSession;
  144. begin
  145. end;
  146. procedure TGDBInterface.DoEndSession(code:longint);
  147. begin
  148. end;
  149. procedure TGDBInterface.DoDebuggerScreen;
  150. begin
  151. end;
  152. procedure TGDBInterface.DoUserScreen;
  153. begin
  154. end;
  155. function tgdbinterface.AllowQuit : boolean;
  156. begin
  157. AllowQuit:=true;
  158. end;
  159. function GDBVersion : string;
  160. begin
  161. GDBVersion:='Fake GDB';
  162. end;
  163. {*****************************************************************************
  164. TFrameEntry
  165. *****************************************************************************}
  166. constructor tframeentry.init;
  167. begin
  168. Reset;
  169. end;
  170. destructor tframeentry.done;
  171. begin
  172. Clear;
  173. end;
  174. procedure tframeentry.reset;
  175. begin
  176. file_name:=nil;
  177. function_name:=nil;
  178. args:=nil;
  179. line_number:=0;
  180. address:=0;
  181. end;
  182. procedure tframeentry.clear;
  183. begin
  184. if assigned(file_name) then
  185. strdispose(file_name);
  186. if assigned(function_name) then
  187. strdispose(function_name);
  188. if assigned(args) then
  189. strdispose(args);
  190. reset;
  191. end;
  192. {*****************************************************************************
  193. tgdbbuffer
  194. *****************************************************************************}
  195. const
  196. blocksize=2048;
  197. constructor tgdbbuffer.init;
  198. begin
  199. Buf:=nil;
  200. Size:=0;
  201. Resize(blocksize);
  202. Reset;
  203. end;
  204. destructor tgdbbuffer.done;
  205. begin
  206. if assigned(buf) then
  207. freemem(buf,size);
  208. end;
  209. procedure tgdbbuffer.reset;
  210. begin
  211. idx:=0;
  212. Buf[0]:=#0;
  213. end;
  214. procedure tgdbbuffer.append(p:pchar);
  215. var
  216. len : longint;
  217. begin
  218. if not assigned(p) then
  219. exit;
  220. len:=Strlen(p);
  221. if len+idx>size then
  222. Resize(len+idx);
  223. Move(p^,buf[idx],len);
  224. inc(idx,len);
  225. buf[idx]:=#0;
  226. end;
  227. procedure tgdbbuffer.resize(nsize : longint);
  228. var
  229. np : pchar;
  230. begin
  231. nsize:=((nsize+blocksize-1) div blocksize)*blocksize;
  232. getmem(np,nsize);
  233. move(buf^,np^,size);
  234. freemem(buf,size);
  235. buf:=np;
  236. size:=nsize;
  237. end;
  238. end.
  239. {
  240. $Log$
  241. Revision 1.8 2000-02-13 00:01:18 carl
  242. * Private variables were wrongly placed.
  243. Revision 1.7 2000/02/07 13:19:43 pierre
  244. + Set_current_frame/Get_current_frame dummies
  245. Revision 1.6 1999/11/25 20:22:59 peter
  246. * package dependencies
  247. Revision 1.5 1999/09/10 08:44:20 peter
  248. * updated
  249. Revision 1.4 1999/08/17 13:25:17 peter
  250. * updates with the compiler browcol
  251. Revision 1.3 1999/07/13 11:25:57 peter
  252. * fixed typo in gdbversion
  253. Revision 1.2 1999/07/12 13:08:20 pierre
  254. + added GDBVersion function
  255. * tries to intercept quit command from GDB Window
  256. + AllowQuit method
  257. Revision 1.1 1999/02/16 10:44:15 peter
  258. * updated
  259. }