gdbint.pp 94 KB

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