gdbint.pas 5.9 KB

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