gdbint.pp 95 KB

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