gdbint.pas 5.3 KB

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