gdbint.pas 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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. signal_name,
  73. signal_string : pchar;
  74. current_pc : CORE_ADDR;
  75. { breakpoint }
  76. last_breakpoint_number,
  77. last_breakpoint_address,
  78. last_breakpoint_line : longint;
  79. last_breakpoint_file : pchar;
  80. invalid_breakpoint_line : boolean;
  81. { Highlevel }
  82. user_screen_shown,
  83. switch_to_user : boolean;
  84. constructor Init;
  85. destructor Done;
  86. procedure clear_frames;
  87. { functions }
  88. function error:boolean;
  89. function error_num:longint;
  90. function get_current_frame : longint;
  91. function set_current_frame(level : longint) : boolean;
  92. procedure DebuggerScreen;
  93. procedure UserScreen;
  94. { Hooks }
  95. procedure DoSelectSourceline(const fn:string;line:longint);virtual;
  96. procedure DoStartSession;virtual;
  97. procedure DoBreakSession;virtual;
  98. procedure DoEndSession(code:longint);virtual;
  99. procedure DoDebuggerScreen;virtual;
  100. procedure DoUserScreen;virtual;
  101. function AllowQuit : boolean;virtual;
  102. end;
  103. function GDBVersion : string;
  104. var
  105. curr_gdb : pgdbinterface;
  106. const
  107. use_gdb_file : boolean = false;
  108. var
  109. gdb_file : text;
  110. inferior_pid : longint;
  111. implementation
  112. uses
  113. strings;
  114. constructor TGDBInterface.Init;
  115. begin
  116. end;
  117. destructor TGDBInterface.Done;
  118. begin
  119. end;
  120. function tgdbinterface.error:boolean;
  121. begin
  122. error:=false;
  123. end;
  124. function tgdbinterface.error_num:longint;
  125. begin
  126. error_num:=0;
  127. end;
  128. function TGDBInterface.get_current_frame : longint;
  129. begin
  130. get_current_frame:=0;
  131. end;
  132. function TGDBInterface.set_current_frame(level : longint) : boolean;
  133. begin
  134. set_current_frame:=true;
  135. end;
  136. procedure TGDBInterface.Clear_Frames;
  137. begin
  138. end;
  139. procedure TGDBInterface.DebuggerScreen;
  140. begin
  141. end;
  142. procedure TGDBInterface.UserScreen;
  143. begin
  144. end;
  145. procedure TGDBInterface.DoSelectSourceline(const fn:string;line:longint);
  146. begin
  147. end;
  148. procedure TGDBInterface.DoStartSession;
  149. begin
  150. end;
  151. procedure TGDBInterface.DoBreakSession;
  152. begin
  153. end;
  154. procedure TGDBInterface.DoEndSession(code:longint);
  155. begin
  156. end;
  157. procedure TGDBInterface.DoDebuggerScreen;
  158. begin
  159. end;
  160. procedure TGDBInterface.DoUserScreen;
  161. begin
  162. end;
  163. function tgdbinterface.AllowQuit : boolean;
  164. begin
  165. AllowQuit:=true;
  166. end;
  167. function GDBVersion : string;
  168. begin
  169. GDBVersion:='Fake GDB';
  170. end;
  171. {*****************************************************************************
  172. TFrameEntry
  173. *****************************************************************************}
  174. constructor tframeentry.init;
  175. begin
  176. Reset;
  177. end;
  178. destructor tframeentry.done;
  179. begin
  180. Clear;
  181. end;
  182. procedure tframeentry.reset;
  183. begin
  184. file_name:=nil;
  185. function_name:=nil;
  186. args:=nil;
  187. line_number:=0;
  188. address:=0;
  189. end;
  190. procedure tframeentry.clear;
  191. begin
  192. if assigned(file_name) then
  193. strdispose(file_name);
  194. if assigned(function_name) then
  195. strdispose(function_name);
  196. if assigned(args) then
  197. strdispose(args);
  198. reset;
  199. end;
  200. {*****************************************************************************
  201. tgdbbuffer
  202. *****************************************************************************}
  203. const
  204. blocksize=2048;
  205. constructor tgdbbuffer.init;
  206. begin
  207. Buf:=nil;
  208. Size:=0;
  209. Resize(blocksize);
  210. Reset;
  211. end;
  212. destructor tgdbbuffer.done;
  213. begin
  214. if assigned(buf) then
  215. freemem(buf,size);
  216. end;
  217. procedure tgdbbuffer.reset;
  218. begin
  219. idx:=0;
  220. Buf[0]:=#0;
  221. end;
  222. procedure tgdbbuffer.append(p:pchar);
  223. var
  224. len : longint;
  225. begin
  226. if not assigned(p) then
  227. exit;
  228. len:=Strlen(p);
  229. if len+idx>size then
  230. Resize(len+idx);
  231. Move(p^,buf[idx],len);
  232. inc(idx,len);
  233. buf[idx]:=#0;
  234. end;
  235. procedure tgdbbuffer.resize(nsize : longint);
  236. var
  237. np : pchar;
  238. begin
  239. nsize:=((nsize+blocksize-1) div blocksize)*blocksize;
  240. getmem(np,nsize);
  241. move(buf^,np^,size);
  242. freemem(buf,size);
  243. buf:=np;
  244. size:=nsize;
  245. end;
  246. end.
  247. {
  248. $Log$
  249. Revision 1.3 2002-09-07 15:40:51 peter
  250. * old logs removed and tabs fixed
  251. Revision 1.2 2002/02/11 18:51:39 peter
  252. * signal_name added
  253. }