gdbint.pp 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144
  1. {
  2. Copyright (c) 1998 by Peter Vreman
  3. Lowlevel GDB interface which communicates directly with libgdb
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. unit GdbInt;
  11. {$mode objfpc}
  12. {$define NotImplemented}
  13. {$define COMPILING_GDBINT_UNIT}
  14. {$ifdef USE_GDBLIBINC}
  15. {$i gdblib.inc}
  16. {$else not USE_GDBLIBINC}
  17. {$i gdbver.inc}
  18. {$endif not USE_GDBLIBINC}
  19. { Possible optional conditionals:
  20. GDB_DISABLE_INTL To explicitly not use libintl
  21. GDB_DISABLE_PYTHON To explicitly not use libpython,
  22. if gdb was configured using --without-python
  23. GDB_CORE_ADDR_FORCE_64BITS To force 64 bits for CORE_ADDR
  24. Verbose To test gdbint
  25. DebugCommand To debug Command method
  26. }
  27. interface
  28. {$smartlink off}
  29. { Is create_breakpoint_hook deprecated? }
  30. { Seem not so for 6.1 }
  31. {$define GDB_HAS_DEPRECATED_CBPH}
  32. { 6.1.x }
  33. {$ifdef GDB_V601}
  34. {$info using gdb 6.1.x}
  35. {$define GDB_V6}
  36. {$define GDB_HAS_DB_COMMANDS}
  37. {$undef GDB_HAS_DEPRECATED_CBPH}
  38. {$endif def GDB_V601}
  39. { 6.2.x }
  40. {$ifdef GDB_V602}
  41. {$info using gdb 6.2.x}
  42. {$define GDB_V6}
  43. {$define GDB_HAS_DB_COMMANDS}
  44. {$endif def GDB_V602}
  45. { 6.3.x }
  46. {$ifdef GDB_V603}
  47. {$info using gdb 6.3.x}
  48. {$define GDB_V6}
  49. {$define GDB_HAS_DB_COMMANDS}
  50. {$endif def GDB_V603}
  51. { 6.4.x }
  52. {$ifdef GDB_V604}
  53. {$info using gdb 6.4.x}
  54. {$define GDB_V6}
  55. {$define GDB_NEEDS_NO_ERROR_INIT}
  56. {$define GDB_HAS_DB_COMMANDS}
  57. {$endif def GDB_V604}
  58. { 6.5.x }
  59. {$ifdef GDB_V605}
  60. {$info using gdb 6.5.x}
  61. {$define GDB_V6}
  62. {$define GDB_NEEDS_NO_ERROR_INIT}
  63. {$endif def GDB_V605}
  64. { 6.6.x }
  65. {$ifdef GDB_V606}
  66. {$info using gdb 6.6.x}
  67. {$define GDB_V6}
  68. {$define GDB_HAS_DB_COMMANDS}
  69. {$define GDB_USES_BP_LOCATION}
  70. {$define GDB_NEEDS_NO_ERROR_INIT}
  71. {$define GDB_USES_EXPAT_LIB}
  72. {$define GDB_HAS_DEBUG_FILE_DIRECTORY}
  73. {$endif def GDB_V606}
  74. { 6.7.x }
  75. {$ifdef GDB_V607}
  76. {$info using gdb 6.7.x}
  77. {$define GDB_V6}
  78. {$define GDB_HAS_DB_COMMANDS}
  79. {$define GDB_USES_BP_LOCATION}
  80. {$define GDB_NEEDS_NO_ERROR_INIT}
  81. {$define GDB_USES_EXPAT_LIB}
  82. {$define GDB_HAS_DEBUG_FILE_DIRECTORY}
  83. {$endif def GDB_V607}
  84. { 6.8.x }
  85. {$ifdef GDB_V608}
  86. {$info using gdb 6.8.x}
  87. {$define GDB_V6}
  88. {$define GDB_HAS_DB_COMMANDS}
  89. {$define GDB_USES_BP_LOCATION}
  90. {$define GDB_BP_LOCATION_HAS_GLOBAL_NEXT}
  91. {$define GDB_NEEDS_NO_ERROR_INIT}
  92. {$define GDB_USES_EXPAT_LIB}
  93. {$define GDB_HAS_DEBUG_FILE_DIRECTORY}
  94. {$define GDB_USES_LIBDECNUMBER}
  95. // {$define GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED}
  96. {$define GDB_HAS_BP_NONE}
  97. {$endif def GDB_V608}
  98. { 7.3.x }
  99. {$ifdef GDB_V703}
  100. {$info using gdb 7.3.x}
  101. {$define GDB_V7}
  102. {$define GDB_BP_LOCATION_HAS_GDBARCH}
  103. {$define GDB_HAS_PROGRAM_SPACE}
  104. {$endif def GDB_V702}
  105. { 7.2.x }
  106. {$ifdef GDB_V702}
  107. {$info using gdb 7.2.x}
  108. {$define GDB_V7}
  109. {$define GDB_BP_LOCATION_HAS_GDBARCH}
  110. {$define GDB_HAS_PROGRAM_SPACE}
  111. {$endif def GDB_V702}
  112. { 7.1.x }
  113. {$ifdef GDB_V701}
  114. {$info using gdb 7.1.x}
  115. {$define GDB_V7}
  116. {$define GDB_BP_LOCATION_HAS_GDBARCH}
  117. {$define GDB_HAS_PROGRAM_SPACE}
  118. {$endif def GDB_V701}
  119. { 7.0.x }
  120. {$ifdef GDB_V700}
  121. {$info using gdb 7.0.x}
  122. {$define GDB_V7}
  123. {$ifdef GDB_CVS}
  124. {$define GDB_BP_LOCATION_HAS_GDBARCH}
  125. {$define GDB_HAS_PROGRAM_SPACE}
  126. {$endif GDB_CVS}
  127. {$endif def GDB_V700}
  128. {$ifdef GDB_V7}
  129. {$define GDB_V6}
  130. {$define GDB_HAS_DB_COMMANDS}
  131. {$define GDB_USES_BP_LOCATION}
  132. {$define GDB_BP_LOCATION_HAS_GLOBAL_NEXT}
  133. {$define GDB_BP_LOCATION_HAS_GDBARCH}
  134. {$define GDB_NEEDS_NO_ERROR_INIT}
  135. {$define GDB_USES_EXPAT_LIB}
  136. {$define GDB_USES_LIBDECNUMBER}
  137. {$define GDB_USES_LIBINTL}
  138. {$ifndef GDB_DISABLE_PYTHON}
  139. {$define GDB_USES_LIBPYTHON}
  140. {$endif}
  141. {$define GDB_HAS_DEBUG_FILE_DIRECTORY}
  142. {$define GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED}
  143. {$define GDB_TARGET_CLOSE_HAS_PTARGET_ARG}
  144. {$define GDB_HAS_BP_NONE}
  145. {$endif def GDB_V7}
  146. {$ifdef GDB_V6}
  147. {$define GDB_HAS_SYSROOT}
  148. {$define GDB_HAS_DB_COMMANDS}
  149. {$define GDB_SYMTAB_HAS_MACROS}
  150. {$define GDB_INIT_HAS_ARGV0}
  151. {$endif GDB_V6}
  152. {$ifdef GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED}
  153. {$define DO_NOT_USE_CBPH}
  154. {$endif}
  155. { GDB has a simulator for powerpc CPU
  156. it is integrated into GDB by default }
  157. {$ifdef cpupowerpc}
  158. {$define GDB_HAS_SIM}
  159. {$endif cpupowerpc}
  160. {$ifdef Solaris}
  161. {$ifdef Sparc}
  162. { Sparc/i386 solaris gdb also supports 64bit mode, thus
  163. CORE_ADDR is 8-byte long }
  164. {$define GDB_CORE_ADDR_FORCE_64BITS}
  165. {$endif Sparc}
  166. {$ifdef i386}
  167. {$define GDB_CORE_ADDR_FORCE_64BITS}
  168. {$endif i386}
  169. {$endif Solaris}
  170. {$ifdef go32v2}
  171. {$ifdef NotImplemented}
  172. {$undef NotImplemented}
  173. {$LINKLIB gdb}
  174. {$ifdef GDB_HAS_SIM}
  175. {$LINKLIB sim}
  176. {$endif GDB_HAS_SIM}
  177. {$LINKLIB bfd}
  178. {$LINKLIB readline}
  179. {$LINKLIB opcodes}
  180. {$LINKLIB history}
  181. {$LINKLIB iberty}
  182. {$ifdef GDB_USES_LIBDECNUMBER}
  183. {$LINKLIB decnumber}
  184. {$endif GDB_USES_LIBDECNUMBER}
  185. {$ifdef GDB_USES_EXPAT_LIB}
  186. {$LINKLIB expat}
  187. {$endif GDB_USES_EXPAT_LIB}
  188. {$ifdef GDB_USES_LIBPYTHON}
  189. {$LINKLIB python}
  190. {$endif GDB_USES_LIBPYTHON}
  191. {$ifndef GDB_DISABLE_INTL}
  192. {$LINKLIB intl}
  193. {$endif ndef GDB_DISABLE_INTL}
  194. {$endif NotImplemented}
  195. {$LINKLIB dbg}
  196. {$LINKLIB c}
  197. {$endif go32v2}
  198. {$ifdef linux}
  199. {$ifdef NotImplemented}
  200. {$undef NotImplemented}
  201. {$LINKLIB libgdb.a}
  202. {$ifdef GDB_HAS_SIM}
  203. {$LINKLIB libsim.a}
  204. {$endif GDB_HAS_SIM}
  205. {$LINKLIB libbfd.a}
  206. {$LINKLIB libreadline.a}
  207. {$LINKLIB libopcodes.a}
  208. {$LINKLIB libhistory.a}
  209. {$LINKLIB libiberty.a}
  210. {$ifdef GDB_USES_LIBDECNUMBER}
  211. {$LINKLIB decnumber}
  212. {$endif GDB_USES_LIBDECNUMBER}
  213. {$ifdef GDB_USES_EXPAT_LIB}
  214. {$LINKLIB expat}
  215. {$endif GDB_USES_EXPAT_LIB}
  216. {$ifdef GDB_USES_LIBPYTHON}
  217. {$LINKLIB python}
  218. {$endif GDB_USES_LIBPYTHON}
  219. {$LINKLIB ncurses}
  220. {$endif NotImplemented}
  221. {$LINKLIB m}
  222. {$LINKLIB dl}
  223. {$LINKLIB c}
  224. {$LINKLIB gcc}
  225. {$endif linux}
  226. {$ifdef freebsd}
  227. {$ifdef NotImplemented}
  228. {$ifdef FreeBSD5} //5.4+ ?
  229. {$linklib kvm}
  230. {$endif}
  231. {$undef NotImplemented}
  232. {$LINKLIB gdb}
  233. {$ifdef GDB_HAS_SIM}
  234. {$LINKLIB sim}
  235. {$endif GDB_HAS_SIM}
  236. {$LINKLIB bfd}
  237. {$LINKLIB readline}
  238. {$LINKLIB opcodes}
  239. {$LINKLIB history}
  240. {$LINKLIB iberty}
  241. {$LINKLIB ncurses}
  242. {$LINKLIB m}
  243. {$LINKLIB iberty}
  244. {$ifndef GDB_DISABLE_INTL}
  245. {$LINKLIB intl}
  246. {$endif ndef GDB_DISABLE_INTL}
  247. {$ifdef GDB_USES_LIBDECNUMBER}
  248. {$LINKLIB decnumber}
  249. {$endif GDB_USES_LIBDECNUMBER}
  250. { does not seem to exist on netbsd LINKLIB dl,
  251. but I use GDB CVS snapshots for the *BSDs}
  252. {$ifdef GDB_USES_EXPAT_LIB}
  253. {$LINKLIB expat}
  254. {$endif GDB_USES_EXPAT_LIB}
  255. {$ifdef GDB_USES_LIBPYTHON}
  256. {$LINKLIB python}
  257. {$endif GDB_USES_LIBPYTHON}
  258. {$endif NotImplemented}
  259. {$LINKLIB c}
  260. {$LINKLIB gcc}
  261. {$endif freebsd}
  262. {$ifdef netbsd}
  263. {$ifdef NotImplemented}
  264. {$undef NotImplemented}
  265. {$LINKLIB gdb}
  266. {$ifdef GDB_HAS_SIM}
  267. {$LINKLIB sim}
  268. {$endif GDB_HAS_SIM}
  269. {$LINKLIB bfd}
  270. {$LINKLIB readline}
  271. {$LINKLIB opcodes}
  272. {$LINKLIB history}
  273. {$LINKLIB iberty}
  274. {$LINKLIB ncurses}
  275. {$LINKLIB m}
  276. {$LINKLIB iberty}
  277. {$LINKLIB intl}
  278. {$ifdef GDB_USES_LIBDECNUMBER}
  279. {$LINKLIB decnumber}
  280. {$endif GDB_USES_LIBDECNUMBER}
  281. {$ifdef GDB_USES_EXPAT_LIB}
  282. {$LINKLIB expat}
  283. {$endif GDB_USES_EXPAT_LIB}
  284. {$ifdef GDB_USES_LIBPYTHON}
  285. {$LINKLIB python}
  286. {$endif GDB_USES_LIBPYTHON}
  287. { does not seem to exist on netbsd LINKLIB dl}
  288. {$endif NotImplemented}
  289. {$LINKLIB c}
  290. {$LINKLIB gcc}
  291. {$endif netbsd}
  292. {$ifdef solaris}
  293. {$ifdef NotImplemented}
  294. {$undef NotImplemented}
  295. {$LINKLIB gdb}
  296. {$ifdef GDB_HAS_SIM}
  297. {$LINKLIB sim}
  298. {$endif GDB_HAS_SIM}
  299. {$LINKLIB bfd}
  300. {$LINKLIB readline}
  301. {$LINKLIB opcodes}
  302. {$LINKLIB history}
  303. {$LINKLIB iberty}
  304. {$LINKLIB curses}
  305. {$LINKLIB m}
  306. {$LINKLIB iberty}
  307. {$LINKLIB intl}
  308. {$ifdef GDB_USES_LIBDECNUMBER}
  309. {$LINKLIB decnumber}
  310. {$endif GDB_USES_LIBDECNUMBER}
  311. {$ifdef GDB_USES_EXPAT_LIB}
  312. {$LINKLIB expat}
  313. {$endif GDB_USES_EXPAT_LIB}
  314. {$ifdef GDB_USES_LIBPYTHON}
  315. {$LINKLIB python}
  316. {$endif GDB_USES_LIBPYTHON}
  317. {$endif NotImplemented}
  318. {$LINKLIB dl}
  319. {$LINKLIB socket}
  320. {$LINKLIB nsl}
  321. {$LINKLIB c}
  322. {$endif solaris}
  323. {$ifdef openbsd}
  324. {$ifdef NotImplemented}
  325. {$undef NotImplemented}
  326. {$LINKLIB gdb}
  327. {$ifdef GDB_HAS_SIM}
  328. {$LINKLIB sim}
  329. {$endif GDB_HAS_SIM}
  330. {$LINKLIB bfd}
  331. {$LINKLIB readline}
  332. {$LINKLIB opcodes}
  333. {$LINKLIB history}
  334. {$LINKLIB iberty}
  335. {$LINKLIB ncurses}
  336. {$LINKLIB m}
  337. {$LINKLIB iberty}
  338. {$ifndef GDB_DISABLE_INTL}
  339. {$LINKLIB intl}
  340. {$endif ndef GDB_DISABLE_INTL}
  341. {$ifdef GDB_USES_LIBDECNUMBER}
  342. {$LINKLIB decnumber}
  343. {$endif GDB_USES_LIBDECNUMBER}
  344. {$ifdef GDB_USES_EXPAT_LIB}
  345. {$LINKLIB expat}
  346. {$endif GDB_USES_EXPAT_LIB}
  347. {$ifdef GDB_USES_LIBPYTHON}
  348. {$LINKLIB python}
  349. {$endif GDB_USES_LIBPYTHON}
  350. { does not seem to exist on netbsd LINKLIB dl}
  351. {$endif NotImplemented}
  352. {$LINKLIB c}
  353. {$LINKLIB gcc}
  354. {$endif netbsd}
  355. {$ifdef win32}
  356. {$ifdef NotImplemented}
  357. {$undef NotImplemented}
  358. {$LINKLIB libgdb.a}
  359. {$ifdef GDB_HAS_SIM}
  360. {$LINKLIB libsim.a}
  361. {$endif GDB_HAS_SIM}
  362. {$LINKLIB libbfd.a}
  363. {$LINKLIB libreadline.a}
  364. {$LINKLIB libopcodes.a}
  365. {$LINKLIB libhistory.a}
  366. {$LINKLIB libiberty.a}
  367. {$ifdef USE_MINGW_GDB}
  368. {$LINKLIB libdecnumber.a}
  369. {$ifdef GDB_USES_LIBDECNUMBER}
  370. {$LINKLIB decnumber}
  371. {$endif GDB_USES_LIBDECNUMBER}
  372. {$ifdef GDB_USES_EXPAT_LIB}
  373. {$LINKLIB expat}
  374. {$endif GDB_USES_EXPAT_LIB}
  375. {$ifdef GDB_USES_LIBPYTHON}
  376. {$LINKLIB python}
  377. {$endif GDB_USES_LIBPYTHON}
  378. {$else not USE_MINGW_GDB}
  379. {$LINKLIB libiconv.a}
  380. {$LINKLIB libncurses.a}
  381. {$ifdef GDB_USES_LIBDECNUMBER}
  382. {$LINKLIB decnumber}
  383. {$endif GDB_USES_LIBDECNUMBER}
  384. {$ifdef GDB_USES_EXPAT_LIB}
  385. {$LINKLIB expat}
  386. {$endif GDB_USES_EXPAT_LIB}
  387. {$ifdef GDB_USES_LIBPYTHON}
  388. {$LINKLIB python}
  389. {$endif GDB_USES_LIBPYTHON}
  390. {$endif not USE_MINGW_GDB}
  391. {$endif NotImplemented}
  392. {$ifdef USE_MINGW_GDB}
  393. {$LINKLIB libm.a}
  394. {$LINKLIB libmoldname.a}
  395. {$LINKLIB libgcc.a}
  396. {$LINKLIB libws2_32.a}
  397. {$LINKLIB libmingwex.a}
  398. {$LINKLIB libmingw32.a}
  399. {$LINKLIB libmsvcrt.a}
  400. {$else not USE_MINGW_GDB}
  401. {$LINKLIB gcc}
  402. {$LINKLIB cygwin} { alias of libm.a and libc.a }
  403. {$LINKLIB libintl.a}
  404. {$LINKLIB imagehlp}
  405. {$endif not USE_MINGW_GDB}
  406. {$LINKLIB kernel32}
  407. {$LINKLIB user32}
  408. {$endif win32}
  409. {$ifdef win64}
  410. {$ifdef NotImplemented}
  411. {$undef NotImplemented}
  412. {$LINKLIB libgdb.a}
  413. {$ifdef GDB_HAS_SIM}
  414. {$LINKLIB libsim.a}
  415. {$endif GDB_HAS_SIM}
  416. {$LINKLIB libbfd.a}
  417. {$LINKLIB libreadline.a}
  418. {$LINKLIB libopcodes.a}
  419. {$LINKLIB libhistory.a}
  420. {$LINKLIB libiberty.a}
  421. {$LINKLIB libintl.a}
  422. {$LINKLIB libdecnumber.a}
  423. {$ifdef GDB_USES_LIBDECNUMBER}
  424. {$LINKLIB decnumber}
  425. {$endif GDB_USES_LIBDECNUMBER}
  426. {$ifdef GDB_USES_EXPAT_LIB}
  427. {$LINKLIB expat}
  428. {$endif GDB_USES_EXPAT_LIB}
  429. {$ifdef GDB_USES_LIBPYTHON}
  430. {$LINKLIB python}
  431. {$endif GDB_USES_LIBPYTHON}
  432. {$endif NotImplemented}
  433. {$LINKLIB libm.a}
  434. {$LINKLIB libmoldname.a}
  435. {$LINKLIB libws2_32.a}
  436. {$LINKLIB libmingwex.a}
  437. {$LINKLIB libmingw32.a}
  438. {$LINKLIB libmsvcrt.a}
  439. {$LINKLIB libgcc.a}
  440. {$LINKLIB libws2_32.a}
  441. {$LINKLIB kernel32}
  442. {$LINKLIB user32}
  443. {$endif win64}
  444. {$ifdef beos}
  445. {$ifdef NotImplemented}
  446. { still need some work... stollen from netbsd}
  447. {$undef NotImplemented}
  448. {$LINKLIB gdb}
  449. {$ifdef GDB_HAS_SIM}
  450. {$LINKLIB sim}
  451. {$endif GDB_HAS_SIM}
  452. {$LINKLIB bfd}
  453. {$LINKLIB readline}
  454. {$LINKLIB opcodes}
  455. { $ LINKLIB history}
  456. {$LINKLIB iberty}
  457. {$LINKLIB ncurses}
  458. { $ LINKLIB m} // include in libroot under BeOS
  459. {$ifndef GDB_DISABLE_INTL}
  460. {$LINKLIB intl}
  461. {$endif ndef GDB_DISABLE_INTL}
  462. {$ifdef GDB_USES_LIBDECNUMBER}
  463. {$LINKLIB decnumber}
  464. {$endif GDB_USES_LIBDECNUMBER}
  465. {$ifdef GDB_USES_EXPAT_LIB}
  466. {$LINKLIB expat}
  467. {$endif GDB_USES_EXPAT_LIB}
  468. {$ifdef GDB_USES_LIBPYTHON}
  469. {$LINKLIB python}
  470. {$endif GDB_USES_LIBPYTHON}
  471. {$endif NotImplemented}
  472. { does not seem to exist on netbsd LINKLIB dl}
  473. { $ LINKLIB c} // This is libroot under BeOS, and always linked
  474. {$LINKLIB debug}
  475. {$LINKLIB gcc}
  476. {$endif beos}
  477. {$ifdef go32v2}
  478. {$define supportexceptions}
  479. {$endif go32v2}
  480. {$ifdef unix}
  481. {$define supportexceptions}
  482. {$endif unix}
  483. {$ifdef CROSSGDB}
  484. { do we need something special if cross GDB? }
  485. {$endif CROSSGDB}
  486. {$ifdef NotImplemented}
  487. {$fatal This OS is not yet supported !!!}
  488. {$endif NotImplemented}
  489. {$packrecords C}
  490. type
  491. psyminfo=^tsyminfo;
  492. tsyminfo=record
  493. address : ptrint;
  494. fname : pchar;
  495. line : longint;
  496. funcname : pchar;
  497. offset : ptrint;
  498. end;
  499. tframeentry = object
  500. file_name : pchar;
  501. function_name : pchar;
  502. args : pchar;
  503. line_number : longint;
  504. address : ptrint;
  505. level : longint;
  506. constructor init;
  507. destructor done;
  508. procedure reset;
  509. procedure clear;
  510. end;
  511. pframeentry=^tframeentry;
  512. ppframeentry=^pframeentry;
  513. { needed for handles }
  514. {not anymore I textrec.inc}
  515. const
  516. k=1;
  517. type
  518. {$if defined(CPUSPARC) and defined(LINUX)}
  519. {$define GDB_CORE_ADDR_FORCE_64BITS}
  520. {$endif}
  521. {$ifdef GDB_CORE_ADDR_FORCE_64BITS}
  522. CORE_ADDR = qword;
  523. {$else}
  524. CORE_ADDR = ptrint; { might be target dependent PM }
  525. {$endif}
  526. streamtype = (afile,astring);
  527. C_FILE = ptrint; { at least under DJGPP }
  528. P_C_FILE = ^C_FILE;
  529. type
  530. pui_file = ^ui_file;
  531. ui_file_flush_ftype = procedure(stream : pui_file);cdecl;
  532. ui_file_write_ftype = procedure(stream : pui_file;buf : pchar;len : longint);cdecl;
  533. ui_file_fputs_ftype = procedure(buf : pchar; stream : pui_file);cdecl;
  534. ui_file_delete_ftype = procedure(stream : pui_file);cdecl;
  535. ui_file_isatty_ftype = function(stream : pui_file) : longbool;cdecl;
  536. ui_file_rewind_ftype = procedure(stream : pui_file);cdecl;
  537. ui_file_put_method_ftype = procedure(var _object; buffer : pchar;length_buffer : longint);cdecl;
  538. ui_file_put_ftype = procedure(stream : pui_file;method : ui_file_put_method_ftype;var context);cdecl;
  539. {$ifdef GDB_V6}
  540. ui_file_read_ftype = function (stream : pui_file; buffer : pchar; len : longint):longint;cdecl;
  541. {$endif}
  542. ui_file = record
  543. magic : plongint;
  544. to_flush : ui_file_flush_ftype;
  545. to_write : ui_file_write_ftype;
  546. to_fputs : ui_file_fputs_ftype;
  547. {$ifdef GDB_V6}
  548. to_read : ui_file_read_ftype;
  549. {$endif}
  550. to_delete : ui_file_delete_ftype;
  551. to_isatty : ui_file_isatty_ftype;
  552. to_rewind : ui_file_rewind_ftype;
  553. to_put : ui_file_put_ftype;
  554. to_data : pointer;
  555. end;
  556. { used to delete stdio_ui_file gdb_stdout and gdb_stderr }
  557. procedure ui_file_delete(stream : pui_file);cdecl;external;
  558. { used to recreate gdb_stdout and gdb_stderr as memory streams }
  559. function mem_fileopen : pui_file;cdecl;external;
  560. { used to change the write procvar to ours }
  561. procedure set_ui_file_write(stream : pui_file;write : ui_file_write_ftype);cdecl;external;
  562. type
  563. (* struct ptid
  564. {
  565. /* Process id */
  566. int pid;
  567. /* Lightweight process id */
  568. long lwp;
  569. /* Thread id */
  570. long tid;
  571. }; *)
  572. pinferior_ptid = ^tinferior_ptid;
  573. tinferior_ptid = record
  574. pid : longint{C int};
  575. lwp : ptrint{ C long};
  576. tid : ptrint{ C long};
  577. end;
  578. {$ifdef win32}
  579. type
  580. { from sys/reent.h
  581. real structure is bigger but only std.. are wanted here PM }
  582. REENT = record
  583. err : longint;
  584. stdin,stdout,stderr : P_C_FILE;
  585. end;
  586. PREENT = ^REENT;
  587. var _impure_ptr : PREENT;cvar;external;
  588. {$endif win32}
  589. type
  590. tgdbbuffer=object
  591. buf : pchar;
  592. size,
  593. idx : longint;
  594. gdb_file : pui_file;
  595. constructor Init;
  596. destructor Done;
  597. procedure Reset;
  598. procedure Resize(nsize : longint);
  599. procedure Append(p:pchar);
  600. procedure lappend(p:pchar;len : longint);
  601. end;
  602. pgdbinterface=^tgdbinterface;
  603. tgdbinterface=object
  604. gdberrorbuf,
  605. gdboutputbuf : tgdbbuffer;
  606. got_error,
  607. reset_command,
  608. call_reset,
  609. signaled,
  610. Debuggee_started : boolean;
  611. { frames and frame info while recording a frame }
  612. frames : ppframeentry;
  613. frame_size,
  614. frame_count : longint;
  615. record_frames,
  616. frame_begin_seen : boolean;
  617. frame_level,
  618. command_level,
  619. stop_breakpoint_number,
  620. current_line_number,
  621. signal_start,
  622. signal_end,
  623. signal_name_start,
  624. signal_name_end,
  625. error_start,
  626. error_end,
  627. function_start,
  628. function_end,
  629. args_start,
  630. args_end,
  631. file_start,
  632. file_end,
  633. line_start,
  634. line_end : longint;
  635. signal_name,
  636. signal_string : pchar;
  637. current_address,
  638. current_pc : CORE_ADDR;
  639. { breakpoint }
  640. last_breakpoint_number,
  641. last_breakpoint_address,
  642. last_breakpoint_line : longint;
  643. last_breakpoint_file : pchar;
  644. invalid_breakpoint_line : boolean;
  645. user_screen_shown,
  646. switch_to_user : boolean;
  647. { init }
  648. constructor init;
  649. destructor done;
  650. { Lowlevel }
  651. function error:boolean;
  652. function error_num:longint;
  653. procedure gdb_command(const s:string);
  654. procedure gdb__init;
  655. procedure gdb_done;
  656. procedure resize_frames;
  657. function add_frameentry:pframeentry;
  658. function get_frameentry(level : longint):pframeentry;
  659. function get_current_frame : ptrint;
  660. function set_current_frame(level : longint) : boolean;
  661. procedure clear_frames;
  662. { Highlevel }
  663. procedure GetAddrSyminfo(addr:ptrint;var si:tsyminfo);
  664. procedure SelectSourceline(fn:pchar;line:longint);
  665. procedure StartSession;
  666. procedure BreakSession;
  667. procedure EndSession(code:longint);
  668. procedure DebuggerScreen;
  669. procedure UserScreen;
  670. procedure FlushAll; virtual;
  671. function Query(question : pchar; args : pchar) : longint; virtual;
  672. { Hooks }
  673. procedure DoSelectSourceline(const fn:string;line:longint);virtual;
  674. procedure DoStartSession;virtual;
  675. procedure DoBreakSession;virtual;
  676. procedure DoEndSession(code:longint);virtual;
  677. procedure DoUserSignal;virtual;
  678. procedure DoDebuggerScreen;virtual;
  679. procedure DoUserScreen;virtual;
  680. function AllowQuit : boolean;virtual;
  681. end;
  682. const
  683. use_gdb_file : boolean = false;
  684. var
  685. curr_gdb : pgdbinterface;
  686. gdb_file : text;
  687. inferior_ptid : tinferior_ptid;cvar;external;
  688. function GDBVersion : string;
  689. function inferior_pid : longint;
  690. {$ifdef GDB_V6}
  691. type
  692. ui_out = pointer;
  693. var
  694. uiout : ui_out;cvar;external;
  695. function cli_out_new (stream : pui_file):ui_out;cdecl;external;
  696. {$endif}
  697. {$ifdef go32v2}
  698. { needed to be sure %fs contains the DOS memory selector
  699. used in Mem[] code PM }
  700. procedure reload_fs;
  701. {$endif go32v2}
  702. implementation
  703. uses
  704. {$ifdef win32}
  705. {$ifdef USE_MINGW_GDB}
  706. {$else not USE_MINGW_GDB}
  707. initc,
  708. {$endif not USE_MINGW_GDB}
  709. {$endif win32}
  710. {$ifdef unix}
  711. baseunix,
  712. {$endif}
  713. {$ifdef go32v2}
  714. go32,
  715. dpmiexcp,
  716. initc,
  717. {$endif}
  718. strings;
  719. {*****************************************************************************
  720. Types used by libgdb.a
  721. *****************************************************************************}
  722. {$ifdef go32v2}
  723. type
  724. jmp_buf = dpmi_jmp_buf;
  725. pjmp_buf = pdpmi_jmp_buf;
  726. function setjmp(var rec : jmp_buf) : longint;cdecl;external;
  727. function malloc(size : longint) : pointer;cdecl;external;
  728. procedure longjmp(var rec : jmp_buf;return_value : longint);cdecl;external;
  729. procedure reload_fs;assembler;
  730. asm
  731. movw dosmemselector,%ax
  732. movw %ax,%fs
  733. end['EAX'];
  734. {$endif}
  735. {$ifdef win32}
  736. type
  737. jmp_buf = record
  738. case byte of
  739. 0 :
  740. { greatest value found in cygwin machine/setjmp.h for i386 }
  741. { mingw uses int[16] C type for i386 }
  742. (unknown_field : array [1..15] of longint;);
  743. 1 :
  744. (eax,ebx,ecx,edx : longint;
  745. esi,edi,ebp,esp,eip : longint;);
  746. end;
  747. pjmp_buf = ^jmp_buf;
  748. {$ifdef USE_MINGW_GDB}
  749. { for obscure reasons, longjmp and _setjmp are defined in mingw32 libmsvcrt.a }
  750. function _setjmp(var rec : jmp_buf) : longint; cdecl; external;
  751. procedure longjmp(var rec : jmp_buf;return_value : longint); cdecl; external;
  752. function setjmp(var rec : jmp_buf) : longint;
  753. begin
  754. setjmp:=_setjmp(rec);
  755. end;
  756. {$else not USE_MINGW_GDB}
  757. function setjmp(var rec : jmp_buf) : longint;cdecl;external;
  758. procedure longjmp(var rec : jmp_buf;return_value : longint);cdecl;external;
  759. {$endif not USE_MINGW_GDB}
  760. {$ifndef supportexceptions}
  761. type
  762. { I don't think FPC would accept that
  763. the funcvar return type is the funcvar type itself ! PM }
  764. SignalHandler = Procedure(Sig : LongInt);cdecl;
  765. function signal(sig : longint;new_signal : SignalHandler) : SignalHandler;cdecl;external;
  766. {define supportexceptions not yet working }
  767. {$endif now exceptions are supported for win32}
  768. {$endif win32}
  769. type
  770. pCORE_ADDR = ^CORE_ADDR;
  771. pblock = ^block;
  772. tlanguage = (language_unknown,language_auto,language_c,
  773. language_cplus,language_java,language_chill,
  774. language_fortran,language_m2,language_asm,
  775. language_scm,language_pascal,language_objc);
  776. bptype = (
  777. {$ifdef GDB_HAS_BP_NONE}
  778. bp_none,
  779. {$endif GDB_HAS_BP_NONE}
  780. bp_breakpoint,bp_hardware_breakpoint,
  781. bp_until,bp_finish,bp_watchpoint,bp_hardware_watchpoint,
  782. bp_read_watchpoint,bp_access_watchpoint,
  783. bp_longjmp,bp_longjmp_resume,bp_step_resume,
  784. bp_through_sigtramp,bp_watchpoint_scope,
  785. bp_call_dummy,bp_shlib_event);
  786. tenable = (disabled,enabled,shlib_disabled);
  787. bpdisp = (del,del_at_next_stop,disable,donttouch);
  788. pbp_location = ^bp_location;
  789. bp_loc_type = (bp_loc_software_breakpoint, bp_loc_hardware_breakpoint,
  790. bp_loc_hardware_watchpoint, bp_loc_other);
  791. target_hw_bp_type = (hw_write, hw_read, hw_access, hw_execute);
  792. {$PACKRECORDS 4}
  793. pbreakpoint = ^breakpoint;
  794. breakpoint = record
  795. next : pbreakpoint;
  796. typ : bptype;
  797. enable : tenable;
  798. disposition : bpdisp;
  799. number : longint;
  800. {$ifdef GDB_USES_BP_LOCATION}
  801. loc : pbp_location;
  802. {$else not GDB_USES_BP_LOCATION}
  803. address : CORE_ADDR;
  804. {$endif not GDB_USES_BP_LOCATION}
  805. line_number : longint;
  806. source_file : pchar;
  807. silent : byte;
  808. ignore_count : longint;
  809. {$ifndef GDB_USES_BP_LOCATION}
  810. shadow_contents : array[0..15] of char;
  811. inserted : char;
  812. duplicate : char;
  813. {$endif not GDB_USES_BP_LOCATION}
  814. commands : pointer; {^command_line}
  815. frame : CORE_ADDR;
  816. cond : pointer; {^expression}
  817. addr_string : ^char;
  818. language : tlanguage;
  819. input_radix : longint;
  820. cond_string : ^char;
  821. exp_string : ^char;
  822. exp : pointer; {^expression}
  823. exp_valid_block : pblock; {^block;}
  824. val : pointer; {value_ptr;}
  825. val_chain : pointer; {value_ptr;}
  826. related_breakpoint : pbreakpoint;
  827. watchpoint_frame : CORE_ADDR;
  828. thread : longint;
  829. hit_count : longint;
  830. section : pointer; {^asection}
  831. end;
  832. bp_target_info = record
  833. placed_address_space : pointer;{paddress_space;}
  834. placed_address : CORE_ADDR;
  835. shadow_contents : array[0..15] of char;
  836. shadow_len : longint;
  837. placed_size : longint;
  838. end;
  839. bp_location = record
  840. next : pbp_location;
  841. {$ifdef GDB_BP_LOCATION_HAS_GLOBAL_NEXT}
  842. global_next : pbp_location;
  843. {$endif GDB_BP_LOCATION_HAS_GLOBAL_NEXT}
  844. loc_type : bp_loc_type;
  845. owner : pbreakpoint;
  846. {$ifdef GDB_BP_LOCATION_HAS_GLOBAL_NEXT}
  847. cond : pointer;{pexpression;}
  848. shlib_disabled : byte;
  849. enabled : byte;
  850. {$endif GDB_BP_LOCATION_HAS_GLOBAL_NEXT}
  851. inserted : byte;
  852. duplicate : byte;
  853. {$ifdef GDB_BP_LOCATION_HAS_GDBARCH}
  854. gdbarch : pointer;{pgdbarch;}
  855. {$endif GDB_BP_LOCATION_HAS_GDBARCH}
  856. {$ifdef GDB_HAS_PROGRAM_SPACE}
  857. pspace : pointer;{pprogram_space;}
  858. {$endif GDB_HAS_PROGRAM_SPACE}
  859. address : CORE_ADDR;
  860. {$ifdef GDB_BP_LOCATION_HAS_GLOBAL_NEXT}
  861. length : longint;
  862. watchpoint_type : target_hw_bp_type;
  863. {$endif GDB_BP_LOCATION_HAS_GLOBAL_NEXT}
  864. section : pointer;{pobj_section;}
  865. requested_address : CORE_ADDR;
  866. {$ifdef GDB_BP_LOCATION_HAS_GLOBAL_NEXT}
  867. function_name : ^char;
  868. {$endif GDB_BP_LOCATION_HAS_GLOBAL_NEXT}
  869. target_info : bp_target_info;
  870. overlay_target_info : bp_target_info;
  871. events_till_retirement : longint;
  872. end;
  873. tfreecode=(free_nothing,free_contents,free_linetable);
  874. psymtab = ^symtab;
  875. symtab = record
  876. next : psymtab;
  877. blockvector : pointer; {^blockvector;}
  878. linetable : pointer; {^linetable;}
  879. block_line_section : longint;
  880. primary : longint;
  881. {$ifdef GDB_SYMTAB_HAS_MACROS}
  882. { new field added in the middle :( }
  883. macro_table : pointer;
  884. {$endif GDB_SYMTAB_HAS_MACROS}
  885. filename : pchar;
  886. dirname : pchar;
  887. free_code : tfreecode;
  888. free_ptr : pchar;
  889. nlines : longint;
  890. line_charpos : ^longint;
  891. language : tlanguage;
  892. Debugformat : pchar;
  893. version : pchar;
  894. fullname : pchar;
  895. objfile : pointer; {^objfile;}
  896. end;
  897. psymtab_and_line = ^symtab_and_line;
  898. symtab_and_line = record
  899. {$ifdef GDB_HAS_PROGRAM_SPACE}
  900. pspace : pointer;
  901. {$endif GDB_HAS_PROGRAM_SPACE}
  902. symtab : psymtab;
  903. section : pointer; {^asection;}
  904. line : longint;
  905. pc : CORE_ADDR;
  906. _end : CORE_ADDR;
  907. { Added fields, not used in gdbint,
  908. but necessary to allocated enough space to
  909. avoid stack memory corruption PM }
  910. explicit_pc : longint;
  911. explicit_line : longint;
  912. end;
  913. symtabs_and_lines = record
  914. sals : ^symtab_and_line;
  915. nelts : longint;
  916. end;
  917. psymbol = ^symbol;
  918. pminimal_symbol = ^minimal_symbol;
  919. general_symbol_info = record
  920. (* Name of the symbol. This is a required field. Storage for the name is
  921. allocated on the psymbol_obstack or symbol_obstack for the associated
  922. objfile. *)
  923. _name : pchar;
  924. (* Value of the symbol. Which member of this union to use, and what
  925. it means, depends on what kind of symbol this is and its
  926. SYMBOL_CLASS. See comments there for more details. All of these
  927. are in host byte order (though what they point to might be in
  928. target byte order, e.g. LOC_CONST_BYTES). *)
  929. value : record
  930. case integer of
  931. (* The fact that this is a long not a LONGEST mainly limits the
  932. range of a LOC_CONST. Since LOC_CONST_BYTES exists, I'm not
  933. sure that is a big deal. *)
  934. 0 : (ivalue : longint;);
  935. 1 : (block : pblock;);
  936. 2 : (bytes : pchar;);
  937. 3 : (address : CORE_ADDR;);
  938. (* for opaque typedef struct chain *)
  939. 4 : (chain : psymbol;);
  940. end;
  941. (* Since one and only one language can apply, wrap the language specific
  942. information inside a union. *)
  943. (* union
  944. {
  945. struct cplus_specific /* For C++ */
  946. /* and Java */
  947. {
  948. char *demangled_name;
  949. } cplus_specific;
  950. struct chill_specific /* For Chill */
  951. {
  952. char *demangled_name;
  953. } chill_specific;
  954. } language_specific; *)
  955. demangled_name : pchar;
  956. (* Record the source code language that applies to this symbol.
  957. This is used to select one of the fields from the language specific
  958. union above. *)
  959. language : tlanguage;
  960. (* Which section is this symbol in? This is an index into
  961. section_offsets for this objfile. Negative means that the symbol
  962. does not get relocated relative to a section.
  963. Disclaimer: currently this is just used for xcoff, so don't
  964. expect all symbol-reading code to set it correctly (the ELF code
  965. also tries to set it correctly). *)
  966. section : word;
  967. (* The bfd section associated with this symbol. *)
  968. bfd_section : pointer {^asection};
  969. end; { of general_symbol_info record declaration }
  970. tminimal_symbol_type =
  971. (
  972. mst_unknown := 0, (* Unknown type, the default *)
  973. mst_text, (* Generally executable instructions *)
  974. mst_data, (* Generally initialized data *)
  975. mst_bss, (* Generally uninitialized data *)
  976. mst_abs, (* Generally absolute (nonrelocatable) *)
  977. (* GDB uses mst_solib_trampoline for the start address of a shared
  978. library trampoline entry. Breakpoints for shared library functions
  979. are put there if the shared library is not yet loaded.
  980. After the shared library is loaded, lookup_minimal_symbol will
  981. prefer the minimal symbol from the shared library (usually
  982. a mst_text symbol) over the mst_solib_trampoline symbol, and the
  983. breakpoints will be moved to their true address in the shared
  984. library via breakpoint_re_set. *)
  985. mst_solib_trampoline, (* Shared library trampoline code *)
  986. (* For the mst_file* types, the names are only guaranteed to be unique
  987. within a given .o file. *)
  988. mst_file_text, (* Static version of mst_text *)
  989. mst_file_data, (* Static version of mst_data *)
  990. mst_file_bss (* Static version of mst_bss *)
  991. );
  992. namespace_enum = (
  993. (* UNDEF_NAMESPACE is used when a namespace has not been discovered or
  994. none of the following apply. This usually indicates an error either
  995. in the symbol information or in gdb's handling of symbols. *)
  996. UNDEF_NAMESPACE,
  997. (* VAR_NAMESPACE is the usual namespace. In C, this contains variables,
  998. function names, typedef names and enum type values. *)
  999. VAR_NAMESPACE,
  1000. (* STRUCT_NAMESPACE is used in C to hold struct, union and enum type names.
  1001. Thus, if `struct foo' is used in a C program, it produces a symbol named
  1002. `foo' in the STRUCT_NAMESPACE. *)
  1003. STRUCT_NAMESPACE,
  1004. (* LABEL_NAMESPACE may be used for names of labels (for gotos);
  1005. currently it is not used and labels are not recorded at all. *)
  1006. LABEL_NAMESPACE,
  1007. (* Searching namespaces. These overlap with VAR_NAMESPACE, providing
  1008. some granularity with the search_symbols function. *)
  1009. (* Everything in VAR_NAMESPACE minus FUNCTIONS_-, TYPES_-, and
  1010. METHODS_NAMESPACE *)
  1011. VARIABLES_NAMESPACE,
  1012. (* All functions -- for some reason not methods, though. *)
  1013. FUNCTIONS_NAMESPACE,
  1014. (* All defined types *)
  1015. TYPES_NAMESPACE,
  1016. (* All class methods -- why is this separated out? *)
  1017. METHODS_NAMESPACE
  1018. );
  1019. address_class = (
  1020. (* Not used; catches errors *)
  1021. LOC_UNDEF,
  1022. (* Value is constant int SYMBOL_VALUE, host byteorder *)
  1023. LOC_CONST,
  1024. (* Value is at fixed address SYMBOL_VALUE_ADDRESS *)
  1025. LOC_STATIC,
  1026. (* Value is in register. SYMBOL_VALUE is the register number. *)
  1027. LOC_REGISTER,
  1028. (* It's an argument; the value is at SYMBOL_VALUE offset in arglist. *)
  1029. LOC_ARG,
  1030. (* Value address is at SYMBOL_VALUE offset in arglist. *)
  1031. LOC_REF_ARG,
  1032. (* Value is in register number SYMBOL_VALUE. Just like LOC_REGISTER
  1033. except this is an argument. Probably the cleaner way to handle
  1034. this would be to separate address_class (which would include
  1035. separate ARG and LOCAL to deal with FRAME_ARGS_ADDRESS versus
  1036. FRAME_LOCALS_ADDRESS), and an is_argument flag.
  1037. For some symbol formats (stabs, for some compilers at least),
  1038. the compiler generates two symbols, an argument and a register.
  1039. In some cases we combine them to a single LOC_REGPARM in symbol
  1040. reading, but currently not for all cases (e.g. it's passed on the
  1041. stack and then loaded into a register). *)
  1042. LOC_REGPARM,
  1043. (* Value is in specified register. Just like LOC_REGPARM except the
  1044. register holds the address of the argument instead of the argument
  1045. itself. This is currently used for the passing of structs and unions
  1046. on sparc and hppa. It is also used for call by reference where the
  1047. address is in a register, at least by mipsread.c. *)
  1048. LOC_REGPARM_ADDR,
  1049. (* Value is a local variable at SYMBOL_VALUE offset in stack frame. *)
  1050. LOC_LOCAL,
  1051. (* Value not used; definition in SYMBOL_TYPE. Symbols in the namespace
  1052. STRUCT_NAMESPACE all have this class. *)
  1053. LOC_TYPEDEF,
  1054. (* Value is address SYMBOL_VALUE_ADDRESS in the code *)
  1055. LOC_LABEL,
  1056. (* In a symbol table, value is SYMBOL_BLOCK_VALUE of a `struct block'.
  1057. In a partial symbol table, SYMBOL_VALUE_ADDRESS is the start address
  1058. of the block. Function names have this class. *)
  1059. LOC_BLOCK,
  1060. (* Value is a constant byte-sequence pointed to by SYMBOL_VALUE_BYTES, in
  1061. target byte order. *)
  1062. LOC_CONST_BYTES,
  1063. (* Value is arg at SYMBOL_VALUE offset in stack frame. Differs from
  1064. LOC_LOCAL in that symbol is an argument; differs from LOC_ARG in
  1065. that we find it in the frame (FRAME_LOCALS_ADDRESS), not in the
  1066. arglist (FRAME_ARGS_ADDRESS). Added for i960, which passes args
  1067. in regs then copies to frame. *)
  1068. LOC_LOCAL_ARG,
  1069. (* Value is at SYMBOL_VALUE offset from the current value of
  1070. register number SYMBOL_BASEREG. This exists mainly for the same
  1071. things that LOC_LOCAL and LOC_ARG do; but we need to do this
  1072. instead because on 88k DWARF gives us the offset from the
  1073. frame/stack pointer, rather than the offset from the "canonical
  1074. frame address" used by COFF, stabs, etc., and we don't know how
  1075. to convert between these until we start examining prologues.
  1076. Note that LOC_BASEREG is much less general than a DWARF expression.
  1077. We don't need the generality (at least not yet), and storing a general
  1078. DWARF expression would presumably take up more space than the existing
  1079. scheme. *)
  1080. LOC_BASEREG,
  1081. (* Same as LOC_BASEREG but it is an argument. *)
  1082. LOC_BASEREG_ARG,
  1083. (* Value is at fixed address, but the address of the variable has
  1084. to be determined from the minimal symbol table whenever the
  1085. variable is referenced.
  1086. This happens if debugging information for a global symbol is
  1087. emitted and the corresponding minimal symbol is defined
  1088. in another object file or runtime common storage.
  1089. The linker might even remove the minimal symbol if the global
  1090. symbol is never referenced, in which case the symbol remains
  1091. unresolved. *)
  1092. LOC_UNRESOLVED,
  1093. (* Value is at a thread-specific location calculated by a
  1094. target-specific method. *)
  1095. LOC_THREAD_LOCAL_STATIC,
  1096. (* The variable does not actually exist in the program.
  1097. The value is ignored. *)
  1098. LOC_OPTIMIZED_OUT,
  1099. (* The variable is static, but actually lives at * (address).
  1100. * I.e. do an extra indirection to get to it.
  1101. * This is used on HP-UX to get at globals that are allocated
  1102. * in shared libraries, where references from images other
  1103. * than the one where the global was allocated are done
  1104. * with a level of indirection.
  1105. *)
  1106. LOC_INDIRECT
  1107. );
  1108. minimal_symbol = record
  1109. (* The general symbol info required for all types of symbols.
  1110. The SYMBOL_VALUE_ADDRESS contains the address that this symbol
  1111. corresponds to. *)
  1112. ginfo : general_symbol_info;
  1113. (* The info field is available for caching machine-specific information
  1114. so it doesn't have to rederive the info constantly (over a serial line).
  1115. It is initialized to zero and stays that way until target-dependent code
  1116. sets it. Storage for any data pointed to by this field should be allo-
  1117. cated on the symbol_obstack for the associated objfile.
  1118. The type would be "void *" except for reasons of compatibility with older
  1119. compilers. This field is optional.
  1120. Currently, the AMD 29000 tdep.c uses it to remember things it has decoded
  1121. from the instructions in the function header, and the MIPS-16 code uses
  1122. it to identify 16-bit procedures. *)
  1123. info : pchar;
  1124. {$ifdef SOFUN_ADDRESS_MAYBE_MISSING}
  1125. (* Which source file is this symbol in? Only relevant for mst_file_*. *)
  1126. filename : pchar;
  1127. {$endif}
  1128. (* Classification types for this symbol. These should be taken as "advisory
  1129. only", since if gdb can't easily figure out a classification it simply
  1130. selects mst_unknown. It may also have to guess when it can't figure out
  1131. which is a better match between two types (mst_data versus mst_bss) for
  1132. example. Since the minimal symbol info is sometimes derived from the
  1133. BFD library's view of a file, we need to live with what information bfd
  1134. supplies. *)
  1135. minimal_symbol_type : tminimal_symbol_type;
  1136. end{ of minimal_symbol};
  1137. block = record
  1138. (* Addresses in the executable code that are in this block. *)
  1139. startaddr,
  1140. endaddr : CORE_ADDR ;
  1141. (* The symbol that names this block, if the block is the body of a
  1142. function; otherwise, zero. *)
  1143. _function : psymbol;
  1144. (* The `struct block' for the containing block, or 0 if none.
  1145. The superblock of a top-level local block (i.e. a function in the
  1146. case of C) is the STATIC_BLOCK. The superblock of the
  1147. STATIC_BLOCK is the GLOBAL_BLOCK. *)
  1148. superblock : pblock;
  1149. (* Version of GCC used to compile the function corresponding
  1150. to this block, or 0 if not compiled with GCC. When possible,
  1151. GCC should be compatible with the native compiler, or if that
  1152. is not feasible, the differences should be fixed during symbol
  1153. reading. As of 16 Apr 93, this flag is never used to distinguish
  1154. between gcc2 and the native compiler.
  1155. If there is no function corresponding to this block, this meaning
  1156. of this flag is undefined. *)
  1157. gcc_compile_flag : byte;
  1158. (* Number of local symbols. *)
  1159. nsyms : longint;
  1160. (* The symbols. If some of them are arguments, then they must be
  1161. in the order in which we would like to print them. *)
  1162. sym : array [0..0] of psymbol;
  1163. end { of block definition };
  1164. symbol = record
  1165. (* The general symbol info required for all types of symbols. *)
  1166. ginfo : general_symbol_info;
  1167. (* Data type of value *)
  1168. _type : pointer{ptype};
  1169. (* Name space code. *)
  1170. namespace : namespace_enum;
  1171. (* Address class *)
  1172. aclass : address_class;
  1173. (* Line number of definition. FIXME: Should we really make the assumption
  1174. that nobody will try to debug files longer than 64K lines? What about
  1175. machine generated programs? *)
  1176. line : word;
  1177. (* Some symbols require an additional value to be recorded on a per-
  1178. symbol basis. Stash those values here. *)
  1179. (*union
  1180. {
  1181. /* Used by LOC_BASEREG and LOC_BASEREG_ARG. */
  1182. short basereg;
  1183. } *)
  1184. aux_value_base_reg : word;
  1185. (* Link to a list of aliases for this symbol.
  1186. Only a "primary/main symbol may have aliases. *)
  1187. aliases : pointer{palias_list};
  1188. (* List of ranges where this symbol is active. This is only
  1189. used by alias symbols at the current time. *)
  1190. ranges : pointer{prange_list};
  1191. end;
  1192. target_signal = (TARGET_SIGNAL_FIRST := 0,
  1193. TARGET_SIGNAL_HUP := 1,TARGET_SIGNAL_INT := 2,
  1194. TARGET_SIGNAL_QUIT := 3,TARGET_SIGNAL_ILL := 4,
  1195. TARGET_SIGNAL_TRAP := 5,TARGET_SIGNAL_ABRT := 6,
  1196. TARGET_SIGNAL_EMT := 7,TARGET_SIGNAL_FPE := 8,
  1197. TARGET_SIGNAL_KILL := 9,TARGET_SIGNAL_BUS := 10,
  1198. TARGET_SIGNAL_SEGV := 11,TARGET_SIGNAL_SYS := 12,
  1199. TARGET_SIGNAL_PIPE := 13,TARGET_SIGNAL_ALRM := 14,
  1200. TARGET_SIGNAL_TERM := 15,TARGET_SIGNAL_URG := 16,
  1201. TARGET_SIGNAL_STOP := 17,TARGET_SIGNAL_TSTP := 18,
  1202. TARGET_SIGNAL_CONT := 19,TARGET_SIGNAL_CHLD := 20,
  1203. TARGET_SIGNAL_TTIN := 21,TARGET_SIGNAL_TTOU := 22,
  1204. TARGET_SIGNAL_IO := 23,TARGET_SIGNAL_XCPU := 24,
  1205. TARGET_SIGNAL_XFSZ := 25,TARGET_SIGNAL_VTALRM := 26,
  1206. TARGET_SIGNAL_PROF := 27,TARGET_SIGNAL_WINCH := 28,
  1207. TARGET_SIGNAL_LOST := 29,TARGET_SIGNAL_USR1 := 30,
  1208. TARGET_SIGNAL_USR2 := 31,TARGET_SIGNAL_PWR := 32,
  1209. TARGET_SIGNAL_POLL := 33,TARGET_SIGNAL_WIND := 34,
  1210. TARGET_SIGNAL_PHONE := 35,TARGET_SIGNAL_WAITING := 36,
  1211. TARGET_SIGNAL_LWP := 37,TARGET_SIGNAL_DANGER := 38,
  1212. TARGET_SIGNAL_GRANT := 39,TARGET_SIGNAL_RETRACT := 40,
  1213. TARGET_SIGNAL_MSG := 41,TARGET_SIGNAL_SOUND := 42,
  1214. TARGET_SIGNAL_SAK := 43,TARGET_SIGNAL_PRIO := 44,
  1215. TARGET_SIGNAL_REALTIME_33 := 45,TARGET_SIGNAL_REALTIME_34 := 46,
  1216. TARGET_SIGNAL_REALTIME_35 := 47,TARGET_SIGNAL_REALTIME_36 := 48,
  1217. TARGET_SIGNAL_REALTIME_37 := 49,TARGET_SIGNAL_REALTIME_38 := 50,
  1218. TARGET_SIGNAL_REALTIME_39 := 51,TARGET_SIGNAL_REALTIME_40 := 52,
  1219. TARGET_SIGNAL_REALTIME_41 := 53,TARGET_SIGNAL_REALTIME_42 := 54,
  1220. TARGET_SIGNAL_REALTIME_43 := 55,TARGET_SIGNAL_REALTIME_44 := 56,
  1221. TARGET_SIGNAL_REALTIME_45 := 57,TARGET_SIGNAL_REALTIME_46 := 58,
  1222. TARGET_SIGNAL_REALTIME_47 := 59,TARGET_SIGNAL_REALTIME_48 := 60,
  1223. TARGET_SIGNAL_REALTIME_49 := 61,TARGET_SIGNAL_REALTIME_50 := 62,
  1224. TARGET_SIGNAL_REALTIME_51 := 63,TARGET_SIGNAL_REALTIME_52 := 64,
  1225. TARGET_SIGNAL_REALTIME_53 := 65,TARGET_SIGNAL_REALTIME_54 := 66,
  1226. TARGET_SIGNAL_REALTIME_55 := 67,TARGET_SIGNAL_REALTIME_56 := 68,
  1227. TARGET_SIGNAL_REALTIME_57 := 69,TARGET_SIGNAL_REALTIME_58 := 70,
  1228. TARGET_SIGNAL_REALTIME_59 := 71,TARGET_SIGNAL_REALTIME_60 := 72,
  1229. TARGET_SIGNAL_REALTIME_61 := 73,TARGET_SIGNAL_REALTIME_62 := 74,
  1230. TARGET_SIGNAL_REALTIME_63 := 75,TARGET_SIGNAL_UNKNOWN,
  1231. TARGET_SIGNAL_DEFAULT,TARGET_SIGNAL_LAST
  1232. );
  1233. strata = (dummy_stratum,file_stratum,core_stratum,download_stratum,process_stratum);
  1234. ptarget_ops = ^target_ops;
  1235. target_ops = record
  1236. to_shortname : pchar;
  1237. to_longname : pchar;
  1238. to_doc : pchar;
  1239. to_open : procedure (_para1:pchar; _para2:longint);
  1240. to_close : procedure (_para1:longint);
  1241. to_attach : procedure (_para1:pchar; _para2:longint);
  1242. to_detach : procedure (_para1:pchar; _para2:longint);
  1243. to_resume : procedure (_para1:longint; _para2:longint; _para3:target_signal);
  1244. to_wait : pointer; {function (_para1:longint; _para2:ptarget_waitstatus):longint;}
  1245. to_fetch_registers : procedure (_para1:longint);
  1246. to_store_registers : procedure (_para1:longint);
  1247. to_prepare_to_store : procedure ;
  1248. to_xfer_memory : function (memaddr:CORE_ADDR; myaddr:pchar; len:longint; write:longint; target:ptarget_ops):longint;
  1249. to_files_info : procedure (_para1:ptarget_ops);
  1250. to_insert_breakpoint : function (_para1:CORE_ADDR; _para2:pchar):longint;
  1251. to_remove_breakpoint : function (_para1:CORE_ADDR; _para2:pchar):longint;
  1252. to_terminal_init : procedure ;
  1253. to_terminal_inferior : procedure ;
  1254. to_terminal_ours_for_output : procedure ;
  1255. to_terminal_ours : procedure ;
  1256. to_terminal_info : procedure (_para1:pchar; _para2:longint);
  1257. to_kill : procedure ;
  1258. to_load : procedure (_para1:pchar; _para2:longint);
  1259. to_lookup_symbol : function (_para1:pchar; _para2:pCORE_ADDR):longint;
  1260. to_create_inferior : procedure (_para1:pchar; _para2:pchar; _para3:ppchar);
  1261. to_mourn_inferior : procedure ;
  1262. to_can_run : function :longint;
  1263. to_notice_signals : procedure (pid:longint);
  1264. to_thread_alive : function (pid:longint):longint;
  1265. to_stop : procedure ;
  1266. to_stratum : strata;
  1267. DONT_USE : pointer;
  1268. to_has_all_memory : longint;
  1269. to_has_memory : longint;
  1270. to_has_stack : longint;
  1271. to_has_registers : longint;
  1272. to_has_execution : longint;
  1273. to_sections : pointer; {^section_table}
  1274. to_sections_end : pointer; {^section_table}
  1275. to_magic : longint;
  1276. end;
  1277. {$PACKRECORDS NORMAL}
  1278. {*****************************************************************************
  1279. Define external calls to libgdb.a
  1280. *****************************************************************************}
  1281. var
  1282. { external variables }
  1283. error_return : jmp_buf;cvar;public;
  1284. quit_return : jmp_buf;cvar;public;
  1285. deprecated_query_hook : pointer;cvar;public;
  1286. {$ifndef GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED}
  1287. {$ifdef GDB_HAS_DEPRECATED_CBPH}
  1288. deprecated_create_breakpoint_hook : pointer;cvar;external;
  1289. {$else}
  1290. create_breakpoint_hook : pointer;cvar;external;
  1291. {$endif}
  1292. {$endif ndef GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED}
  1293. current_target : target_ops;cvar;external;
  1294. stop_pc : CORE_ADDR;cvar;external;
  1295. { Only used from GDB 5.01 but doesn't hurst otherwise }
  1296. interpreter_p : pchar;cvar;public;
  1297. { we need also to declare some vars }
  1298. watchdog : longint;cvar;external;
  1299. gdb_error : longint;cvar;public;
  1300. display_time : longbool;cvar;public;
  1301. display_space : longbool;cvar;public;
  1302. { Whether this is the command line version or not }
  1303. tui_version : longint;cvar;public;
  1304. { Whether xdb commands will be handled }
  1305. {$ifdef GDB_HAS_DB_COMMANDS}
  1306. xdb_commands : longint;cvar;public;
  1307. { Whether dbx commands will be handled }
  1308. dbx_commands : longint;cvar;public;
  1309. {$endif GDB_HAS_DB_COMMANDS}
  1310. var
  1311. gdb_stdout : pui_file;cvar;public;
  1312. gdb_stderr : pui_file;cvar;public;
  1313. gdb_stdlog : pui_file;cvar;public;
  1314. gdb_stdtarg : pui_file;cvar;public;
  1315. event_loop_p : longint;cvar;public;
  1316. {$ifdef GDB_V6}
  1317. (* target IO streams *)
  1318. gdb_stdtargin : pui_file;cvar;public;
  1319. gdb_stdtargerr : pui_file;cvar;public;
  1320. {$endif}
  1321. { used for gdb_stdout and gdb_stderr }
  1322. function xmalloc(size : longint) : pointer;cdecl;external;
  1323. { used for QueryHook }
  1324. { xvasprintf is present at least from GDB 5.3
  1325. while xstrvprintf only appears in version 6.2,
  1326. so only use xvasprintf function }
  1327. function xvasprintf(ret : ppchar; msg : pchar) : pchar; varargs; cdecl; external;
  1328. procedure xfree(p : pointer); cdecl; external;
  1329. function find_pc_line(i:CORE_ADDR;l:longint):symtab_and_line;cdecl;external;
  1330. function find_pc_function(i:CORE_ADDR):psymbol;cdecl;external;
  1331. function lookup_minimal_symbol_by_pc(i : CORE_ADDR):pminimal_symbol;cdecl;external;
  1332. {$ifdef GDB_INIT_HAS_ARGV0}
  1333. procedure gdb_init(argv0 : pchar);cdecl;external;
  1334. {$else not GDB_INIT_HAS_ARGV0}
  1335. procedure gdb_init;cdecl;external;
  1336. {$endif not GDB_INIT_HAS_ARGV0}
  1337. procedure execute_command(p:pchar;i:longint);cdecl;external;
  1338. {$ifdef GDB_TARGET_CLOSE_HAS_PTARGET_ARG}
  1339. procedure target_kill;cdecl;external;
  1340. procedure target_close(pt : ptarget_ops; i:longint);cdecl;external;
  1341. {$else not GDB_TARGET_CLOSE_HAS_PTARGET_ARG}
  1342. procedure target_close(i:longint);cdecl;external;
  1343. {$endif ndef GDB_TARGET_CLOSE_HAS_PTARGET_ARG}
  1344. {*****************************************************************************
  1345. Helpers
  1346. *****************************************************************************}
  1347. procedure Debug(const s:string);
  1348. begin
  1349. if use_gdb_file then
  1350. Writeln(gdb_file,s)
  1351. else
  1352. Writeln(s);
  1353. end;
  1354. {*****************************************************************************
  1355. TFrameEntry
  1356. *****************************************************************************}
  1357. constructor tframeentry.init;
  1358. begin
  1359. Reset;
  1360. end;
  1361. destructor tframeentry.done;
  1362. begin
  1363. Clear;
  1364. end;
  1365. procedure tframeentry.reset;
  1366. begin
  1367. file_name:=nil;
  1368. function_name:=nil;
  1369. args:=nil;
  1370. line_number:=0;
  1371. address:=0;
  1372. end;
  1373. procedure tframeentry.clear;
  1374. begin
  1375. if assigned(file_name) then
  1376. strdispose(file_name);
  1377. if assigned(function_name) then
  1378. strdispose(function_name);
  1379. if assigned(args) then
  1380. strdispose(args);
  1381. reset;
  1382. end;
  1383. {*****************************************************************************
  1384. tgdbbuffer
  1385. *****************************************************************************}
  1386. const
  1387. blocksize=2048;
  1388. constructor tgdbbuffer.init;
  1389. begin
  1390. Buf:=nil;
  1391. gdb_file:=nil;
  1392. Size:=0;
  1393. Resize(blocksize);
  1394. Reset;
  1395. end;
  1396. destructor tgdbbuffer.done;
  1397. begin
  1398. if assigned(buf) then
  1399. freemem(buf,size);
  1400. end;
  1401. procedure tgdbbuffer.reset;
  1402. begin
  1403. idx:=0;
  1404. Buf[0]:=#0;
  1405. end;
  1406. procedure tgdbbuffer.append(p:pchar);
  1407. var
  1408. len : longint;
  1409. begin
  1410. if not assigned(p) then
  1411. exit;
  1412. len:=Strlen(p);
  1413. if len+1+idx>size then
  1414. Resize(len+1+idx);
  1415. Move(p^,buf[idx],len);
  1416. inc(idx,len);
  1417. buf[idx]:=#0;
  1418. end;
  1419. procedure tgdbbuffer.lappend(p:pchar;len : longint);
  1420. begin
  1421. if not assigned(p) then
  1422. exit;
  1423. if len+idx+1>size then
  1424. Resize(len+idx+1);
  1425. Move(p^,buf[idx],len);
  1426. inc(idx,len);
  1427. buf[idx]:=#0;
  1428. end;
  1429. procedure tgdbbuffer.resize(nsize : longint);
  1430. var
  1431. np : pchar;
  1432. begin
  1433. nsize:=((nsize+blocksize-1) div blocksize)*blocksize;
  1434. getmem(np,nsize);
  1435. if assigned(buf) then
  1436. begin
  1437. move(buf^,np^,size);
  1438. freemem(buf,size);
  1439. end;
  1440. buf:=np;
  1441. size:=nsize;
  1442. end;
  1443. {*****************************************************************************
  1444. Hook calls from libgdb.a
  1445. *****************************************************************************}
  1446. {$ifdef go32v2}
  1447. procedure gdbpas_prev_exception_handler;cdecl;public;
  1448. begin
  1449. end;
  1450. {$endif go32v2}
  1451. procedure init_proc;cdecl;public;
  1452. begin
  1453. end;
  1454. procedure annotate_signalled;cdecl;public;
  1455. begin
  1456. {$ifdef Verbose}
  1457. Debug('|signalled|');
  1458. {$endif}
  1459. end;
  1460. procedure annotate_signal_name;cdecl;public;
  1461. begin
  1462. {$ifdef Verbose}
  1463. Debug('|signal_name|');
  1464. {$endif}
  1465. with curr_gdb^ do
  1466. signal_name_start:=gdboutputbuf.idx;
  1467. end;
  1468. procedure annotate_signal_name_end;cdecl;public;
  1469. begin
  1470. {$ifdef Verbose}
  1471. Debug('|signal_name_end|');
  1472. {$endif}
  1473. with curr_gdb^ do
  1474. signal_name_end:=gdboutputbuf.idx;
  1475. end;
  1476. procedure annotate_signal_string;cdecl;public;
  1477. begin
  1478. {$ifdef Verbose}
  1479. Debug('|signal_string|');
  1480. {$endif}
  1481. with curr_gdb^ do
  1482. signal_start:=gdboutputbuf.idx;
  1483. end;
  1484. procedure annotate_signal_string_end;cdecl;public;
  1485. var
  1486. c : char;
  1487. begin
  1488. {$ifdef Verbose}
  1489. Debug('|signal_string_end|');
  1490. {$endif}
  1491. with curr_gdb^ do
  1492. begin
  1493. signal_end:=gdboutputbuf.idx;
  1494. c:=gdboutputbuf.buf[signal_end];
  1495. gdboutputbuf.buf[signal_end]:=#0;
  1496. if assigned(signal_string) then
  1497. strdispose(signal_string);
  1498. signal_string:=strnew(gdboutputbuf.buf+signal_start);
  1499. gdboutputbuf.buf[signal_end]:=c;
  1500. c:=gdboutputbuf.buf[signal_name_end];
  1501. gdboutputbuf.buf[signal_name_end]:=#0;
  1502. if assigned(signal_name) then
  1503. strdispose(signal_name);
  1504. signal_name:=strnew(gdboutputbuf.buf+signal_name_start);
  1505. gdboutputbuf.buf[signal_name_end]:=c;
  1506. if (user_screen_shown) then
  1507. begin
  1508. DebuggerScreen;
  1509. DoUserSignal;
  1510. UserScreen;
  1511. end
  1512. else
  1513. DoUserSignal;
  1514. call_reset:=true;
  1515. signaled:=false;
  1516. end;
  1517. end;
  1518. procedure annotate_signal;cdecl;public;
  1519. begin
  1520. {$ifdef Verbose}
  1521. Debug('|signal|');
  1522. {$endif}
  1523. with curr_gdb^ do
  1524. signaled:=true;
  1525. end;
  1526. procedure annotate_exited(exitstatus:longint);cdecl;public;
  1527. begin
  1528. {$ifdef Verbose}
  1529. Debug('|exited|');
  1530. {$endif}
  1531. {#ifdef __DJGPP__
  1532. /* this is very important. The exit code of a djgpp program
  1533. disables interrupts and after this there is no other interrupt
  1534. called, which enables interrupts with the iret. */
  1535. __dpmi_get_and_enable_virtual_interrupt_state();
  1536. #endif }
  1537. {$ifdef go32v2}
  1538. {$asmmode att}
  1539. asm
  1540. movw $0x901,%ax
  1541. int $0x31
  1542. end;
  1543. {$asmmode default}
  1544. reload_fs;
  1545. {$endif def go32v2}
  1546. curr_gdb^.DebuggerScreen;
  1547. { DeleteBreakPoints; }
  1548. curr_gdb^.EndSession(exitstatus);
  1549. end;
  1550. procedure annotate_error;cdecl;public;
  1551. begin
  1552. {$ifdef Verbose}
  1553. Debug('|error|');
  1554. {$endif}
  1555. end;
  1556. procedure annotate_error_begin;cdecl;public;
  1557. begin
  1558. {$ifdef Verbose}
  1559. Debug('|error begin|');
  1560. {$endif}
  1561. with curr_gdb^ do
  1562. begin
  1563. error_start:=gdboutputbuf.idx+strlen(gdboutputbuf.buf);
  1564. got_error:=true;
  1565. end;
  1566. {$ifdef Verbose}
  1567. Debug('|end of error begin|');
  1568. {$endif}
  1569. end;
  1570. procedure annotate_starting;cdecl;public;
  1571. begin
  1572. {$ifdef Verbose}
  1573. Debug('|starting|');
  1574. {$endif}
  1575. {$ifdef go32v2}
  1576. reload_fs;
  1577. {$endif go32v2}
  1578. curr_gdb^.UserScreen;
  1579. end;
  1580. procedure annotate_stopped;cdecl;public;
  1581. var
  1582. sym : symtab_and_line;
  1583. fname : pchar;
  1584. begin
  1585. {$ifdef Verbose}
  1586. Debug('|stopped|');
  1587. {$endif}
  1588. with curr_gdb^ do
  1589. begin
  1590. {$ifdef go32v2}
  1591. reload_fs;
  1592. {$endif go32v2}
  1593. DebuggerScreen;
  1594. current_pc:=stop_pc;
  1595. Debuggee_started:=inferior_pid<>0;
  1596. if not Debuggee_started then exit;
  1597. if reset_command then exit;
  1598. sym:=find_pc_line(stop_pc,0);
  1599. if assigned(sym.symtab) then
  1600. fname:=sym.symtab^.filename
  1601. else
  1602. fname:=nil;
  1603. SelectSourceLine(fname,sym.line);
  1604. end;
  1605. end;
  1606. function inferior_pid : longint;
  1607. begin
  1608. inferior_pid:=inferior_ptid.pid;
  1609. end;
  1610. procedure proc_remove_foreign(pid:longint);cdecl;public;
  1611. begin
  1612. end;
  1613. procedure breakpoints_changed;cdecl;public;
  1614. begin
  1615. {$ifdef Verbose}
  1616. Debug('|breakpoints_changed|');
  1617. {$endif}
  1618. end;
  1619. procedure annotate_ignore_count_change;cdecl;public;
  1620. begin
  1621. {$ifdef Verbose}
  1622. Debug('|annotate_ignore_count_change()|');
  1623. {$endif}
  1624. end;
  1625. procedure annotate_new_thread;cdecl;public;
  1626. begin
  1627. {$ifdef Verbose}
  1628. Debug('|annotate_new_thread()|');
  1629. {$endif}
  1630. end;
  1631. procedure annotate_thread_changed;cdecl;public;
  1632. begin
  1633. {$ifdef Verbose}
  1634. Debug('|annotate_thread_changed()|');
  1635. {$endif}
  1636. end;
  1637. procedure annotate_breakpoint(num:longint);cdecl;public;
  1638. begin
  1639. {$ifdef Verbose}
  1640. Debug('|breakpoint(%d)|');
  1641. {$endif}
  1642. With Curr_gdb^ do
  1643. stop_breakpoint_number:=num;
  1644. end;
  1645. procedure annotate_watchpoint(num:longint);cdecl;public;
  1646. begin
  1647. {$ifdef Verbose}
  1648. Debug('|watchpoint(%d)|');
  1649. {$endif}
  1650. With Curr_gdb^ do
  1651. stop_breakpoint_number:=num;
  1652. end;
  1653. procedure annotate_catchpoint(num:longint);cdecl;public;
  1654. begin
  1655. {$ifdef Verbose}
  1656. Debug('|catchpoint(%d)|');
  1657. {$endif}
  1658. With Curr_gdb^ do
  1659. stop_breakpoint_number:=num;
  1660. end;
  1661. procedure annotate_breakpoints_headers;cdecl;public;
  1662. begin
  1663. {$ifdef Verbose}
  1664. Debug('|breakpoints_headers|');
  1665. {$endif}
  1666. end;
  1667. procedure annotate_breakpoints_table;cdecl;public;
  1668. begin
  1669. {$ifdef Verbose}
  1670. Debug('|breakpoints_table|');
  1671. {$endif}
  1672. end;
  1673. procedure annotate_record;cdecl;public;
  1674. begin
  1675. {$ifdef Verbose}
  1676. Debug('|record|');
  1677. {$endif}
  1678. end;
  1679. procedure annotate_breakpoints_table_end;cdecl;public;
  1680. begin
  1681. {$ifdef Verbose}
  1682. Debug('|breakpoints_table_end|');
  1683. {$endif}
  1684. end;
  1685. procedure annotate_frames_invalid;cdecl;public;
  1686. begin
  1687. {$ifdef Verbose}
  1688. Debug('|frames_invalid|');
  1689. {$endif}
  1690. end;
  1691. procedure annotate_frame_begin(level:longint;pc:CORE_ADDR);cdecl;public;
  1692. begin
  1693. {$ifdef Verbose}
  1694. Debug('|frame_begin(%d,%ld)|');
  1695. {$endif}
  1696. with curr_gdb^ do
  1697. begin
  1698. frame_begin_seen:=true;
  1699. frame_level:=level;
  1700. current_address:=pc;
  1701. current_line_number:=-1;
  1702. function_start:=-1;
  1703. function_end:=-1;
  1704. args_start:=-1;
  1705. args_end:=-1;
  1706. file_start:=-1;
  1707. file_end:=-1;
  1708. line_start:=-1;
  1709. line_end:=-1;
  1710. end;
  1711. end;
  1712. procedure annotate_frame_address;cdecl;public;
  1713. begin
  1714. {$ifdef Verbose}
  1715. Debug('|frame_address|');
  1716. {$endif}
  1717. end;
  1718. procedure annotate_frame_address_end;cdecl;public;
  1719. begin
  1720. {$ifdef Verbose}
  1721. Debug('|frame_address_end|');
  1722. {$endif}
  1723. end;
  1724. procedure annotate_frame_function_name;cdecl;public;
  1725. begin
  1726. {$ifdef Verbose}
  1727. Debug('|frame_function_name|');
  1728. {$endif}
  1729. with curr_gdb^ do
  1730. function_start:=gdboutputbuf.idx;
  1731. end;
  1732. procedure annotate_frame_args;cdecl;public;
  1733. begin
  1734. {$ifdef Verbose}
  1735. Debug('|frame_args|');
  1736. {$endif}
  1737. with curr_gdb^ do
  1738. begin
  1739. function_end:=gdboutputbuf.idx;
  1740. args_start:=gdboutputbuf.idx;
  1741. end;
  1742. end;
  1743. procedure annotate_frame_source_begin;cdecl;public;
  1744. begin
  1745. {$ifdef Verbose}
  1746. Debug('|frame_source_begin|');
  1747. {$endif}
  1748. with curr_gdb^ do
  1749. args_end:=gdboutputbuf.idx;
  1750. end;
  1751. procedure annotate_frame_source_file;cdecl;public;
  1752. begin
  1753. {$ifdef Verbose}
  1754. Debug('|frame_source_file|');
  1755. {$endif}
  1756. with curr_gdb^ do
  1757. file_start:=gdboutputbuf.idx;
  1758. end;
  1759. procedure annotate_frame_source_file_end;cdecl;public;
  1760. begin
  1761. {$ifdef Verbose}
  1762. Debug('|frame_source_file_end|');
  1763. {$endif}
  1764. with curr_gdb^ do
  1765. file_end:=gdboutputbuf.idx;
  1766. end;
  1767. procedure annotate_frame_source_line;cdecl;public;
  1768. begin
  1769. {$ifdef Verbose}
  1770. Debug('|frame_source_line|');
  1771. {$endif}
  1772. with curr_gdb^ do
  1773. line_start:=gdboutputbuf.idx;
  1774. end;
  1775. procedure annotate_frame_source_end;cdecl;public;
  1776. begin
  1777. {$ifdef Verbose}
  1778. Debug('|frame_source_end|');
  1779. {$endif}
  1780. with curr_gdb^ do
  1781. line_end:=gdboutputbuf.idx;
  1782. end;
  1783. procedure annotate_frame_where;cdecl;public;
  1784. begin
  1785. {$ifdef Verbose}
  1786. Debug('|frame_where|');
  1787. {$endif}
  1788. end;
  1789. procedure annotate_frame_end;cdecl;public;
  1790. var
  1791. fe : pframeentry;
  1792. c : char;
  1793. err : integer;
  1794. begin
  1795. {$ifdef Verbose}
  1796. Debug('|frame_end|');
  1797. {$endif}
  1798. with curr_gdb^ do
  1799. begin
  1800. if (not record_frames) or (not frame_begin_seen) then
  1801. exit;
  1802. { This can happen, when the function has no Debugging information }
  1803. if (args_start >= 0) and (args_end < 0) then
  1804. args_end:=gdboutputbuf.idx;
  1805. frame_begin_seen:=false;
  1806. fe:=get_frameentry(frame_level);
  1807. fe^.address:=current_address;
  1808. fe^.level:=frame_level;
  1809. if (function_start>=0) then
  1810. begin
  1811. c:=gdboutputbuf.buf[function_end];
  1812. gdboutputbuf.buf[function_end]:=#0;
  1813. fe^.function_name:=strnew(gdboutputbuf.buf+function_start);
  1814. gdboutputbuf.buf[function_end]:=c;
  1815. end;
  1816. if (file_start>=0) then
  1817. begin
  1818. c:=gdboutputbuf.buf[file_end];
  1819. gdboutputbuf.buf[file_end]:=#0;
  1820. fe^.file_name:=strnew(gdboutputbuf.buf+file_start);
  1821. gdboutputbuf.buf[file_end]:=c;
  1822. end;
  1823. if (args_start>=0) then
  1824. begin
  1825. {$warning FIXME} {sometimes the ide crashes here because ars_end is 0, AD}
  1826. if args_end > 0 then
  1827. begin
  1828. if (gdboutputbuf.buf[args_end-1]=#10) then
  1829. dec(args_end);
  1830. c:=gdboutputbuf.buf[args_end];
  1831. gdboutputbuf.buf[args_end]:=#0;
  1832. fe^.args:=strnew(gdboutputbuf.buf+args_start);
  1833. gdboutputbuf.buf[args_end]:=c;
  1834. end;
  1835. end;
  1836. if (line_start>=0) then
  1837. begin
  1838. c:=gdboutputbuf.buf[line_end];
  1839. gdboutputbuf.buf[line_end]:=#0;
  1840. { sscanf(gdb_output_buffer+line_start,'%d',&fe^.line_number); }
  1841. val(strpas(pchar(@gdboutputbuf.buf[line_start])),fe^.line_number,err);
  1842. gdboutputbuf.buf[line_end]:=c;
  1843. end;
  1844. end;
  1845. end;
  1846. procedure annotate_quit;cdecl;public;
  1847. begin
  1848. {$ifdef Verbose}
  1849. Debug('|quit|');
  1850. {$endif}
  1851. end;
  1852. procedure annotate_arg_begin;cdecl;public;
  1853. begin
  1854. {$ifdef Verbose}
  1855. Debug('|arg_begin|');
  1856. {$endif}
  1857. end;
  1858. procedure annotate_arg_name_end;cdecl;public;
  1859. begin
  1860. {$ifdef Verbose}
  1861. Debug('|arg_name_end|');
  1862. {$endif}
  1863. end;
  1864. procedure annotate_arg_value(typ:pointer);cdecl;public;
  1865. begin
  1866. {$ifdef Verbose}
  1867. Debug('|arg_value|');
  1868. {$endif}
  1869. end;
  1870. procedure annotate_arg_end;cdecl;public;
  1871. begin
  1872. {$ifdef Verbose}
  1873. Debug('|arg_end|');
  1874. {$endif}
  1875. end;
  1876. procedure annotate_source(filename:pchar;line,character,mid:longint;pc:CORE_ADDR);cdecl;public;
  1877. begin
  1878. {$ifdef Verbose}
  1879. Debug('|source|');
  1880. {$endif}
  1881. end;
  1882. procedure annotate_function_call;cdecl;public;
  1883. begin
  1884. {$ifdef Verbose}
  1885. Debug('|function_call|');
  1886. {$endif}
  1887. end;
  1888. procedure annotate_signal_handler_caller;cdecl;public;
  1889. begin
  1890. {$ifdef Verbose}
  1891. Debug('|signal_handler_caller|');
  1892. {$endif}
  1893. end;
  1894. procedure annotate_array_section_begin(index:longint;elttype:pointer);cdecl;public;
  1895. begin
  1896. {$ifdef Verbose}
  1897. Debug('|array_section_begin()|');
  1898. {$endif}
  1899. end;
  1900. procedure annotate_elt_rep(repcount:longint);cdecl;public;
  1901. begin
  1902. {$ifdef Verbose}
  1903. Debug('|elt_rep()|');
  1904. {$endif}
  1905. end;
  1906. procedure annotate_elt_rep_end;cdecl;public;
  1907. begin
  1908. {$ifdef Verbose}
  1909. Debug('|elt_rep_end|');
  1910. {$endif}
  1911. end;
  1912. procedure annotate_elt;cdecl;public;
  1913. begin
  1914. {$ifdef Verbose}
  1915. Debug('|elt|');
  1916. {$endif}
  1917. end;
  1918. procedure annotate_array_section_end;cdecl;public;
  1919. begin
  1920. {$ifdef Verbose}
  1921. Debug('|array_section_end|');
  1922. {$endif}
  1923. end;
  1924. procedure annotate_display_begin;cdecl;public;
  1925. begin
  1926. {$ifdef Verbose}
  1927. Debug('|display_begin|');
  1928. {$endif}
  1929. end;
  1930. procedure annotate_display_number_end;cdecl;public;
  1931. begin
  1932. {$ifdef Verbose}
  1933. Debug('|display_number_end|');
  1934. {$endif}
  1935. end;
  1936. procedure annotate_display_format;cdecl;public;
  1937. begin
  1938. {$ifdef Verbose}
  1939. Debug('|display_format|');
  1940. {$endif}
  1941. end;
  1942. procedure annotate_display_expression;cdecl;public;
  1943. begin
  1944. {$ifdef Verbose}
  1945. Debug('|display_expression|');
  1946. {$endif}
  1947. end;
  1948. procedure annotate_display_expression_end;cdecl;public;
  1949. begin
  1950. {$ifdef Verbose}
  1951. Debug('|display_expression_end|');
  1952. {$endif}
  1953. end;
  1954. procedure annotate_display_value;cdecl;public;
  1955. begin
  1956. {$ifdef Verbose}
  1957. Debug('|display_value|');
  1958. {$endif}
  1959. end;
  1960. procedure annotate_display_end;cdecl;public;
  1961. begin
  1962. {$ifdef Verbose}
  1963. Debug('|display_end|');
  1964. {$endif}
  1965. end;
  1966. procedure annotate_field (num:longint);cdecl;public;
  1967. begin
  1968. {$ifdef Verbose}
  1969. Debug('a_field(%d)');
  1970. {$endif}
  1971. end;
  1972. procedure annotate_field_begin(typ:pointer);cdecl;public;
  1973. begin
  1974. {$ifdef Verbose}
  1975. Debug('a_field_begin\n');
  1976. {$endif}
  1977. end;
  1978. procedure annotate_field_name_end;cdecl;public;
  1979. begin
  1980. {$ifdef Verbose}
  1981. Debug('a_field_name_end\n');
  1982. {$endif}
  1983. end;
  1984. procedure annotate_field_value;cdecl;public;
  1985. begin
  1986. {$ifdef Verbose}
  1987. Debug('a_field_value\n');
  1988. {$endif}
  1989. end;
  1990. procedure annotate_field_end;cdecl;public;
  1991. begin
  1992. {$ifdef Verbose}
  1993. Debug('a_field_end\n');
  1994. {$endif}
  1995. end;
  1996. procedure annotate_value_history_begin (histindex:longint;typ:pointer);cdecl;public;
  1997. begin
  1998. {$ifdef Verbose}
  1999. Debug('a_value_history_begin(%d)\n');
  2000. {$endif}
  2001. end;
  2002. procedure annotate_value_begin (typ:pointer);cdecl;public;
  2003. begin
  2004. {$ifdef Verbose}
  2005. Debug('a_value_begin\n');
  2006. {$endif}
  2007. end;
  2008. procedure annotate_value_history_value;cdecl;public;
  2009. begin
  2010. {$ifdef Verbose}
  2011. Debug('a_value_history_value\n');
  2012. {$endif}
  2013. end;
  2014. procedure annotate_value_history_end;cdecl;public;
  2015. begin
  2016. {$ifdef Verbose}
  2017. Debug('a_value_history_end\n');
  2018. {$endif}
  2019. end;
  2020. procedure annotate_value_end;cdecl;public;
  2021. begin
  2022. {$ifdef Verbose}
  2023. Debug('a_value_end\n');
  2024. {$endif}
  2025. end;
  2026. procedure _initialize_annotate;cdecl;public;
  2027. begin
  2028. end;
  2029. procedure gdbint_ui_file_write(stream : pui_file; p : pchar; len : longint);cdecl;
  2030. begin
  2031. if assigned(curr_gdb) then
  2032. with curr_gdb^ do
  2033. if stream = gdb_stderr then
  2034. gdberrorbuf.lappend(p,len)
  2035. else if stream = gdb_stdout then
  2036. gdboutputbuf.lappend(p,len)
  2037. else
  2038. begin
  2039. gdberrorbuf.append('Unknown gdb ui_file');
  2040. gdberrorbuf.lappend(p,len);
  2041. end;
  2042. end;
  2043. function QueryHook(question : pchar; arg : ppchar) : longint; cdecl;
  2044. var local : pchar;
  2045. begin
  2046. if not assigned(curr_gdb) then
  2047. QueryHook:=0
  2048. else
  2049. begin
  2050. if curr_gdb^.reset_command and ((pos('Kill',question)>0) or
  2051. (pos('Discard symbol table',question)>0)) then
  2052. QueryHook:=1
  2053. else if pos('%',question)>0 then
  2054. begin
  2055. xvasprintf(@local,question,arg);
  2056. { xvasprintf can failed, in that case local is set to nil }
  2057. if not assigned(local) then
  2058. local:=question;
  2059. QueryHook:=curr_gdb^.Query(local, nil);
  2060. xfree(local);
  2061. end
  2062. else
  2063. QueryHook:=curr_gdb^.Query(question, nil);
  2064. end;
  2065. end;
  2066. procedure CreateBreakPointHook(var b:breakpoint);cdecl;
  2067. var
  2068. sym : symtab_and_line;
  2069. { this procedure is only here to avoid the problems
  2070. with different version of gcc having different stack
  2071. handling:
  2072. on older versions find_pc_line uses just "ret"
  2073. while on newer gcc version "ret $4" is used
  2074. if this call is within the CreateBreakPointHook function
  2075. it changes %esp and thus the registers are
  2076. not restored correctly PM }
  2077. procedure get_pc_line;
  2078. begin
  2079. {$ifdef GDB_USES_BP_LOCATION}
  2080. if assigned (b.loc) then
  2081. sym:=find_pc_line(b.loc^.address,0)
  2082. {$else not GDB_USES_BP_LOCATION}
  2083. if (b.address <> 0) then
  2084. sym:=find_pc_line(b.address,0)
  2085. {$endif not GDB_USES_BP_LOCATION}
  2086. else
  2087. fillchar (sym, sizeof(sym), #0);
  2088. end;
  2089. begin
  2090. get_pc_line;
  2091. with curr_gdb^ do
  2092. begin
  2093. last_breakpoint_number:=b.number;
  2094. { function breakpoints have zero as file and as line !!
  2095. but they are valid !! }
  2096. invalid_breakpoint_line:=(b.line_number<>sym.line) and (b.line_number<>0);
  2097. {$ifdef GDB_USES_BP_LOCATION}
  2098. if assigned (b.loc) then
  2099. last_breakpoint_address:=b.loc^.address
  2100. else
  2101. last_breakpoint_address:=0;
  2102. {$else not GDB_USES_BP_LOCATION}
  2103. last_breakpoint_address:=b.address;
  2104. {$endif not GDB_USES_BP_LOCATION}
  2105. last_breakpoint_line:=sym.line;
  2106. if assigned(sym.symtab) then
  2107. last_breakpoint_file:=sym.symtab^.filename
  2108. else
  2109. last_breakpoint_file:=nil;
  2110. end;
  2111. end;
  2112. {$ifdef GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED}
  2113. type
  2114. breakpoint_created_function_type = procedure (bpnum : longint); cdecl;
  2115. pobserver = pointer;
  2116. var
  2117. breakpoint_created_observer : pobserver = nil;
  2118. function observer_attach_breakpoint_created(create_func : breakpoint_created_function_type) : pobserver;cdecl;external;
  2119. procedure observer_detach_breakpoint_created(pob : pobserver);cdecl;external;
  2120. var breakpoint_chain : pbreakpoint ;cvar;external;
  2121. procedure notify_breakpoint_created(bpnum : longint);cdecl;
  2122. var
  2123. pb : pbreakpoint;
  2124. begin
  2125. pb:=breakpoint_chain;
  2126. while assigned(pb) do
  2127. begin
  2128. if pb^.number=bpnum then
  2129. begin
  2130. CreateBreakPointHook(pb^);
  2131. exit;
  2132. end
  2133. else
  2134. pb:=pb^.next;
  2135. end;
  2136. end;
  2137. {$endif def GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED}
  2138. { Avoid loading of main.o object by providing a
  2139. stripped down version of relocate_gdb_directory function }
  2140. function relocate_gdb_directory(path : pchar) : pchar; cdecl; public;
  2141. begin
  2142. relocate_gdb_directory:=path;
  2143. end;
  2144. {*****************************************************************************
  2145. tgdbinterface
  2146. *****************************************************************************}
  2147. constructor tgdbinterface.init;
  2148. begin
  2149. gdboutputbuf.init;
  2150. gdberrorbuf.init;
  2151. record_frames:=true;
  2152. { This must be placed before gdb__init is called
  2153. as gdb_init might issue output PM }
  2154. curr_gdb:=@self;
  2155. gdb__init;
  2156. command_level:=0;
  2157. { set output mode for GDB }
  2158. { only these values disable filtering
  2159. DONT CHANGE THEM !!! PM }
  2160. gdb_command('set width 0xffffffff');
  2161. gdb_command('set height 0xffffffff');
  2162. { other standard commands used for fpc debugging }
  2163. gdb_command('set print demangle off');
  2164. gdb_command('set gnutarget auto');
  2165. gdb_command('set language auto');
  2166. gdb_command('set print vtbl on');
  2167. gdb_command('set print object on');
  2168. gdb_command('set print null-stop');
  2169. {$ifdef USE_MINGW_GDB} // maybe this also should be done for newer cygwin gdbs.
  2170. gdb_command('set confirm off');
  2171. {$endif}
  2172. end;
  2173. destructor tgdbinterface.done;
  2174. begin
  2175. clear_frames;
  2176. gdb_done;
  2177. gdboutputbuf.done;
  2178. gdberrorbuf.done;
  2179. end;
  2180. procedure tgdbinterface.gdb__init;
  2181. begin
  2182. gdboutputbuf.reset;
  2183. gdberrorbuf.reset;
  2184. {$ifdef GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED}
  2185. breakpoint_created_observer:=observer_attach_breakpoint_created(@notify_breakpoint_created);
  2186. {$else not GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED}
  2187. {$ifdef GDB_HAS_DEPRECATED_CBPH}
  2188. deprecated_create_breakpoint_hook:=@CreateBreakPointHook;
  2189. {$else}
  2190. create_breakpoint_hook:=@CreateBreakPointHook;
  2191. {$endif}
  2192. {$endif}
  2193. deprecated_query_hook :=@QueryHook;
  2194. signal_string:=nil;
  2195. signal_name:=nil;
  2196. end;
  2197. procedure tgdbinterface.gdb_done;
  2198. begin
  2199. if debuggee_started then
  2200. begin
  2201. {$ifdef GDB_TARGET_CLOSE_HAS_PTARGET_ARG}
  2202. target_kill;
  2203. target_close(@current_target,1);
  2204. {$else not GDB_TARGET_CLOSE_HAS_PTARGET_ARG}
  2205. current_target.to_kill;
  2206. target_close(1);
  2207. {$endif ndef GDB_TARGET_CLOSE_HAS_PTARGET_ARG}
  2208. end;
  2209. {$ifdef GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED}
  2210. observer_detach_breakpoint_created(breakpoint_created_observer);
  2211. breakpoint_created_observer:=nil;
  2212. {$else not GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED}
  2213. {$ifdef GDB_HAS_DEPRECATED_CBPH}
  2214. deprecated_create_breakpoint_hook:=nil;
  2215. {$else}
  2216. create_breakpoint_hook:=nil;
  2217. {$endif}
  2218. {$endif}
  2219. end;
  2220. procedure tgdbinterface.FlushAll;
  2221. begin
  2222. end;
  2223. function tgdbinterface.Query(question : pchar; args : pchar) : longint;
  2224. begin
  2225. Query:=0;
  2226. end;
  2227. function tgdbinterface.error:boolean;
  2228. begin
  2229. error:=got_error;
  2230. end;
  2231. function tgdbinterface.error_num:longint;
  2232. begin
  2233. error_num:=gdb_error;
  2234. end;
  2235. var
  2236. top_level_val : longint;
  2237. function catch_errors(func : pointer; command : pchar; from_tty,mask : longint) : longint;cdecl;external;
  2238. function gdbint_execute_command(command : pchar; from_tty,mask : longint) : longint;cdecl;
  2239. begin
  2240. gdbint_execute_command:=1;
  2241. execute_command(command,from_tty);
  2242. gdbint_execute_command:=0;
  2243. end;
  2244. {$ifdef cpui386}
  2245. type
  2246. tfpustate = word;
  2247. const
  2248. MaskAllExceptions = $ff;
  2249. {$else}
  2250. type
  2251. tfpustate = longint;
  2252. const
  2253. MaskAllExceptions = 0;
  2254. {$endif}
  2255. procedure SaveFPUState(var control :TFPUState);
  2256. begin
  2257. {$ifdef cpui386}
  2258. asm
  2259. movl control, %edi
  2260. fstcw (%edi)
  2261. end;
  2262. {$else}
  2263. control:=0;
  2264. {$endif}
  2265. end;
  2266. procedure SetFPUState(control : TFPUState);
  2267. begin
  2268. {$ifdef cpui386}
  2269. asm
  2270. fnclex
  2271. fldcw control
  2272. end;
  2273. {$else}
  2274. {$endif}
  2275. end;
  2276. function MaskAllFPUExceptions(control : TFPUState) : TFPUState;
  2277. begin
  2278. {$ifdef cpui386}
  2279. MaskAllFPUExceptions := control or MaskAllExceptions;
  2280. {$endif}
  2281. end;
  2282. procedure tgdbinterface.gdb_command(const s:string);
  2283. var
  2284. command : array[0..256] of char;
  2285. prev_stop_breakpoint_number,
  2286. mask : longint;
  2287. s2 : string;
  2288. old_quit_return,
  2289. old_error_return : jmp_buf;
  2290. control : TFPUState;
  2291. begin
  2292. inc(command_level);
  2293. SaveFPUState(control);
  2294. SetFPUState(MaskAllFPUExceptions(control));
  2295. move(s[1],command,length(s));
  2296. command[length(s)]:=#0;
  2297. old_quit_return:=quit_return;
  2298. old_error_return:=error_return;
  2299. gdb_error:=0;
  2300. got_error:=false;
  2301. if command_level=1 then
  2302. prev_stop_breakpoint_number:=0
  2303. else
  2304. prev_stop_breakpoint_number:=stop_breakpoint_number;
  2305. stop_breakpoint_number:=0;
  2306. { Trap quit commands }
  2307. s2:=s;
  2308. while (length(s2)>0) and ((s2[1]=' ') or (s2[1]=#9)) do
  2309. s2:=copy(s2,2,255);
  2310. if (length(s2)>0) and
  2311. (UpCase(s2[1])='Q') and
  2312. ((length(s2)=1) or
  2313. (s2[2]=' ') or
  2314. ((UpCase(s2[2])='U') and
  2315. ((length(s2)=2) or
  2316. (s2[3]=' ') or
  2317. ((UpCase(s2[3])='I') and
  2318. ((length(s2)=3) or
  2319. (s2[4]=' ') or
  2320. ((UpCase(s2[4])='T') and
  2321. ((length(s2)=4) or
  2322. (s2[5]=' ')
  2323. ))))))) then
  2324. begin
  2325. if not AllowQuit then
  2326. exit;
  2327. end;
  2328. {$ifdef DebugCommand}
  2329. Debug('start of handle_gdb_command ('+s+')');
  2330. {$endif}
  2331. top_level_val:=setjmp(error_return);
  2332. if top_level_val=0 then
  2333. begin
  2334. quit_return:=error_return;
  2335. mask:=longint($ffffffff);
  2336. catch_errors(@gdbint_execute_command,@command,0,mask);
  2337. {$ifdef go32v2}
  2338. reload_fs;
  2339. {$endif go32v2}
  2340. end
  2341. else
  2342. {$ifdef Verbose}
  2343. Debug('error longjmp in handle_gdb_command ('+s+')');
  2344. {$endif}
  2345. ;
  2346. {$ifdef DebugCommand}
  2347. Debug('end of handle_gdb_command ('+s+')');
  2348. {$endif}
  2349. quit_return:=old_quit_return;
  2350. error_return:=old_error_return;
  2351. dec(command_level);
  2352. stop_breakpoint_number:=prev_stop_breakpoint_number;
  2353. SetFPUState(control);
  2354. end;
  2355. procedure tgdbinterface.resize_frames;
  2356. var
  2357. i : longint;
  2358. new_frames : ppframeentry;
  2359. begin
  2360. if (frame_count>=frame_size) then
  2361. begin
  2362. getmem(new_frames,sizeof(pointer)*(frame_count+1));
  2363. for i:=0 to frame_size-1 do
  2364. new_frames[i]:=frames[i];
  2365. if assigned(frames) then
  2366. freemem(frames,sizeof(pointer)*frame_size);
  2367. frames:=new_frames;
  2368. frame_size:=frame_count+1;
  2369. for i:=frame_count to frame_size-1 do
  2370. frames[i]:=new(pframeentry,init);
  2371. end;
  2372. end;
  2373. function tgdbinterface.add_frameentry:pframeentry;
  2374. begin
  2375. resize_frames;
  2376. add_frameentry:=frames[frame_count];
  2377. inc(frame_count);
  2378. end;
  2379. function tgdbinterface.get_frameentry(level : longint) : pframeentry;
  2380. begin
  2381. { only climb values one by one PM }
  2382. if level>=frame_count then
  2383. resize_frames;
  2384. get_frameentry:=frames[level];
  2385. frames[level]^.clear;
  2386. if level>=frame_count then
  2387. inc(frame_count);
  2388. end;
  2389. procedure tgdbinterface.clear_frames;
  2390. var
  2391. i : longint;
  2392. begin
  2393. for i:=0 to frame_size-1 do
  2394. dispose(frames[i],done);
  2395. if assigned(frames) then
  2396. begin
  2397. freemem(frames,sizeof(pointer)*Frame_size);
  2398. frames:=nil;
  2399. end;
  2400. frame_count:=0;
  2401. frame_size:=0;
  2402. end;
  2403. function tgdbinterface.get_current_frame : ptrint;
  2404. begin
  2405. record_frames:=false;
  2406. gdb_command('f');
  2407. get_current_frame:=frame_level;
  2408. record_frames:=true;
  2409. end;
  2410. function tgdbinterface.set_current_frame(level : longint) : boolean;
  2411. var
  2412. s : string;
  2413. begin
  2414. record_frames:=false;
  2415. str(level,s);
  2416. gdb_command('f '+s);
  2417. if level=frame_level then
  2418. set_current_frame:=true
  2419. else
  2420. set_current_frame:=false;
  2421. record_frames:=true;
  2422. end;
  2423. {*****************************************************************************
  2424. Highlevel tgdbinterface
  2425. *****************************************************************************}
  2426. procedure tgdbinterface.GetAddrSyminfo(addr:ptrint;var si:tsyminfo);
  2427. var
  2428. sym : symtab_and_line;
  2429. symbol : psymbol;
  2430. begin
  2431. sym:=find_pc_line(addr,1);
  2432. fillchar(si,sizeof(tsyminfo),0);
  2433. si.address:=addr;
  2434. si.offset:=addr-sym.pc;
  2435. if assigned(sym.symtab) then
  2436. si.fname:=sym.symtab^.filename
  2437. else
  2438. si.fname:=nil;
  2439. si.line:=sym.line;
  2440. symbol:=find_pc_function(addr);
  2441. if assigned(symbol) then
  2442. si.funcname:=symbol^.ginfo._name
  2443. else
  2444. si.funcname:=nil;
  2445. end;
  2446. procedure tgdbinterface.SelectSourceLine(fn:pchar;line:longint);
  2447. begin
  2448. if assigned(fn) then
  2449. DoSelectSourceLine(StrPas(fn),line)
  2450. else
  2451. DoSelectSourceLine('',line);
  2452. end;
  2453. procedure tgdbinterface.StartSession;
  2454. begin
  2455. DoStartSession;
  2456. end;
  2457. procedure tgdbinterface.BreakSession;
  2458. begin
  2459. DoBreakSession;
  2460. end;
  2461. procedure tgdbinterface.EndSession(code:longint);
  2462. begin
  2463. Debuggee_started:=false;
  2464. { inferior_ptid.pid:=0;
  2465. This leads to an assertion failure
  2466. from generic_mount_inferior }
  2467. DoEndSession(code);
  2468. if assigned(signal_name) then
  2469. strdispose(signal_name);
  2470. signal_name:=nil;
  2471. if assigned(signal_string) then
  2472. strdispose(signal_string);
  2473. signal_string:=nil;
  2474. end;
  2475. procedure tgdbinterface.DebuggerScreen;
  2476. begin
  2477. {$ifdef Verbose}
  2478. Debug('|DebuggerScreen|');
  2479. {$endif}
  2480. if user_screen_shown then
  2481. DoDebuggerScreen;
  2482. user_screen_shown:=false;
  2483. end;
  2484. procedure tgdbinterface.UserScreen;
  2485. begin
  2486. {$ifdef Verbose}
  2487. Debug('|UserScreen|');
  2488. {$endif}
  2489. if switch_to_user then
  2490. begin
  2491. if (not user_screen_shown) then
  2492. DoUserScreen;
  2493. user_screen_shown:=true;
  2494. end;
  2495. end;
  2496. {---------------------------------------
  2497. Default Hooks
  2498. ---------------------------------------}
  2499. procedure tgdbinterface.DoSelectSourceLine(const fn:string;line:longint);
  2500. {$ifdef Verbose}
  2501. var
  2502. s : string;
  2503. {$endif}
  2504. begin
  2505. {$ifdef Verbose}
  2506. Str(line,S);
  2507. Debug('|SelectSource '+fn+':'+s+'|');
  2508. {$endif}
  2509. end;
  2510. procedure tgdbinterface.DoStartSession;
  2511. begin
  2512. end;
  2513. procedure tgdbinterface.DoBreakSession;
  2514. begin
  2515. end;
  2516. procedure tgdbinterface.DoEndSession(code:longint);
  2517. begin
  2518. end;
  2519. procedure tgdbinterface.DoUserSignal;
  2520. begin
  2521. end;
  2522. procedure tgdbinterface.DoDebuggerScreen;
  2523. begin
  2524. end;
  2525. procedure tgdbinterface.DoUserScreen;
  2526. begin
  2527. end;
  2528. function tgdbinterface.AllowQuit : boolean;
  2529. begin
  2530. AllowQuit:=true;
  2531. end;
  2532. var
  2533. version : array[0..0] of char;cvar;external;
  2534. {$ifndef GDB_NEEDS_NO_ERROR_INIT}
  2535. { doesn't seem to exist anymore. Seems to work fine without }
  2536. procedure error_init;cdecl;external;
  2537. {$endif GDB_NEEDS_NO_ERROR_INIT}
  2538. function GDBVersion : string;
  2539. begin
  2540. GDBVersion:='GDB '+StrPas(version);
  2541. end;
  2542. const next_exit : pointer = nil;
  2543. procedure DoneLibGDB;
  2544. begin
  2545. exitproc:=next_exit;
  2546. end;
  2547. {$ifdef go32v2}
  2548. var
  2549. c_environ : ppchar;external name '_environ';
  2550. c_argc : longint;external name '___crt0_argc';
  2551. c_argv : ppchar;external name '___crt0_argv';
  2552. procedure ReallocateEnvironUsingCMalloc;
  2553. var
  2554. neededsize , count : longint;
  2555. penv : pchar;
  2556. newenv : ppchar;
  2557. begin
  2558. if not assigned(c_environ) then
  2559. neededsize:=0
  2560. else
  2561. begin
  2562. count:=0;
  2563. penv:=c_environ^;
  2564. while assigned(penv) do
  2565. begin
  2566. inc(count);
  2567. inc(penv,sizeof(pchar));
  2568. end;
  2569. neededsize:=count*sizeof(pchar);
  2570. end;
  2571. newenv:=malloc(neededsize);
  2572. system.move(c_environ,newenv,neededsize);
  2573. c_environ:=newenv;
  2574. end;
  2575. {$endif def go32v2}
  2576. var
  2577. current_directory : pchar; cvar; external;
  2578. gdb_dirbuf : array[0..0] of char; cvar; external;
  2579. CurrentDir : AnsiString;
  2580. const
  2581. DIRBUF_SIZE = 1024;
  2582. procedure InitLibGDB;
  2583. {$ifdef supportexceptions}
  2584. var
  2585. OldSigInt : SignalHandler;
  2586. {$endif supportexceptions}
  2587. {$ifdef GDB_INIT_HAS_ARGV0}
  2588. var
  2589. argv0 : pchar;
  2590. {$endif not GDB_INIT_HAS_ARGV0}
  2591. begin
  2592. {$ifdef go32v2}
  2593. { c_environ:=system.envp; }
  2594. { DJGPP libC presupposes the c_enivron was malloc'ated }
  2595. ReallocateEnvironUsingCMalloc;
  2596. c_argc:=system.argc;
  2597. c_argv:=system.argv;
  2598. {$endif def go32v2}
  2599. {$ifdef supportexceptions}
  2600. {$ifdef go32v2}
  2601. OldSigInt:=Signal(SIGINT,SignalHandler(@SIG_DFL));
  2602. {$else}
  2603. {$ifdef Unix}
  2604. OldSigInt:=fpSignal(SIGINT,SignalHandler(SIG_DFL));
  2605. {$else}
  2606. OldSigInt:=Signal(SIGINT,SignalHandler(SIG_DFL));
  2607. {$endif}
  2608. {$endif}
  2609. {$endif supportexceptions}
  2610. if assigned(gdb_stderr) then
  2611. ui_file_delete(gdb_stderr);
  2612. if assigned(gdb_stdout) then
  2613. ui_file_delete(gdb_stdout);
  2614. gdb_stderr:=mem_fileopen;
  2615. gdb_stdout:=mem_fileopen;
  2616. gdb_stdlog:=gdb_stderr;
  2617. gdb_stdtarg:=gdb_stderr;
  2618. set_ui_file_write(gdb_stdout,@gdbint_ui_file_write);
  2619. set_ui_file_write(gdb_stderr,@gdbint_ui_file_write);
  2620. {$ifndef GDB_NEEDS_NO_ERROR_INIT}
  2621. error_init;
  2622. {$endif GDB_NEEDS_NO_ERROR_INIT}
  2623. {$ifdef GDB_V6}
  2624. // gdb_stdtargin := gdb_stdin;
  2625. gdb_stdtargerr := gdb_stderr;
  2626. {$endif}
  2627. GetDir(0, CurrentDir);
  2628. if length(CurrentDir)<DIRBUF_SIZE then
  2629. strpcopy(@gdb_dirbuf,CurrentDir)
  2630. else
  2631. gdb_dirbuf[0]:=#0;
  2632. current_directory:=@gdb_dirbuf[0];
  2633. next_exit:=exitproc;
  2634. exitproc:=@DoneLibGDB;
  2635. {$ifdef GDB_V6}
  2636. uiout := cli_out_new (gdb_stdout);
  2637. {$endif}
  2638. {$ifdef GDB_INIT_HAS_ARGV0}
  2639. getmem(argv0,length(paramstr(0))+1);
  2640. strpcopy(argv0,paramstr(0));
  2641. gdb_init(argv0);
  2642. freemem(argv0,length(paramstr(0))+1);
  2643. {$else not GDB_INIT_HAS_ARGV0}
  2644. gdb_init;
  2645. {$endif not GDB_INIT_HAS_ARGV0}
  2646. {$ifdef supportexceptions}
  2647. {$ifdef unix}
  2648. fpsignal(SIGINT,OldSigInt);
  2649. {$else}
  2650. Signal(SIGINT,OldSigInt);
  2651. {$endif}
  2652. {$endif supportexceptions}
  2653. if setjmp(error_return)=0 then
  2654. begin
  2655. quit_return:=error_return;
  2656. exit;
  2657. end
  2658. else
  2659. begin
  2660. {$ifdef Verbose}
  2661. Debug('|LongJump to Init|');
  2662. {$endif}
  2663. {$ifdef go32v2}
  2664. RunError(99);
  2665. {$endif def go32v2}
  2666. end;
  2667. WatchDog:=0;
  2668. end;
  2669. {$ifdef GDB_HAS_SYSROOT}
  2670. var gdb_sysroot : pchar; cvar;public;
  2671. gdb_datadir : pchar; cvar;public;
  2672. python_libdir : pchar;cvar;public;
  2673. gdb_sysrootc : char;
  2674. return_child_result : longbool;cvar;public;
  2675. return_child_result_value : longint;cvar;public;
  2676. batch_silent : longbool;cvar;public;
  2677. batch_flag : longbool;cvar;public;
  2678. {$endif}
  2679. {$ifdef GDB_HAS_DEBUG_FILE_DIRECTORY}
  2680. var
  2681. debug_file_directory : pchar; cvar; external;
  2682. {$endif GDB_HAS_DEBUG_FILE_DIRECTORY}
  2683. begin
  2684. {$ifdef GDB_HAS_SYSROOT}
  2685. gdb_sysrootc := #0;
  2686. gdb_sysroot := @gdb_sysrootc;
  2687. gdb_datadir := @gdb_sysrootc;
  2688. python_libdir := @gdb_sysrootc;
  2689. {$endif}
  2690. {$ifdef GDB_HAS_DEBUG_FILE_DIRECTORY}
  2691. debug_file_directory := '/usr/local/lib';
  2692. {$endif GDB_HAS_DEBUG_FILE_DIRECTORY}
  2693. gdb_stderr:=nil;
  2694. gdb_stdout:=nil;
  2695. InitLibGDB;
  2696. end.