gdbint.pas 5.4 KB

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