fpdebug.pas 98 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998-2000 by Pierre Muller
  5. Debugger call routines for the IDE
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit FPDebug;
  13. interface
  14. {$i globdir.inc}
  15. uses
  16. {$ifdef win32}
  17. Windows,
  18. {$endif win32}
  19. Objects,Dialogs,Drivers,Views,
  20. {$ifndef NODEBUG}
  21. GDBCon,GDBInt,
  22. {$endif NODEBUG}
  23. Menus,
  24. WViews,WEditor,
  25. FPViews;
  26. type
  27. {$ifndef NODEBUG}
  28. PDebugController=^TDebugController;
  29. TDebugController=object(TGDBController)
  30. InvalidSourceLine : boolean;
  31. { if true the current debugger raw will stay in middle of
  32. editor window when debugging PM }
  33. CenterDebuggerRow : boolean;
  34. Disableallinvalidbreakpoints : boolean;
  35. OrigPwd, { pwd at startup }
  36. LastFileName : string;
  37. LastSource : PView; {PsourceWindow !! }
  38. HiddenStepsCount : longint;
  39. { no need to switch if using another terminal }
  40. NoSwitch : boolean;
  41. HasExe : boolean;
  42. RunCount : longint;
  43. WindowWidth : longint;
  44. FPCBreakErrorNumber : longint;
  45. {$ifdef SUPPORT_REMOTE}
  46. isRemoteDebugging:boolean;
  47. {$endif SUPPORT_REMOTE}
  48. constructor Init;
  49. procedure SetExe(const exefn:string);
  50. procedure SetWidth(AWidth : longint);
  51. procedure SetSourceDirs;
  52. destructor Done;
  53. procedure DoSelectSourceline(const fn:string;line:longint);virtual;
  54. { procedure DoStartSession;virtual;
  55. procedure DoBreakSession;virtual;}
  56. procedure DoEndSession(code:longint);virtual;
  57. procedure DoUserSignal;virtual;
  58. procedure AnnotateError;
  59. procedure InsertBreakpoints;
  60. procedure RemoveBreakpoints;
  61. procedure ReadWatches;
  62. procedure RereadWatches;
  63. procedure ResetBreakpointsValues;
  64. procedure DoDebuggerScreen;virtual;
  65. procedure DoUserScreen;virtual;
  66. procedure Reset;virtual;
  67. procedure ResetDebuggerRows;
  68. procedure Run;virtual;
  69. procedure Continue;virtual;
  70. procedure UntilReturn;virtual;
  71. procedure CommandBegin(const s:string);virtual;
  72. procedure CommandEnd(const s:string);virtual;
  73. function IsRunning : boolean;
  74. function AllowQuit : boolean;virtual;
  75. function GetValue(Const expr : string) : pchar;
  76. function GetFramePointer : CORE_ADDR;
  77. function GetLongintAt(addr : CORE_ADDR) : longint;
  78. function GetPointerAt(addr : CORE_ADDR) : CORE_ADDR;
  79. end;
  80. {$endif NODEBUG}
  81. BreakpointType = (bt_function,bt_file_line,bt_watch,
  82. bt_awatch,bt_rwatch,bt_address,bt_invalid);
  83. BreakpointState = (bs_enabled,bs_disabled,bs_deleted,bs_delete_after);
  84. PBreakpointCollection=^TBreakpointCollection;
  85. PBreakpoint=^TBreakpoint;
  86. TBreakpoint=object(TObject)
  87. typ : BreakpointType;
  88. state : BreakpointState;
  89. owner : PBreakpointCollection;
  90. Name : PString; { either function name or expr to watch }
  91. FileName : PString;
  92. OldValue,CurrentValue : Pstring;
  93. Line : Longint; { only used for bt_file_line type }
  94. Conditions : PString; { conditions relative to that breakpoint }
  95. IgnoreCount : Longint; { how many counts should be ignored }
  96. Commands : pchar; { commands that should be executed on breakpoint }
  97. GDBIndex : longint;
  98. GDBState : BreakpointState;
  99. constructor Init_function(Const AFunc : String);
  100. constructor Init_Address(Const AAddress : String);
  101. constructor Init_Empty;
  102. constructor Init_file_line(AFile : String; ALine : longint);
  103. constructor Init_type(atyp : BreakpointType;Const AnExpr : String);
  104. constructor Load(var S: TStream);
  105. procedure Store(var S: TStream);
  106. procedure Insert;
  107. procedure Remove;
  108. procedure Enable;
  109. procedure Disable;
  110. procedure UpdateSource;
  111. procedure ResetValues;
  112. destructor Done;virtual;
  113. end;
  114. TBreakpointCollection=object(TCollection)
  115. function At(Index: Integer): PBreakpoint;
  116. function GetGDB(index : longint) : PBreakpoint;
  117. function GetType(typ : BreakpointType;Const s : String) : PBreakpoint;
  118. function ToggleFileLine(FileName: String;LineNr : Longint) : boolean;
  119. procedure Update;
  120. procedure ShowBreakpoints(W : PFPWindow);
  121. function FindBreakpointAt(Editor : PSourceEditor; Line : longint) : PBreakpoint;
  122. procedure AdaptBreakpoints(Editor : PSourceEditor; Pos, Change : longint);
  123. procedure ShowAllBreakpoints;
  124. end;
  125. PBreakpointItem = ^TBreakpointItem;
  126. TBreakpointItem = object(TObject)
  127. Breakpoint : PBreakpoint;
  128. constructor Init(ABreakpoint : PBreakpoint);
  129. function GetText(MaxLen: Sw_integer): string; virtual;
  130. procedure Selected; virtual;
  131. function GetModuleName: string; virtual;
  132. end;
  133. PBreakpointsListBox = ^TBreakpointsListBox;
  134. TBreakpointsListBox = object(THSListBox)
  135. Transparent : boolean;
  136. NoSelection : boolean;
  137. MaxWidth : Sw_integer;
  138. (* ModuleNames : PStoreCollection; *)
  139. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  140. procedure AddBreakpoint(P: PBreakpointItem); virtual;
  141. function GetText(Item,MaxLen: Sw_Integer): String; virtual;
  142. function GetLocalMenu: PMenu;virtual;
  143. procedure Clear; virtual;
  144. procedure TrackSource; virtual;
  145. procedure EditNew; virtual;
  146. procedure EditCurrent; virtual;
  147. procedure DeleteCurrent; virtual;
  148. procedure ToggleCurrent;
  149. procedure Draw; virtual;
  150. procedure HandleEvent(var Event: TEvent); virtual;
  151. constructor Load(var S: TStream);
  152. procedure Store(var S: TStream);
  153. destructor Done; virtual;
  154. end;
  155. PBreakpointsWindow = ^TBreakpointsWindow;
  156. TBreakpointsWindow = object(TFPDlgWindow)
  157. BreakLB : PBreakpointsListBox;
  158. constructor Init;
  159. procedure AddBreakpoint(ABreakpoint : PBreakpoint);
  160. procedure ClearBreakpoints;
  161. procedure ReloadBreakpoints;
  162. procedure Close; virtual;
  163. procedure SizeLimits(var Min, Max: TPoint);virtual;
  164. procedure HandleEvent(var Event: TEvent); virtual;
  165. procedure Update; virtual;
  166. constructor Load(var S: TStream);
  167. procedure Store(var S: TStream);
  168. destructor Done; virtual;
  169. end;
  170. PBreakpointItemDialog = ^TBreakpointItemDialog;
  171. TBreakpointItemDialog = object(TCenterDialog)
  172. constructor Init(ABreakpoint: PBreakpoint);
  173. function Execute: Word; virtual;
  174. private
  175. Breakpoint : PBreakpoint;
  176. TypeRB : PRadioButtons;
  177. NameIL : PEditorInputLine;
  178. ConditionsIL: PEditorInputLine;
  179. LineIL : PEditorInputLine;
  180. IgnoreIL : PEditorInputLine;
  181. end;
  182. PWatch = ^TWatch;
  183. TWatch = Object(TObject)
  184. constructor Init(s : string);
  185. constructor Load(var S: TStream);
  186. procedure Store(var S: TStream);
  187. procedure rename(s : string);
  188. procedure Get_new_value;
  189. procedure Force_new_value;
  190. destructor done;virtual;
  191. expr : pstring;
  192. private
  193. GDBRunCount : longint;
  194. last_value,current_value : pchar;
  195. end;
  196. PWatchesCollection = ^TWatchesCollection;
  197. TWatchesCollection = Object(TCollection)
  198. constructor Init;
  199. procedure Insert(Item: Pointer); virtual;
  200. function At(Index: Integer): PWatch;
  201. procedure Update;
  202. private
  203. MaxW : integer;
  204. end;
  205. PWatchesListBox = ^TWatchesListBox;
  206. TWatchesListBox = object(THSListBox)
  207. Transparent : boolean;
  208. MaxWidth : Sw_integer;
  209. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  210. (* procedure AddWatch(P: PWatch); virtual; *)
  211. procedure Update(AMaxWidth : integer);
  212. function GetText (Item: Sw_Integer; MaxLen: Sw_Integer): String; Virtual;
  213. function GetIndentedText(Item,Indent,MaxLen: Sw_Integer;var Modified : boolean): String; virtual;
  214. function GetLocalMenu: PMenu;virtual;
  215. (* procedure Clear; virtual;
  216. procedure TrackSource; virtual;*)
  217. procedure EditNew; virtual;
  218. procedure EditCurrent; virtual;
  219. procedure DeleteCurrent; virtual;
  220. (*procedure ToggleCurrent; *)
  221. procedure Draw; virtual;
  222. procedure HandleEvent(var Event: TEvent); virtual;
  223. constructor Load(var S: TStream);
  224. procedure Store(var S: TStream);
  225. destructor Done; virtual;
  226. end;
  227. PWatchItemDialog = ^TWatchItemDialog;
  228. TWatchItemDialog = object(TCenterDialog)
  229. constructor Init(AWatch: PWatch);
  230. function Execute: Word; virtual;
  231. private
  232. Watch : PWatch;
  233. NameIL : PEditorInputLine;
  234. TextST : PAdvancedStaticText;
  235. end;
  236. PWatchesWindow = ^TWatchesWindow;
  237. TWatchesWindow = Object(TFPDlgWindow)
  238. WLB : PWatchesListBox;
  239. Constructor Init;
  240. constructor Load(var S: TStream);
  241. procedure Store(var S: TStream);
  242. procedure Update; virtual;
  243. destructor Done; virtual;
  244. end;
  245. PFramesListBox = ^TFramesListBox;
  246. TFramesListBox = object(TMessageListBox)
  247. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  248. procedure Update;
  249. function GetLocalMenu: PMenu;virtual;
  250. procedure GotoSource; virtual;
  251. procedure GotoAssembly; virtual;
  252. procedure HandleEvent(var Event: TEvent); virtual;
  253. destructor Done; virtual;
  254. end;
  255. PStackWindow = ^TStackWindow;
  256. TStackWindow = Object(TFPDlgWindow)
  257. FLB : PFramesListBox;
  258. Constructor Init;
  259. constructor Load(var S: TStream);
  260. procedure Store(var S: TStream);
  261. procedure Update; virtual;
  262. destructor Done; virtual;
  263. end;
  264. procedure InitStackWindow;
  265. procedure DoneStackWindow;
  266. function ActiveBreakpoints : boolean;
  267. function GDBFileName(st : string) : string;
  268. function OSFileName(st : string) : string;
  269. const
  270. BreakpointTypeStr : Array[BreakpointType] of String[9]
  271. = ( 'function','file-line','watch','awatch','rwatch','address','invalid');
  272. BreakpointStateStr : Array[BreakpointState] of String[8]
  273. = ( 'enabled','disabled','invalid',''{'to be deleted' should never be used});
  274. var
  275. {$ifndef NODEBUG}
  276. Debugger : PDebugController;
  277. {$endif NODEBUG}
  278. BreakpointsCollection : PBreakpointCollection;
  279. WatchesCollection : PwatchesCollection;
  280. procedure InitDebugger;
  281. procedure DoneDebugger;
  282. procedure InitGDBWindow;
  283. procedure DoneGDBWindow;
  284. procedure InitDisassemblyWindow;
  285. procedure DoneDisassemblyWindow;
  286. procedure InitBreakpoints;
  287. procedure DoneBreakpoints;
  288. procedure InitWatches;
  289. procedure DoneWatches;
  290. procedure RegisterFPDebugViews;
  291. procedure UpdateDebugViews;
  292. implementation
  293. uses
  294. Dos,
  295. {$ifdef fpc}
  296. Video,
  297. {$endif fpc}
  298. {$ifdef DOS}
  299. fpusrscr,
  300. {$endif DOS}
  301. App,Strings,
  302. FVConsts,
  303. {$ifdef win32}
  304. Windebug,
  305. {$endif win32}
  306. {$ifdef Unix}
  307. {$ifdef VER1_0}
  308. Linux,
  309. {$else}
  310. termio,
  311. {$endif}
  312. {$endif Unix}
  313. Systems,Globals,
  314. FPRegs,
  315. FPString,FPVars,FPUtils,FPConst,FPSwitch,
  316. FPIntf,FPCompil,FPIde,FPHelp,
  317. Validate,WUtils,Wconsts;
  318. const
  319. RBreakpointsWindow: TStreamRec = (
  320. ObjType: 1701;
  321. VmtLink: Ofs(TypeOf(TBreakpointsWindow)^);
  322. Load: @TBreakpointsWindow.Load;
  323. Store: @TBreakpointsWindow.Store
  324. );
  325. RBreakpointsListBox : TStreamRec = (
  326. ObjType: 1702;
  327. VmtLink: Ofs(TypeOf(TBreakpointsListBox)^);
  328. Load: @TBreakpointsListBox.Load;
  329. Store: @TBreakpointsListBox.Store
  330. );
  331. RWatchesWindow: TStreamRec = (
  332. ObjType: 1703;
  333. VmtLink: Ofs(TypeOf(TWatchesWindow)^);
  334. Load: @TWatchesWindow.Load;
  335. Store: @TWatchesWindow.Store
  336. );
  337. RWatchesListBox: TStreamRec = (
  338. ObjType: 1704;
  339. VmtLink: Ofs(TypeOf(TWatchesListBox)^);
  340. Load: @TWatchesListBox.Load;
  341. Store: @TWatchesListBox.Store
  342. );
  343. RStackWindow: TStreamRec = (
  344. ObjType: 1705;
  345. VmtLink: Ofs(TypeOf(TStackWindow)^);
  346. Load: @TStackWindow.Load;
  347. Store: @TStackWindow.Store
  348. );
  349. RFramesListBox: TStreamRec = (
  350. ObjType: 1706;
  351. VmtLink: Ofs(TypeOf(TFramesListBox)^);
  352. Load: @TFramesListBox.Load;
  353. Store: @TFramesListBox.Store
  354. );
  355. RBreakpoint: TStreamRec = (
  356. ObjType: 1707;
  357. VmtLink: Ofs(TypeOf(TBreakpoint)^);
  358. Load: @TBreakpoint.Load;
  359. Store: @TBreakpoint.Store
  360. );
  361. RWatch: TStreamRec = (
  362. ObjType: 1708;
  363. VmtLink: Ofs(TypeOf(TWatch)^);
  364. Load: @TWatch.Load;
  365. Store: @TWatch.Store
  366. );
  367. RBreakpointCollection: TStreamRec = (
  368. ObjType: 1709;
  369. VmtLink: Ofs(TypeOf(TBreakpointCollection)^);
  370. Load: @TBreakpointCollection.Load;
  371. Store: @TBreakpointCollection.Store
  372. );
  373. RWatchesCollection: TStreamRec = (
  374. ObjType: 1710;
  375. VmtLink: Ofs(TypeOf(TWatchesCollection)^);
  376. Load: @TWatchesCollection.Load;
  377. Store: @TWatchesCollection.Store
  378. );
  379. {$ifdef I386}
  380. const
  381. FrameName = '$ebp';
  382. {$define FrameNameKnown}
  383. {$endif i386}
  384. {$ifdef m68k}
  385. const
  386. FrameName = '$fp';
  387. {$define FrameNameKnown}
  388. {$endif m68k}
  389. {$ifdef powerpc}
  390. { stack and frame registers are the same on powerpc,
  391. so I am not sure that this will work PM }
  392. const
  393. FrameName = '$r1';
  394. {$define FrameNameKnown}
  395. {$endif powerpc}
  396. {$ifdef TP}
  397. function HexStr(Value: longint; Len: byte): string;
  398. begin
  399. HexStr:=IntToHex(Value,Len);
  400. end;
  401. {$endif}
  402. function GDBFileName(st : string) : string;
  403. {$ifndef Unix}
  404. var i : longint;
  405. {$endif Unix}
  406. begin
  407. {$ifdef NODEBUG}
  408. GDBFileName:=st;
  409. {$else NODEBUG}
  410. {$ifdef Unix}
  411. GDBFileName:=st;
  412. {$else}
  413. { should we also use / chars ? }
  414. for i:=1 to Length(st) do
  415. if st[i]='\' then
  416. {$ifdef win32}
  417. { Don't touch at '\ ' used to escapes spaces in windows file names PM }
  418. if (i=length(st)) or (st[i+1]<>' ') then
  419. {$endif win32}
  420. st[i]:='/';
  421. {$ifdef win32}
  422. { for win32 we should convert e:\ into //e/ PM }
  423. if (length(st)>2) and (st[2]=':') and (st[3]='/') then
  424. st:=CygDrivePrefix+'/'+st[1]+copy(st,3,length(st));
  425. { support spaces in the name by escaping them but without changing '\ ' into '\\ ' }
  426. for i:=Length(st) downto 1 do
  427. if (st[i]=' ') and ((i=1) or (st[i-1]<>'\')) then
  428. st:=copy(st,1,i-1)+'\'+copy(st,i,length(st));
  429. {$endif win32}
  430. {$ifdef go32v2}
  431. { for go32v2 we should convert //e/ back into e:/ PM }
  432. if (length(st)>3) and (st[1]='/') and (st[2]='/') and (st[4]='/') then
  433. st:=st[3]+':/'+copy(st,5,length(st));
  434. {$endif go32v2}
  435. GDBFileName:=LowerCaseStr(st);
  436. {$endif}
  437. {$endif NODEBUG}
  438. end;
  439. function OSFileName(st : string) : string;
  440. {$ifndef Unix}
  441. var i : longint;
  442. {$endif Unix}
  443. begin
  444. {$ifdef Unix}
  445. OSFileName:=st;
  446. {$else}
  447. {$ifdef win32}
  448. {$ifndef NODEBUG}
  449. { for win32 we should convert /cygdrive/e/ into e:\ PM }
  450. if pos(CygDrivePrefix+'/',st)=1 then
  451. st:=st[Length(CygdrivePrefix)+2]+':\'+copy(st,length(CygdrivePrefix)+4,length(st));
  452. {$endif NODEBUG}
  453. {$endif win32}
  454. { support spaces in the name by escaping them but without changing '\ ' into '\\ ' }
  455. for i:=Length(st) downto 2 do
  456. if (st[i]=' ') and (st[i-1]='\') then
  457. st:=copy(st,1,i-2)+copy(st,i,length(st));
  458. {$ifdef go32v2}
  459. { for go32v2 we should convert //e/ back into e:/ PM }
  460. if (length(st)>3) and (st[1]='/') and (st[2]='/') and (st[4]='/') then
  461. st:=st[3]+':\'+copy(st,5,length(st));
  462. {$endif go32v2}
  463. { should we also use / chars ? }
  464. for i:=1 to Length(st) do
  465. if st[i]='/' then
  466. st[i]:='\';
  467. OSFileName:=LowerCaseStr(st);
  468. {$endif}
  469. end;
  470. {****************************************************************************
  471. TDebugController
  472. ****************************************************************************}
  473. procedure UpdateDebugViews;
  474. begin
  475. {$ifdef SUPPORT_REMOTE}
  476. PushStatus(msg_getting_info_on+RemoteMachine);
  477. {$endif SUPPORT_REMOTE}
  478. DeskTop^.Lock;
  479. If assigned(StackWindow) then
  480. StackWindow^.Update;
  481. If assigned(RegistersWindow) then
  482. RegistersWindow^.Update;
  483. {$ifndef NODEBUG}
  484. If assigned(Debugger) then
  485. Debugger^.ReadWatches;
  486. {$endif NODEBUG}
  487. If assigned(FPUWindow) then
  488. FPUWindow^.Update;
  489. DeskTop^.UnLock;
  490. {$ifdef SUPPORT_REMOTE}
  491. PopStatus;
  492. {$endif SUPPORT_REMOTE}
  493. end;
  494. {$ifndef NODEBUG}
  495. constructor TDebugController.Init;
  496. begin
  497. inherited Init;
  498. CenterDebuggerRow:=IniCenterDebuggerRow;
  499. Disableallinvalidbreakpoints:=false;
  500. NoSwitch:=False;
  501. HasExe:=false;
  502. Debugger:=@self;
  503. WindowWidth:=-1;
  504. switch_to_user:=true;
  505. GetDir(0,OrigPwd);
  506. Command('set print object off');
  507. end;
  508. procedure TDebugController.SetExe(const exefn:string);
  509. var f : string;
  510. begin
  511. f := GDBFileName(GetShortName(exefn));
  512. if (f<>'') and ExistsFile(exefn) then
  513. begin
  514. LoadFile(f);
  515. HasExe:=true;
  516. Command('b FPC_BREAK_ERROR');
  517. FPCBreakErrorNumber:=last_breakpoint_number;
  518. {$ifdef FrameNameKnown}
  519. { this fails in GDB 5.1 because
  520. GDB replies that there is an attempt to dereference
  521. a generic pointer...
  522. test delayed in DoSourceLine... PM
  523. Command('cond '+IntToStr(FPCBreakErrorNumber)+
  524. ' (('+FrameName+' + 8)^ <> 0) or'+
  525. ' (('+FrameName+' + 12)^ <> 0)'); }
  526. {$endif FrameNameKnown}
  527. SetArgs(GetRunParameters);
  528. SetSourceDirs;
  529. InsertBreakpoints;
  530. ReadWatches;
  531. end
  532. else
  533. begin
  534. HasExe:=false;
  535. Command('file');
  536. end;
  537. end;
  538. procedure TDebugController.SetWidth(AWidth : longint);
  539. begin
  540. WindowWidth:=AWidth;
  541. Command('set width '+inttostr(WindowWidth));
  542. end;
  543. procedure TDebugController.SetSourceDirs;
  544. var f,s: string;
  545. i : longint;
  546. Dir : SearchRec;
  547. begin
  548. f:=GetSourceDirectories+';'+OrigPwd;
  549. repeat
  550. i:=pos(';',f);
  551. if i=0 then
  552. s:=f
  553. else
  554. begin
  555. s:=copy(f,1,i-1);
  556. system.delete(f,1,i);
  557. end;
  558. DefaultReplacements(s);
  559. if (pos('*',s)=0) and ExistsDir(s) then
  560. Command('dir '+GDBFileName(GetShortName(s)))
  561. { we should also handle the /* cases of -Fu option }
  562. else if pos('*',s)>0 then
  563. begin
  564. Dos.FindFirst(s,Directory,Dir);
  565. { the '*' can only be in the last dir level }
  566. s:=DirOf(s);
  567. while Dos.DosError=0 do
  568. begin
  569. if ((Dir.attr and Directory) <> 0) and ExistsDir(s+Dir.Name) then
  570. Command('dir '+GDBFileName(GetShortName(s+Dir.Name)));
  571. Dos.FindNext(Dir);
  572. end;
  573. {$ifdef FPC}
  574. Dos.FindClose(Dir);
  575. {$endif def FPC}
  576. end;
  577. until i=0;
  578. end;
  579. procedure TDebugController.InsertBreakpoints;
  580. procedure DoInsert(PB : PBreakpoint);
  581. begin
  582. PB^.Insert;
  583. end;
  584. begin
  585. BreakpointsCollection^.ForEach(@DoInsert);
  586. Disableallinvalidbreakpoints:=false;
  587. end;
  588. procedure TDebugController.ReadWatches;
  589. procedure DoRead(PB : PWatch);
  590. begin
  591. PB^.Get_new_value;
  592. end;
  593. begin
  594. WatchesCollection^.ForEach(@DoRead);
  595. If Assigned(WatchesWindow) then
  596. WatchesWindow^.Update;
  597. end;
  598. procedure TDebugController.RereadWatches;
  599. procedure DoRead(PB : PWatch);
  600. begin
  601. PB^.Force_new_value;
  602. end;
  603. begin
  604. WatchesCollection^.ForEach(@DoRead);
  605. If Assigned(WatchesWindow) then
  606. WatchesWindow^.Update;
  607. end;
  608. procedure TDebugController.RemoveBreakpoints;
  609. procedure DoDelete(PB : PBreakpoint);
  610. begin
  611. PB^.Remove;
  612. end;
  613. begin
  614. BreakpointsCollection^.ForEach(@DoDelete);
  615. end;
  616. procedure TDebugController.ResetBreakpointsValues;
  617. procedure DoResetVal(PB : PBreakpoint);
  618. begin
  619. PB^.ResetValues;
  620. end;
  621. begin
  622. BreakpointsCollection^.ForEach(@DoResetVal);
  623. end;
  624. destructor TDebugController.Done;
  625. begin
  626. { kill the program if running }
  627. Reset;
  628. RemoveBreakpoints;
  629. inherited Done;
  630. end;
  631. procedure TDebugController.Run;
  632. {$ifdef Unix}
  633. var
  634. Debuggeefile : text;
  635. ResetOK, TTYUsed : boolean;
  636. {$endif Unix}
  637. {$ifdef PALMOSGDB}
  638. const
  639. TargetProtocol = 'palmos';
  640. {$else}
  641. const
  642. TargetProtocol = 'remote';
  643. {$endif PALMOSGDB}
  644. {$ifdef SUPPORT_REMOTE}
  645. var
  646. S,ErrorStr : string;
  647. {$endif SUPPORT_REMOTE}
  648. begin
  649. ResetBreakpointsValues;
  650. {$ifdef SUPPORT_REMOTE}
  651. NoSwitch:=true;
  652. isRemoteDebugging:=false;
  653. {$ifndef CROSSGDB}
  654. If (RemoteMachine<>'') and (RemotePort<>'') then
  655. {$else CROSSGDB}
  656. if true then
  657. {$endif CROSSGDB}
  658. begin
  659. isRemoteDebugging:=true;
  660. S:=RemoteMachine;
  661. If pos('@',S)>0 then
  662. S:=copy(S,pos('@',S)+1,High(S));
  663. If RemotePort<>'' then
  664. S:=S+':'+RemotePort;
  665. {$ifdef PALMOSGDB}
  666. { set the default value for PalmOS }
  667. If S='' then
  668. S:='localhost:2000';
  669. {$endif PALMOSGDB}
  670. PushStatus(msg_connectingto+S);
  671. Command('target '+TargetProtocol+' '+S);
  672. if Error then
  673. begin
  674. ErrorStr:=strpas(GetError);
  675. ErrorBox(#3'Error in "target '+TargetProtocol+'"'#13#3+ErrorStr,nil);
  676. PopStatus;
  677. exit;
  678. end;
  679. PopStatus;
  680. end
  681. else
  682. begin
  683. {$endif SUPPORT_REMOTE}
  684. {$ifdef win32}
  685. { Run the debugge in another console }
  686. if DebuggeeTTY<>'' then
  687. Command('set new-console on')
  688. else
  689. Command('set new-console off');
  690. NoSwitch:=DebuggeeTTY<>'';
  691. {$endif win32}
  692. {$ifdef Unix}
  693. { Run the debuggee in another tty }
  694. if DebuggeeTTY <> '' then
  695. begin
  696. {$I-}
  697. Assign(Debuggeefile,DebuggeeTTY);
  698. system.Reset(Debuggeefile);
  699. ResetOK:=IOResult=0;
  700. If ResetOK and {$ifdef ver1_0}IsATTY(textrec(Debuggeefile).handle){$else}(IsATTY(textrec(Debuggeefile).handle)<>-1){$endif} then
  701. begin
  702. Command('tty '+DebuggeeTTY);
  703. TTYUsed:=true;
  704. end
  705. else
  706. begin
  707. Command('tty ');
  708. TTYUsed:=false;
  709. end;
  710. if ResetOK then
  711. close(Debuggeefile);
  712. if TTYUsed and (DebuggeeTTY<>TTYName(stdout)) then
  713. NoSwitch:= true
  714. else
  715. NoSwitch:=false;
  716. end
  717. else
  718. begin
  719. if TTYName(input)<>'' then
  720. Command('tty '+TTYName(input));
  721. NoSwitch := false;
  722. end;
  723. {$endif Unix}
  724. {$ifdef SUPPORT_REMOTE}
  725. end;
  726. {$endif SUPPORT_REMOTE}
  727. { Switch to user screen to get correct handles }
  728. UserScreen;
  729. { Don't try to print GDB messages while in User Screen mode }
  730. If assigned(GDBWindow) then
  731. GDBWindow^.Editor^.Lock;
  732. {$ifdef SUPPORT_REMOTE}
  733. if isRemoteDebugging then
  734. begin
  735. inc(init_count);
  736. { pass the stop in start code }
  737. Command('continue');
  738. end else
  739. {$endif SUPPORT_REMOTE}
  740. { Set cwd for debuggee }
  741. SetDir(GetRunDir);
  742. inherited Run;
  743. { Restore cwd for IDE }
  744. SetDir(StartupDir);
  745. DebuggerScreen;
  746. If assigned(GDBWindow) then
  747. GDBWindow^.Editor^.UnLock;
  748. IDEApp.SetCmdState([cmResetDebugger,cmUntilReturn],true);
  749. IDEApp.UpdateRunMenu(true);
  750. UpdateDebugViews;
  751. end;
  752. function TDebugController.IsRunning : boolean;
  753. begin
  754. IsRunning:=debuggee_started;
  755. end;
  756. procedure TDebugController.Continue;
  757. begin
  758. {$ifdef NODEBUG}
  759. NoDebugger;
  760. {$else}
  761. if not debuggee_started then
  762. Run
  763. else
  764. inherited Continue;
  765. UpdateDebugViews;
  766. {$endif NODEBUG}
  767. end;
  768. procedure TDebugController.UntilReturn;
  769. begin
  770. Command('finish');
  771. UpdateDebugViews;
  772. { We could try to get the return value !
  773. Not done yet }
  774. end;
  775. procedure TDebugController.CommandBegin(const s:string);
  776. begin
  777. if assigned(GDBWindow) and (in_command>1) then
  778. begin
  779. { We should do something special for errors !! }
  780. If StrLen(GetError)>0 then
  781. GDBWindow^.WriteErrorText(GetError);
  782. GDBWindow^.WriteOutputText(GetOutput);
  783. end;
  784. if assigned(GDBWindow) then
  785. GDBWindow^.WriteString(S);
  786. end;
  787. procedure TDebugController.CommandEnd(const s:string);
  788. begin
  789. if assigned(GDBWindow) and (in_command<=1) then
  790. begin
  791. { We should do something special for errors !! }
  792. If StrLen(GetError)>0 then
  793. GDBWindow^.WriteErrorText(GetError);
  794. GDBWindow^.WriteOutputText(GetOutput);
  795. GDBWindow^.Editor^.TextEnd;
  796. end;
  797. end;
  798. function TDebugController.AllowQuit : boolean;
  799. begin
  800. if IsRunning then
  801. begin
  802. if ConfirmBox('Really quit GDB window'#13+
  803. 'and kill running program?',nil,true)=cmYes then
  804. begin
  805. Reset;
  806. DoneGDBWindow;
  807. {AllowQuit:=true;}
  808. AllowQuit:=false;
  809. end
  810. else
  811. AllowQuit:=false;
  812. end
  813. else if ConfirmBox('Really quit GDB window?',nil,true)=cmYes then
  814. begin
  815. DoneGDBWindow;
  816. {AllowQuit:=true;}
  817. AllowQuit:=false;
  818. end
  819. else
  820. AllowQuit:=false;
  821. end;
  822. procedure TDebugController.ResetDebuggerRows;
  823. procedure ResetDebuggerRow(P: PView); {$ifndef FPC}far;{$endif}
  824. begin
  825. if assigned(P) and
  826. (TypeOf(P^)=TypeOf(TSourceWindow)) then
  827. PSourceWindow(P)^.Editor^.SetLineFlagExclusive(lfDebuggerRow,-1);
  828. end;
  829. begin
  830. Desktop^.ForEach(@ResetDebuggerRow);
  831. end;
  832. procedure TDebugController.Reset;
  833. begin
  834. inherited Reset;
  835. { we need to free the executable
  836. if we want to recompile it }
  837. SetExe('');
  838. NoSwitch:=false;
  839. { In case we have something that the compiler touched }
  840. If IDEApp.IsRunning then
  841. begin
  842. IDEApp.SetCmdState([cmResetDebugger,cmUntilReturn],false);
  843. IDEApp.UpdateRunMenu(false);
  844. AskToReloadAllModifiedFiles;
  845. ResetDebuggerRows;
  846. end;
  847. end;
  848. procedure TDebugController.AnnotateError;
  849. var errornb : longint;
  850. begin
  851. if error then
  852. begin
  853. errornb:=error_num;
  854. UpdateDebugViews;
  855. ErrorBox(#3'Error within GDB'#13#3'Error code = %d',@errornb);
  856. end;
  857. end;
  858. function TDebugController.GetValue(Const expr : string) : pchar;
  859. var
  860. p,p2,p3 : pchar;
  861. begin
  862. if WindowWidth<>-1 then
  863. Command('set width 0xffffffff');
  864. Command('p '+expr);
  865. p:=GetOutput;
  866. p3:=nil;
  867. if assigned(p) and (p[strlen(p)-1]=#10) then
  868. begin
  869. p3:=p+strlen(p)-1;
  870. p3^:=#0;
  871. end;
  872. if assigned(p) then
  873. p2:=strpos(p,'=')
  874. else
  875. p2:=nil;
  876. if assigned(p2) then
  877. p:=p2+1;
  878. while p^ in [' ',TAB] do
  879. inc(p);
  880. { get rid of type }
  881. if p^ = '(' then
  882. p:=strpos(p,')')+1;
  883. while p^ in [' ',TAB] do
  884. inc(p);
  885. if assigned(p) then
  886. GetValue:=StrNew(p)
  887. else
  888. GetValue:=StrNew(GetError);
  889. if assigned(p3) then
  890. p3^:=#10;
  891. got_error:=false;
  892. if WindowWidth<>-1 then
  893. Command('set width '+IntToStr(WindowWidth));
  894. end;
  895. function TDebugController.GetFramePointer : CORE_ADDR;
  896. var
  897. st : string;
  898. p : longint;
  899. begin
  900. {$ifdef FrameNameKnown}
  901. Command('p /d '+FrameName);
  902. st:=strpas(GetOutput);
  903. p:=pos('=',st);
  904. while (p<length(st)) and (st[p+1] in [' ',#9]) do
  905. inc(p);
  906. Delete(st,1,p);
  907. p:=1;
  908. while (st[p] in ['0'..'9']) do
  909. inc(p);
  910. Delete(st,p,High(st));
  911. GetFramePointer:=StrToCard(st);
  912. {$else not FrameNameKnown}
  913. GetFramePointer:=0;
  914. {$endif not FrameNameKnown}
  915. end;
  916. function TDebugController.GetLongintAt(addr : CORE_ADDR) : longint;
  917. var
  918. st : string;
  919. p : longint;
  920. begin
  921. Command('x /wd 0x'+hexstr(longint(addr),8));
  922. st:=strpas(GetOutput);
  923. p:=pos(':',st);
  924. while (p<length(st)) and (st[p+1] in [' ',#9]) do
  925. inc(p);
  926. Delete(st,1,p);
  927. p:=1;
  928. while (st[p] in ['0'..'9']) do
  929. inc(p);
  930. Delete(st,p,High(st));
  931. GetLongintAt:=StrToInt(st);
  932. end;
  933. function TDebugController.GetPointerAt(addr : CORE_ADDR) : CORE_ADDR;
  934. var
  935. st : string;
  936. p : longint;
  937. begin
  938. Command('x /wx 0x'+hexstr(longint(addr),8));
  939. st:=strpas(GetOutput);
  940. p:=pos(':',st);
  941. while (p<length(st)) and (st[p+1] in [' ',#9]) do
  942. inc(p);
  943. if (p<length(st)) and (st[p+1]='$') then
  944. inc(p);
  945. Delete(st,1,p);
  946. p:=1;
  947. while (st[p] in ['0'..'9','A'..'F','a'..'f']) do
  948. inc(p);
  949. Delete(st,p,High(st));
  950. GetPointerAt:=HexToCard(st);
  951. end;
  952. procedure TDebugController.DoSelectSourceLine(const fn:string;line:longint);
  953. var
  954. W: PSourceWindow;
  955. Found : boolean;
  956. PB : PBreakpoint;
  957. S : String;
  958. BreakIndex : longint;
  959. stop_addr : CORE_ADDR;
  960. i,ExitCode : longint;
  961. ExitAddr,ExitFrame : CORE_ADDR;
  962. const
  963. FirstArgOffset = 2 * sizeof(CORE_ADDR);
  964. SecondArgOffset = 3 * sizeof(CORE_ADDR);
  965. ThirdArgOffset = 4 * sizeof(CORE_ADDR);
  966. begin
  967. BreakIndex:=stop_breakpoint_number;
  968. Desktop^.Lock;
  969. { 0 based line count in Editor }
  970. if Line>0 then
  971. dec(Line);
  972. S:=fn;
  973. stop_addr:=current_pc;
  974. if (BreakIndex=FPCBreakErrorNumber) then
  975. begin
  976. { Procedure HandleErrorAddrFrame
  977. (Errno : longint;addr,frame : longint);
  978. [public,alias:'FPC_BREAK_ERROR']; }
  979. {$ifdef FrameNameKnown}
  980. ExitCode:=GetLongintAt(GetFramePointer+FirstArgOffset);
  981. ExitAddr:=GetPointerAt(GetFramePointer+SecondArgOffset);
  982. ExitFrame:=GetPointerAt(GetFramePointer+ThirdArgOffset);
  983. if (ExitCode=0) and (ExitAddr=0) then
  984. begin
  985. Desktop^.Unlock;
  986. Command('continue');
  987. exit;
  988. end;
  989. { forget all old frames }
  990. clear_frames;
  991. { record new frames }
  992. Command('backtrace');
  993. for i:=0 to frame_count-1 do
  994. begin
  995. with frames[i]^ do
  996. begin
  997. if ExitAddr=address then
  998. begin
  999. Command('f '+IntToStr(i));
  1000. if assigned(file_name) then
  1001. begin
  1002. s:=strpas(file_name);
  1003. line:=line_number;
  1004. stop_addr:=address;
  1005. end;
  1006. break;
  1007. end;
  1008. end;
  1009. end;
  1010. {$endif FrameNameKnown}
  1011. end;
  1012. { Update Disassembly position }
  1013. if Assigned(DisassemblyWindow) then
  1014. DisassemblyWindow^.SetCurAddress(stop_addr);
  1015. if (fn=LastFileName) then
  1016. begin
  1017. W:=PSourceWindow(LastSource);
  1018. if assigned(W) then
  1019. begin
  1020. W^.Editor^.SetCurPtr(0,Line);
  1021. W^.Editor^.TrackCursor(CenterDebuggerRow);
  1022. W^.Editor^.SetLineFlagExclusive(lfDebuggerRow,Line);
  1023. UpdateDebugViews;
  1024. {if Not assigned(GDBWindow) or not GDBWindow^.GetState(sfActive) then
  1025. handled by SelectInDebugSession}
  1026. W^.SelectInDebugSession;
  1027. InvalidSourceLine:=false;
  1028. end
  1029. else
  1030. InvalidSourceLine:=true;
  1031. end
  1032. else
  1033. begin
  1034. if s='' then
  1035. W:=nil
  1036. else
  1037. W:=TryToOpenFile(nil,s,0,Line,false);
  1038. if assigned(W) then
  1039. begin
  1040. W^.Editor^.SetLineFlagExclusive(lfDebuggerRow,Line);
  1041. W^.Editor^.TrackCursor(CenterDebuggerRow);
  1042. UpdateDebugViews;
  1043. {if Not assigned(GDBWindow) or not GDBWindow^.GetState(sfActive) then
  1044. handled by SelectInDebugSession}
  1045. W^.SelectInDebugSession;
  1046. LastSource:=W;
  1047. InvalidSourceLine:=false;
  1048. end
  1049. { only search a file once }
  1050. else
  1051. begin
  1052. Desktop^.UnLock;
  1053. if s='' then
  1054. Found:=false
  1055. else
  1056. { it is easier to handle with a * at the end }
  1057. Found:=IDEApp.OpenSearch(s+'*');
  1058. Desktop^.Lock;
  1059. if not Found then
  1060. begin
  1061. InvalidSourceLine:=true;
  1062. LastSource:=Nil;
  1063. { Show the stack in that case }
  1064. InitStackWindow;
  1065. UpdateDebugViews;
  1066. StackWindow^.MakeFirst;
  1067. end
  1068. else
  1069. begin
  1070. { should now be open }
  1071. W:=TryToOpenFile(nil,s,0,Line,true);
  1072. W^.Editor^.SetLineFlagExclusive(lfDebuggerRow,Line);
  1073. W^.Editor^.TrackCursor(CenterDebuggerRow);
  1074. UpdateDebugViews;
  1075. {if Not assigned(GDBWindow) or not GDBWindow^.GetState(sfActive) then
  1076. handled by SelectInDebugSession}
  1077. W^.SelectInDebugSession;
  1078. LastSource:=W;
  1079. InvalidSourceLine:=false;
  1080. end;
  1081. end;
  1082. end;
  1083. LastFileName:=s;
  1084. Desktop^.UnLock;
  1085. if BreakIndex>0 then
  1086. begin
  1087. PB:=BreakpointsCollection^.GetGDB(BreakIndex);
  1088. if (BreakIndex=FPCBreakErrorNumber) then
  1089. begin
  1090. if (ExitCode<>0) or (ExitAddr<>0) then
  1091. WarningBox(#3'Run Time Error '+IntToStr(ExitCode)+#13+
  1092. #3'Error address $'+IntToHex(ExitAddr,8),nil)
  1093. else
  1094. WarningBox(#3'Run Time Error',nil);
  1095. end
  1096. else if not assigned(PB) then
  1097. begin
  1098. WarningBox(#3'Stopped by breakpoint '+IntToStr(BreakIndex),nil);
  1099. end
  1100. { For watch we should get old and new value !! }
  1101. else if (Not assigned(GDBWindow) or not GDBWindow^.GetState(sfActive)) and
  1102. (PB^.typ<>bt_file_line) and (PB^.typ<>bt_function) and
  1103. (PB^.typ<>bt_address) then
  1104. begin
  1105. Command('p '+GetStr(PB^.Name));
  1106. S:=GetPChar(GetOutput);
  1107. got_error:=false;
  1108. If Pos('=',S)>0 then
  1109. S:=Copy(S,Pos('=',S)+1,255);
  1110. If S[Length(S)]=#10 then
  1111. Delete(S,Length(S),1);
  1112. if Assigned(PB^.OldValue) then
  1113. DisposeStr(PB^.OldValue);
  1114. PB^.OldValue:=PB^.CurrentValue;
  1115. PB^.CurrentValue:=NewStr(S);
  1116. If PB^.typ=bt_function then
  1117. WarningBox(#3'GDB stopped due to'#13+
  1118. #3+BreakpointTypeStr[PB^.typ]+' '+GetStr(PB^.Name),nil)
  1119. else if (GetStr(PB^.OldValue)<>S) then
  1120. WarningBox(#3'GDB stopped due to'#13+
  1121. #3+BreakpointTypeStr[PB^.typ]+' '+GetStr(PB^.Name)+#13+
  1122. #3+'Old value = '+GetStr(PB^.OldValue)+#13+
  1123. #3+'New value = '+GetStr(PB^.CurrentValue),nil)
  1124. else
  1125. WarningBox(#3'GDB stopped due to'#13+
  1126. #3+BreakpointTypeStr[PB^.typ]+' '+GetStr(PB^.Name)+#13+
  1127. #3+' value = '+GetStr(PB^.CurrentValue),nil);
  1128. end;
  1129. end;
  1130. end;
  1131. procedure TDebugController.DoUserSignal;
  1132. var P :Array[1..2] of pstring;
  1133. S1, S2 : string;
  1134. begin
  1135. S1:=strpas(signal_name);
  1136. S2:=strpas(signal_string);
  1137. P[1]:=@S1;
  1138. P[2]:=@S2;
  1139. WarningBox(msg_programsignal,@P);
  1140. end;
  1141. procedure TDebugController.DoEndSession(code:longint);
  1142. var P :Array[1..2] of longint;
  1143. begin
  1144. IDEApp.SetCmdState([cmUntilReturn,cmResetDebugger],false);
  1145. IDEApp.UpdateRunMenu(false);
  1146. ResetDebuggerRows;
  1147. LastExitCode:=Code;
  1148. If HiddenStepsCount=0 then
  1149. InformationBox(msg_programexitedwithexitcode,@code)
  1150. else
  1151. begin
  1152. P[1]:=code;
  1153. P[2]:=HiddenStepsCount;
  1154. WarningBox(msg_programexitedwithcodeandsteps,@P);
  1155. end;
  1156. { In case we have something that the compiler touched }
  1157. AskToReloadAllModifiedFiles;
  1158. {$ifdef win32}
  1159. main_pid_valid:=false;
  1160. {$endif win32}
  1161. end;
  1162. procedure TDebugController.DoDebuggerScreen;
  1163. {$ifdef win32}
  1164. var
  1165. IdeMode : DWord;
  1166. {$endif win32}
  1167. begin
  1168. if NoSwitch then
  1169. begin
  1170. PopStatus;
  1171. end
  1172. else
  1173. begin
  1174. IDEApp.ShowIDEScreen;
  1175. Message(Application,evBroadcast,cmDebuggerStopped,pointer(RunCount));
  1176. PopStatus;
  1177. end;
  1178. {$ifdef win32}
  1179. if NoSwitch then
  1180. begin
  1181. { Ctrl-C as normal char }
  1182. GetConsoleMode(GetStdHandle(cardinal(Std_Input_Handle)), @IdeMode);
  1183. IdeMode:=(IdeMode or ENABLE_MOUSE_INPUT or ENABLE_WINDOW_INPUT) and not ENABLE_PROCESSED_INPUT;
  1184. SetConsoleMode(GetStdHandle(cardinal(Std_Input_Handle)), IdeMode);
  1185. end;
  1186. ChangeDebuggeeWindowTitleTo(Stopped_State);
  1187. {$endif win32}
  1188. end;
  1189. procedure TDebugController.DoUserScreen;
  1190. {$ifdef win32}
  1191. var
  1192. IdeMode : DWord;
  1193. {$endif win32}
  1194. begin
  1195. Inc(RunCount);
  1196. if NoSwitch then
  1197. begin
  1198. {$ifdef SUPPORT_REMOTE}
  1199. PushStatus(msg_runningremotely+RemoteMachine);
  1200. {$else not SUPPORT_REMOTE}
  1201. {$ifdef Unix}
  1202. PushStatus(msg_runninginanotherwindow+DebuggeeTTY);
  1203. {$else not Unix}
  1204. PushStatus(msg_runninginanotherwindow);
  1205. {$endif Unix}
  1206. {$endif not SUPPORT_REMOTE}
  1207. end
  1208. else
  1209. begin
  1210. PushStatus(msg_runningprogram);
  1211. IDEApp.ShowUserScreen;
  1212. end;
  1213. {$ifdef win32}
  1214. if NoSwitch then
  1215. begin
  1216. { Ctrl-C as interrupt }
  1217. GetConsoleMode(GetStdHandle(cardinal(Std_Input_Handle)), @IdeMode);
  1218. IdeMode:=(IdeMode or ENABLE_MOUSE_INPUT or ENABLE_PROCESSED_INPUT or ENABLE_WINDOW_INPUT);
  1219. SetConsoleMode(GetStdHandle(cardinal(Std_Input_Handle)), IdeMode);
  1220. end;
  1221. ChangeDebuggeeWindowTitleTo(Running_State);
  1222. {$endif win32}
  1223. end;
  1224. {$endif NODEBUG}
  1225. {****************************************************************************
  1226. TBreakpoint
  1227. ****************************************************************************}
  1228. function ActiveBreakpoints : boolean;
  1229. var
  1230. IsActive : boolean;
  1231. procedure TestActive(PB : PBreakpoint);
  1232. begin
  1233. If PB^.state=bs_enabled then
  1234. IsActive:=true;
  1235. end;
  1236. begin
  1237. IsActive:=false;
  1238. If assigned(BreakpointsCollection) then
  1239. BreakpointsCollection^.ForEach(@TestActive);
  1240. ActiveBreakpoints:=IsActive;
  1241. end;
  1242. constructor TBreakpoint.Init_function(Const AFunc : String);
  1243. begin
  1244. typ:=bt_function;
  1245. state:=bs_enabled;
  1246. GDBState:=bs_deleted;
  1247. Name:=NewStr(AFunc);
  1248. FileName:=nil;
  1249. Line:=0;
  1250. IgnoreCount:=0;
  1251. Commands:=nil;
  1252. Conditions:=nil;
  1253. OldValue:=nil;
  1254. CurrentValue:=nil;
  1255. end;
  1256. constructor TBreakpoint.Init_Address(Const AAddress : String);
  1257. begin
  1258. typ:=bt_address;
  1259. state:=bs_enabled;
  1260. GDBState:=bs_deleted;
  1261. Name:=NewStr(AAddress);
  1262. FileName:=nil;
  1263. Line:=0;
  1264. IgnoreCount:=0;
  1265. Commands:=nil;
  1266. Conditions:=nil;
  1267. OldValue:=nil;
  1268. CurrentValue:=nil;
  1269. end;
  1270. constructor TBreakpoint.Init_Empty;
  1271. begin
  1272. typ:=bt_function;
  1273. state:=bs_enabled;
  1274. GDBState:=bs_deleted;
  1275. Name:=Nil;
  1276. FileName:=nil;
  1277. Line:=0;
  1278. IgnoreCount:=0;
  1279. Commands:=nil;
  1280. Conditions:=nil;
  1281. OldValue:=nil;
  1282. CurrentValue:=nil;
  1283. end;
  1284. constructor TBreakpoint.Init_type(atyp : BreakpointType;Const AnExpr : String);
  1285. begin
  1286. typ:=atyp;
  1287. state:=bs_enabled;
  1288. GDBState:=bs_deleted;
  1289. Name:=NewStr(AnExpr);
  1290. IgnoreCount:=0;
  1291. Commands:=nil;
  1292. Conditions:=nil;
  1293. OldValue:=nil;
  1294. CurrentValue:=nil;
  1295. end;
  1296. constructor TBreakpoint.Init_file_line(AFile : String; ALine : longint);
  1297. var
  1298. CurDir : String;
  1299. begin
  1300. typ:=bt_file_line;
  1301. state:=bs_enabled;
  1302. GDBState:=bs_deleted;
  1303. AFile:=FEXpand(AFile);
  1304. (*
  1305. { d:test.pas:12 does not work !! }
  1306. { I do not know how to solve this if
  1307. if (Length(AFile)>1) and (AFile[2]=':') then
  1308. AFile:=Copy(AFile,3,255); }
  1309. {$ifdef Unix}
  1310. CurDir:=GetCurDir;
  1311. {$else}
  1312. CurDir:=LowerCaseStr(GetCurDir);
  1313. {$endif Unix}
  1314. if Pos(CurDir,OSFileName(AFile))=1 then
  1315. FileName:=NewStr(Copy(OSFileName(AFile),length(CurDir)+1,255))
  1316. else
  1317. *)
  1318. FileName:=NewStr(OSFileName(AFile));
  1319. Name:=nil;
  1320. Line:=ALine;
  1321. IgnoreCount:=0;
  1322. Commands:=nil;
  1323. Conditions:=nil;
  1324. OldValue:=nil;
  1325. CurrentValue:=nil;
  1326. end;
  1327. constructor TBreakpoint.Load(var S: TStream);
  1328. var
  1329. FName : PString;
  1330. begin
  1331. S.Read(typ,SizeOf(BreakpointType));
  1332. S.Read(state,SizeOf(BreakpointState));
  1333. GDBState:=bs_deleted;
  1334. case typ of
  1335. bt_file_line :
  1336. begin
  1337. { convert to current target }
  1338. FName:=S.ReadStr;
  1339. FileName:=NewStr(OSFileName(GetStr(FName)));
  1340. If Assigned(FName) then
  1341. DisposeStr(FName);
  1342. S.Read(Line,SizeOf(Line));
  1343. Name:=nil;
  1344. end;
  1345. else
  1346. begin
  1347. Name:=S.ReadStr;
  1348. Line:=0;
  1349. FileName:=nil;
  1350. end;
  1351. end;
  1352. S.Read(IgnoreCount,SizeOf(IgnoreCount));
  1353. Commands:=S.StrRead;
  1354. Conditions:=S.ReadStr;
  1355. OldValue:=nil;
  1356. CurrentValue:=nil;
  1357. end;
  1358. procedure TBreakpoint.Store(var S: TStream);
  1359. var
  1360. St : String;
  1361. begin
  1362. S.Write(typ,SizeOf(BreakpointType));
  1363. S.Write(state,SizeOf(BreakpointState));
  1364. case typ of
  1365. bt_file_line :
  1366. begin
  1367. st:=OSFileName(GetStr(FileName));
  1368. S.WriteStr(@St);
  1369. S.Write(Line,SizeOf(Line));
  1370. end;
  1371. else
  1372. begin
  1373. S.WriteStr(Name);
  1374. end;
  1375. end;
  1376. S.Write(IgnoreCount,SizeOf(IgnoreCount));
  1377. S.StrWrite(Commands);
  1378. S.WriteStr(Conditions);
  1379. end;
  1380. procedure TBreakpoint.Insert;
  1381. var
  1382. p,p2 : pchar;
  1383. st : string;
  1384. begin
  1385. {$ifndef NODEBUG}
  1386. If not assigned(Debugger) then Exit;
  1387. Remove;
  1388. Debugger^.last_breakpoint_number:=0;
  1389. if (GDBState=bs_deleted) and (state=bs_enabled) then
  1390. begin
  1391. if (typ=bt_file_line) and assigned(FileName) then
  1392. Debugger^.Command('break '+GDBFileName(NameAndExtOf(GetStr(FileName)))+':'+IntToStr(Line))
  1393. else if (typ=bt_function) and assigned(name) then
  1394. Debugger^.Command('break '+name^)
  1395. else if (typ=bt_address) and assigned(name) then
  1396. Debugger^.Command('break *0x'+name^)
  1397. else if (typ=bt_watch) and assigned(name) then
  1398. Debugger^.Command('watch '+name^)
  1399. else if (typ=bt_awatch) and assigned(name) then
  1400. Debugger^.Command('awatch '+name^)
  1401. else if (typ=bt_rwatch) and assigned(name) then
  1402. Debugger^.Command('rwatch '+name^);
  1403. if Debugger^.last_breakpoint_number<>0 then
  1404. begin
  1405. GDBIndex:=Debugger^.last_breakpoint_number;
  1406. GDBState:=bs_enabled;
  1407. Debugger^.Command('cond '+IntToStr(GDBIndex)+' '+GetStr(Conditions));
  1408. If IgnoreCount>0 then
  1409. Debugger^.Command('ignore '+IntToStr(GDBIndex)+' '+IntToStr(IgnoreCount));
  1410. If Assigned(Commands) then
  1411. begin
  1412. {Commands are not handled yet }
  1413. Debugger^.Command('command '+IntToStr(GDBIndex));
  1414. p:=commands;
  1415. while assigned(p) do
  1416. begin
  1417. p2:=strscan(p,#10);
  1418. if assigned(p2) then
  1419. p2^:=#0;
  1420. st:=strpas(p);
  1421. Debugger^.command(st);
  1422. if assigned(p2) then
  1423. p2^:=#10;
  1424. p:=p2;
  1425. if assigned(p) then
  1426. inc(p);
  1427. end;
  1428. Debugger^.Command('end');
  1429. end;
  1430. end
  1431. else
  1432. { Here there was a problem !! }
  1433. begin
  1434. GDBIndex:=0;
  1435. if not Debugger^.Disableallinvalidbreakpoints then
  1436. begin
  1437. if (typ=bt_file_line) and assigned(FileName) then
  1438. begin
  1439. ClearFormatParams;
  1440. AddFormatParamStr(NameAndExtOf(FileName^));
  1441. AddFormatParamInt(Line);
  1442. if ChoiceBox(msg_couldnotsetbreakpointat,@FormatParams,[btn_ok,button_DisableAllBreakpoints],false)=cmUserBtn2 then
  1443. Debugger^.Disableallinvalidbreakpoints:=true;
  1444. end
  1445. else
  1446. begin
  1447. ClearFormatParams;
  1448. AddFormatParamStr(BreakpointTypeStr[typ]);
  1449. AddFormatParamStr(GetStr(Name));
  1450. if ChoiceBox(msg_couldnotsetbreakpointtype,@FormatParams,[btn_ok,button_DisableAllBreakpoints],false)=cmUserBtn2 then
  1451. Debugger^.Disableallinvalidbreakpoints:=true;
  1452. end;
  1453. end;
  1454. state:=bs_disabled;
  1455. UpdateSource;
  1456. end;
  1457. end
  1458. else if (GDBState=bs_disabled) and (state=bs_enabled) then
  1459. Enable
  1460. else if (GDBState=bs_enabled) and (state=bs_disabled) then
  1461. Disable;
  1462. {$endif NODEBUG}
  1463. end;
  1464. procedure TBreakpoint.Remove;
  1465. begin
  1466. {$ifndef NODEBUG}
  1467. If not assigned(Debugger) then Exit;
  1468. if GDBIndex>0 then
  1469. Debugger^.Command('delete '+IntToStr(GDBIndex));
  1470. GDBIndex:=0;
  1471. GDBState:=bs_deleted;
  1472. {$endif NODEBUG}
  1473. end;
  1474. procedure TBreakpoint.Enable;
  1475. begin
  1476. {$ifndef NODEBUG}
  1477. If not assigned(Debugger) then Exit;
  1478. if GDBIndex>0 then
  1479. Debugger^.Command('enable '+IntToStr(GDBIndex))
  1480. else
  1481. Insert;
  1482. GDBState:=bs_disabled;
  1483. {$endif NODEBUG}
  1484. end;
  1485. procedure TBreakpoint.Disable;
  1486. begin
  1487. {$ifndef NODEBUG}
  1488. If not assigned(Debugger) then Exit;
  1489. if GDBIndex>0 then
  1490. Debugger^.Command('disable '+IntToStr(GDBIndex));
  1491. GDBState:=bs_disabled;
  1492. {$endif NODEBUG}
  1493. end;
  1494. procedure TBreakpoint.ResetValues;
  1495. begin
  1496. if assigned(OldValue) then
  1497. DisposeStr(OldValue);
  1498. OldValue:=nil;
  1499. if assigned(CurrentValue) then
  1500. DisposeStr(CurrentValue);
  1501. CurrentValue:=nil;
  1502. end;
  1503. procedure TBreakpoint.UpdateSource;
  1504. var W: PSourceWindow;
  1505. b : boolean;
  1506. begin
  1507. if typ=bt_file_line then
  1508. begin
  1509. W:=SearchOnDesktop(OSFileName(GetStr(FileName)),false);
  1510. If assigned(W) then
  1511. begin
  1512. if state=bs_enabled then
  1513. b:=true
  1514. else
  1515. b:=false;
  1516. W^.Editor^.SetLineFlagState(Line-1,lfBreakpoint,b);
  1517. end;
  1518. end;
  1519. end;
  1520. destructor TBreakpoint.Done;
  1521. begin
  1522. Remove;
  1523. ResetValues;
  1524. if assigned(Name) then
  1525. DisposeStr(Name);
  1526. if assigned(FileName) then
  1527. DisposeStr(FileName);
  1528. if assigned(Conditions) then
  1529. DisposeStr(Conditions);
  1530. if assigned(Commands) then
  1531. StrDispose(Commands);
  1532. inherited Done;
  1533. end;
  1534. {****************************************************************************
  1535. TBreakpointCollection
  1536. ****************************************************************************}
  1537. function TBreakpointCollection.At(Index: Integer): PBreakpoint;
  1538. begin
  1539. At:=inherited At(Index);
  1540. end;
  1541. procedure TBreakpointCollection.Update;
  1542. begin
  1543. {$ifndef NODEBUG}
  1544. if assigned(Debugger) then
  1545. begin
  1546. Debugger^.RemoveBreakpoints;
  1547. Debugger^.InsertBreakpoints;
  1548. end;
  1549. {$endif NODEBUG}
  1550. if assigned(BreakpointsWindow) then
  1551. BreakpointsWindow^.Update;
  1552. end;
  1553. function TBreakpointCollection.GetGDB(index : longint) : PBreakpoint;
  1554. function IsNum(P : PBreakpoint) : boolean;{$ifndef FPC}far;{$endif}
  1555. begin
  1556. IsNum:=P^.GDBIndex=index;
  1557. end;
  1558. begin
  1559. if index=0 then
  1560. GetGDB:=nil
  1561. else
  1562. GetGDB:=FirstThat(@IsNum);
  1563. end;
  1564. procedure TBreakpointCollection.ShowBreakpoints(W : PFPWindow);
  1565. procedure SetInSource(P : PBreakpoint);{$ifndef FPC}far;{$endif}
  1566. begin
  1567. If assigned(P^.FileName) and
  1568. (OSFileName(P^.FileName^)=OSFileName(FExpand(PSourceWindow(W)^.Editor^.FileName))) then
  1569. PSourceWindow(W)^.Editor^.SetLineFlagState(P^.Line-1,lfBreakpoint,P^.state=bs_enabled);
  1570. end;
  1571. procedure SetInDisassembly(P : PBreakpoint);{$ifndef FPC}far;{$endif}
  1572. var
  1573. PDL : PDisasLine;
  1574. S : string;
  1575. ps,qs,i : longint;
  1576. begin
  1577. for i:=0 to PDisassemblyWindow(W)^.Editor^.GetLineCount-1 do
  1578. begin
  1579. PDL:=PDisasLine(PDisassemblyWindow(W)^.Editor^.GetLine(i));
  1580. if PDL^.Address=0 then
  1581. begin
  1582. if (P^.typ=bt_file_line) then
  1583. begin
  1584. S:=PDisassemblyWindow(W)^.Editor^.GetDisplayText(i);
  1585. ps:=pos(':',S);
  1586. qs:=pos(' ',copy(S,ps+1,High(S)));
  1587. if (GDBFileName(P^.FileName^)=GDBFileName(FExpand(Copy(S,1,ps-1)))) and
  1588. (StrToInt(copy(S,ps+1,qs-1))=P^.line) then
  1589. PDisassemblyWindow(W)^.Editor^.SetLineFlagState(i,lfBreakpoint,P^.state=bs_enabled);
  1590. end;
  1591. end
  1592. else
  1593. begin
  1594. If (P^.typ=bt_address) and (PDL^.Address=HexToCard(P^.Name^)) then
  1595. PDisassemblyWindow(W)^.Editor^.SetLineFlagState(i,lfBreakpoint,P^.state=bs_enabled);
  1596. end;
  1597. end;
  1598. end;
  1599. begin
  1600. if W=PFPWindow(DisassemblyWindow) then
  1601. ForEach(@SetInDisassembly)
  1602. else
  1603. ForEach(@SetInSource);
  1604. end;
  1605. procedure TBreakpointCollection.AdaptBreakpoints(Editor : PSourceEditor; Pos, Change : longint);
  1606. procedure AdaptInSource(P : PBreakpoint);{$ifndef FPC}far;{$endif}
  1607. begin
  1608. If assigned(P^.FileName) and
  1609. (P^.FileName^=OSFileName(FExpand(Editor^.FileName))) then
  1610. begin
  1611. if P^.state=bs_enabled then
  1612. Editor^.SetLineFlagState(P^.Line-1,lfBreakpoint,false);
  1613. if P^.Line-1>=Pos then
  1614. begin
  1615. if (Change>0) or (P^.Line-1>=Pos-Change) then
  1616. P^.line:=P^.Line+Change
  1617. else
  1618. begin
  1619. { removing inside a ForEach call leads to problems }
  1620. { so we do that after PM }
  1621. P^.state:=bs_delete_after;
  1622. end;
  1623. end;
  1624. if P^.state=bs_enabled then
  1625. Editor^.SetLineFlagState(P^.Line-1,lfBreakpoint,true);
  1626. end;
  1627. end;
  1628. var
  1629. I : longint;
  1630. begin
  1631. ForEach(@AdaptInSource);
  1632. I:=Count-1;
  1633. While (I>=0) do
  1634. begin
  1635. if At(I)^.state=bs_delete_after then
  1636. AtFree(I);
  1637. Dec(I);
  1638. end;
  1639. end;
  1640. function TBreakpointCollection.FindBreakpointAt(Editor : PSourceEditor; Line : longint) : PBreakpoint;
  1641. function IsAtLine(P : PBreakpoint) : boolean;{$ifndef FPC}far;{$endif}
  1642. begin
  1643. If assigned(P^.FileName) and
  1644. (P^.FileName^=OSFileName(FExpand(Editor^.FileName))) and
  1645. (Line=P^.Line) then
  1646. IsAtLine:=true
  1647. else
  1648. IsAtLine:=false;
  1649. end;
  1650. begin
  1651. FindBreakpointAt:=FirstThat(@IsAtLine);
  1652. end;
  1653. procedure TBreakpointCollection.ShowAllBreakpoints;
  1654. procedure SetInSource(P : PBreakpoint);{$ifndef FPC}far;{$endif}
  1655. var
  1656. W : PSourceWindow;
  1657. begin
  1658. If assigned(P^.FileName) then
  1659. begin
  1660. W:=SearchOnDesktop(P^.FileName^,false);
  1661. if assigned(W) then
  1662. W^.Editor^.SetLineFlagState(P^.Line-1,lfBreakpoint,P^.state=bs_enabled);
  1663. end;
  1664. end;
  1665. begin
  1666. ForEach(@SetInSource);
  1667. end;
  1668. function TBreakpointCollection.GetType(typ : BreakpointType;Const s : String) : PBreakpoint;
  1669. function IsThis(P : PBreakpoint) : boolean;{$ifndef FPC}far;{$endif}
  1670. begin
  1671. IsThis:=(P^.typ=typ) and (GetStr(P^.Name)=S);
  1672. end;
  1673. begin
  1674. GetType:=FirstThat(@IsThis);
  1675. end;
  1676. function TBreakpointCollection.ToggleFileLine(FileName: String;LineNr : Longint) : boolean;
  1677. function IsThere(P : PBreakpoint) : boolean;{$ifndef FPC}far;{$endif}
  1678. begin
  1679. IsThere:=(P^.typ=bt_file_line) and assigned(P^.FileName) and
  1680. (OSFileName(P^.FileName^)=FileName) and (P^.Line=LineNr);
  1681. end;
  1682. var
  1683. PB : PBreakpoint;
  1684. begin
  1685. ToggleFileLine:=false;
  1686. FileName:=OSFileName(FExpand(FileName));
  1687. PB:=FirstThat(@IsThere);
  1688. If Assigned(PB) then
  1689. begin
  1690. { delete it form source window }
  1691. PB^.state:=bs_disabled;
  1692. PB^.UpdateSource;
  1693. { remove from collection }
  1694. BreakpointsCollection^.free(PB);
  1695. end
  1696. else
  1697. begin
  1698. PB:= New(PBreakpoint,Init_file_line(FileName,LineNr));
  1699. if assigned(PB) then
  1700. Begin
  1701. Insert(PB);
  1702. PB^.UpdateSource;
  1703. ToggleFileLine:=true;
  1704. End;
  1705. end;
  1706. Update;
  1707. end;
  1708. {****************************************************************************
  1709. TBreakpointItem
  1710. ****************************************************************************}
  1711. constructor TBreakpointItem.Init(ABreakpoint : PBreakpoint);
  1712. begin
  1713. inherited Init;
  1714. Breakpoint:=ABreakpoint;
  1715. end;
  1716. function TBreakpointItem.GetText(MaxLen: Sw_integer): string;
  1717. var S: string;
  1718. begin
  1719. with Breakpoint^ do
  1720. begin
  1721. S:=BreakpointTypeStr[typ];
  1722. While Length(S)<10 do
  1723. S:=S+' ';
  1724. S:=S+'|';
  1725. S:=S+BreakpointStateStr[state]+' ';
  1726. While Length(S)<20 do
  1727. S:=S+' ';
  1728. S:=S+'|';
  1729. if (typ=bt_file_line) then
  1730. S:=S+NameAndExtOf(GetStr(FileName))+':'+IntToStr(Line)
  1731. else
  1732. S:=S+GetStr(name);
  1733. While Length(S)<40 do
  1734. S:=S+' ';
  1735. S:=S+'|';
  1736. if IgnoreCount>0 then
  1737. S:=S+IntToStr(IgnoreCount);
  1738. While Length(S)<49 do
  1739. S:=S+' ';
  1740. S:=S+'|';
  1741. if assigned(Conditions) then
  1742. S:=S+' '+GetStr(Conditions);
  1743. if length(S)>MaxLen then S:=copy(S,1,MaxLen-2)+'..';
  1744. GetText:=S;
  1745. end;
  1746. end;
  1747. procedure TBreakpointItem.Selected;
  1748. begin
  1749. end;
  1750. function TBreakpointItem.GetModuleName: string;
  1751. begin
  1752. if breakpoint^.typ=bt_file_line then
  1753. GetModuleName:=GetStr(breakpoint^.FileName)
  1754. else
  1755. GetModuleName:='';
  1756. end;
  1757. {****************************************************************************
  1758. TBreakpointsListBox
  1759. ****************************************************************************}
  1760. constructor TBreakpointsListBox.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  1761. begin
  1762. inherited Init(Bounds,1,AHScrollBar, AVScrollBar);
  1763. GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY;
  1764. NoSelection:=true;
  1765. end;
  1766. function TBreakpointsListBox.GetLocalMenu: PMenu;
  1767. var M: PMenu;
  1768. begin
  1769. if (Owner<>nil) and (Owner^.GetState(sfModal)) then M:=nil else
  1770. M:=NewMenu(
  1771. NewItem(menu_bplocal_gotosource,'',kbNoKey,cmMsgGotoSource,hcMsgGotoSource,
  1772. NewItem(menu_bplocal_editbreakpoint,'',kbNoKey,cmEditBreakpoint,hcEditBreakpoint,
  1773. NewItem(menu_bplocal_newbreakpoint,'',kbNoKey,cmNewBreakpoint,hcNewBreakpoint,
  1774. NewItem(menu_bplocal_deletebreakpoint,'',kbNoKey,cmDeleteBreakpoint,hcDeleteBreakpoint,
  1775. NewItem(menu_bplocal_togglestate,'',kbNoKey,cmToggleBreakpoint,hcToggleBreakpoint,
  1776. nil))))));
  1777. GetLocalMenu:=M;
  1778. end;
  1779. procedure TBreakpointsListBox.HandleEvent(var Event: TEvent);
  1780. var DontClear: boolean;
  1781. begin
  1782. case Event.What of
  1783. evKeyDown :
  1784. begin
  1785. DontClear:=false;
  1786. case Event.KeyCode of
  1787. kbEnter :
  1788. Message(@Self,evCommand,cmMsgGotoSource,nil);
  1789. kbIns :
  1790. Message(@Self,evCommand,cmNewBreakpoint,nil);
  1791. kbDel :
  1792. Message(@Self,evCommand,cmDeleteBreakpoint,nil);
  1793. else
  1794. DontClear:=true;
  1795. end;
  1796. if not DontClear then
  1797. ClearEvent(Event);
  1798. end;
  1799. evBroadcast :
  1800. case Event.Command of
  1801. cmListItemSelected :
  1802. if Event.InfoPtr=@Self then
  1803. Message(@Self,evCommand,cmEditBreakpoint,nil);
  1804. end;
  1805. evCommand :
  1806. begin
  1807. DontClear:=false;
  1808. case Event.Command of
  1809. cmMsgTrackSource :
  1810. if Range>0 then
  1811. TrackSource;
  1812. cmEditBreakpoint :
  1813. EditCurrent;
  1814. cmToggleBreakpoint :
  1815. ToggleCurrent;
  1816. cmDeleteBreakpoint :
  1817. DeleteCurrent;
  1818. cmNewBreakpoint :
  1819. EditNew;
  1820. cmMsgClear :
  1821. Clear;
  1822. else
  1823. DontClear:=true;
  1824. end;
  1825. if not DontClear then
  1826. ClearEvent(Event);
  1827. end;
  1828. end;
  1829. inherited HandleEvent(Event);
  1830. end;
  1831. procedure TBreakpointsListBox.AddBreakpoint(P: PBreakpointItem);
  1832. var W : integer;
  1833. begin
  1834. if List=nil then New(List, Init(20,20));
  1835. W:=length(P^.GetText(255));
  1836. if W>MaxWidth then
  1837. begin
  1838. MaxWidth:=W;
  1839. if HScrollBar<>nil then
  1840. HScrollBar^.SetRange(0,MaxWidth);
  1841. end;
  1842. List^.Insert(P);
  1843. SetRange(List^.Count);
  1844. if Focused=List^.Count-1-1 then
  1845. FocusItem(List^.Count-1);
  1846. P^.Breakpoint^.UpdateSource;
  1847. DrawView;
  1848. end;
  1849. function TBreakpointsListBox.GetText(Item,MaxLen: Sw_Integer): String;
  1850. var P: PBreakpointItem;
  1851. S: string;
  1852. begin
  1853. P:=List^.At(Item);
  1854. S:=P^.GetText(MaxLen);
  1855. GetText:=copy(S,1,MaxLen);
  1856. end;
  1857. procedure TBreakpointsListBox.Clear;
  1858. begin
  1859. if assigned(List) then
  1860. Dispose(List, Done);
  1861. List:=nil;
  1862. MaxWidth:=0;
  1863. SetRange(0); DrawView;
  1864. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  1865. end;
  1866. procedure TBreakpointsListBox.TrackSource;
  1867. var W: PSourceWindow;
  1868. P: PBreakpointItem;
  1869. R: TRect;
  1870. begin
  1871. (*Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  1872. if Range=0 then Exit;*)
  1873. P:=List^.At(Focused);
  1874. if P^.GetModuleName='' then Exit;
  1875. Desktop^.Lock;
  1876. GetNextEditorBounds(R);
  1877. R.B.Y:=Owner^.Origin.Y;
  1878. W:=EditorWindowFile(P^.GetModuleName);
  1879. if assigned(W) then
  1880. begin
  1881. W^.GetExtent(R);
  1882. R.B.Y:=Owner^.Origin.Y;
  1883. W^.ChangeBounds(R);
  1884. W^.Editor^.SetCurPtr(1,P^.Breakpoint^.Line);
  1885. end
  1886. else
  1887. W:=TryToOpenFile(@R,P^.GetModuleName,1,P^.Breakpoint^.Line,true);
  1888. if W<>nil then
  1889. begin
  1890. W^.Select;
  1891. W^.Editor^.TrackCursor(true);
  1892. W^.Editor^.SetLineFlagExclusive(lfHighlightRow,P^.Breakpoint^.Line);
  1893. end;
  1894. if Assigned(Owner) then
  1895. Owner^.Select;
  1896. Desktop^.UnLock;
  1897. end;
  1898. procedure TBreakpointsListBox.ToggleCurrent;
  1899. var
  1900. P: PBreakpointItem;
  1901. begin
  1902. if Range=0 then Exit;
  1903. P:=List^.At(Focused);
  1904. if P=nil then Exit;
  1905. if P^.Breakpoint^.state=bs_enabled then
  1906. P^.Breakpoint^.state:=bs_disabled
  1907. else if P^.Breakpoint^.state=bs_disabled then
  1908. P^.Breakpoint^.state:=bs_enabled;
  1909. P^.Breakpoint^.UpdateSource;
  1910. BreakpointsCollection^.Update;
  1911. end;
  1912. procedure TBreakpointsListBox.EditCurrent;
  1913. var
  1914. P: PBreakpointItem;
  1915. begin
  1916. if Range=0 then Exit;
  1917. P:=List^.At(Focused);
  1918. if P=nil then Exit;
  1919. Application^.ExecuteDialog(New(PBreakpointItemDialog,Init(P^.Breakpoint)),nil);
  1920. P^.Breakpoint^.UpdateSource;
  1921. BreakpointsCollection^.Update;
  1922. end;
  1923. procedure TBreakpointsListBox.DeleteCurrent;
  1924. var
  1925. P: PBreakpointItem;
  1926. begin
  1927. if Range=0 then Exit;
  1928. P:=List^.At(Focused);
  1929. if P=nil then Exit;
  1930. { delete it form source window }
  1931. P^.Breakpoint^.state:=bs_disabled;
  1932. P^.Breakpoint^.UpdateSource;
  1933. BreakpointsCollection^.free(P^.Breakpoint);
  1934. List^.free(P);
  1935. BreakpointsCollection^.Update;
  1936. end;
  1937. procedure TBreakpointsListBox.EditNew;
  1938. var
  1939. P: PBreakpoint;
  1940. begin
  1941. P:=New(PBreakpoint,Init_Empty);
  1942. if Application^.ExecuteDialog(New(PBreakpointItemDialog,Init(P)),nil)<>cmCancel then
  1943. begin
  1944. P^.UpdateSource;
  1945. BreakpointsCollection^.Insert(P);
  1946. BreakpointsCollection^.Update;
  1947. end
  1948. else
  1949. dispose(P,Done);
  1950. end;
  1951. procedure TBreakpointsListBox.Draw;
  1952. var
  1953. I, J, Item: Sw_Integer;
  1954. NormalColor, SelectedColor, FocusedColor, Color: Word;
  1955. ColWidth, CurCol, Indent: Integer;
  1956. B: TDrawBuffer;
  1957. Text: String;
  1958. SCOff: Byte;
  1959. TC: byte;
  1960. procedure MT(var C: word); begin if TC<>0 then C:=(C and $ff0f) or (TC and $f0); end;
  1961. begin
  1962. if (Owner<>nil) then TC:=ord(Owner^.GetColor(6)) else TC:=0;
  1963. if State and (sfSelected + sfActive) = (sfSelected + sfActive) then
  1964. begin
  1965. NormalColor := GetColor(1);
  1966. FocusedColor := GetColor(3);
  1967. SelectedColor := GetColor(4);
  1968. end else
  1969. begin
  1970. NormalColor := GetColor(2);
  1971. SelectedColor := GetColor(4);
  1972. end;
  1973. if Transparent then
  1974. begin MT(NormalColor); MT(SelectedColor); end;
  1975. if NoSelection then
  1976. SelectedColor:=NormalColor;
  1977. if HScrollBar <> nil then Indent := HScrollBar^.Value
  1978. else Indent := 0;
  1979. ColWidth := Size.X div NumCols + 1;
  1980. for I := 0 to Size.Y - 1 do
  1981. begin
  1982. for J := 0 to NumCols-1 do
  1983. begin
  1984. Item := J*Size.Y + I + TopItem;
  1985. CurCol := J*ColWidth;
  1986. if (State and (sfSelected + sfActive) = (sfSelected + sfActive)) and
  1987. (Focused = Item) and (Range > 0) then
  1988. begin
  1989. Color := FocusedColor;
  1990. SetCursor(CurCol+1,I);
  1991. SCOff := 0;
  1992. end
  1993. else if (Item < Range) and IsSelected(Item) then
  1994. begin
  1995. Color := SelectedColor;
  1996. SCOff := 2;
  1997. end
  1998. else
  1999. begin
  2000. Color := NormalColor;
  2001. SCOff := 4;
  2002. end;
  2003. MoveChar(B[CurCol], ' ', Color, ColWidth);
  2004. if Item < Range then
  2005. begin
  2006. Text := GetText(Item, ColWidth + Indent);
  2007. Text := Copy(Text,Indent,ColWidth);
  2008. MoveStr(B[CurCol+1], Text, Color);
  2009. if ShowMarkers then
  2010. begin
  2011. WordRec(B[CurCol]).Lo := Byte(SpecialChars[SCOff]);
  2012. WordRec(B[CurCol+ColWidth-2]).Lo := Byte(SpecialChars[SCOff+1]);
  2013. end;
  2014. end;
  2015. MoveChar(B[CurCol+ColWidth-1], #179, GetColor(5), 1);
  2016. end;
  2017. WriteLine(0, I, Size.X, 1, B);
  2018. end;
  2019. end;
  2020. constructor TBreakpointsListBox.Load(var S: TStream);
  2021. begin
  2022. inherited Load(S);
  2023. end;
  2024. procedure TBreakpointsListBox.Store(var S: TStream);
  2025. var OL: PCollection;
  2026. OldR : integer;
  2027. begin
  2028. OL:=List;
  2029. OldR:=Range;
  2030. Range:=0;
  2031. New(List, Init(1,1));
  2032. inherited Store(S);
  2033. Dispose(List, Done);
  2034. Range:=OldR;
  2035. List:=OL;
  2036. { ^^^ nasty trick - has anyone a better idea how to avoid storing the
  2037. collection? Pasting here a modified version of TListBox.Store+
  2038. TAdvancedListBox.Store isn't a better solution, since by eventually
  2039. changing the obj-hierarchy you'll always have to modify this, too - BG }
  2040. end;
  2041. destructor TBreakpointsListBox.Done;
  2042. begin
  2043. inherited Done;
  2044. if List<>nil then Dispose(List, Done);
  2045. end;
  2046. {****************************************************************************
  2047. TBreakpointsWindow
  2048. ****************************************************************************}
  2049. constructor TBreakpointsWindow.Init;
  2050. var R,R2: TRect;
  2051. HSB,VSB: PScrollBar;
  2052. ST: PStaticText;
  2053. S: String;
  2054. X,X1 : Sw_integer;
  2055. Btn: PButton;
  2056. const
  2057. NumButtons = 5;
  2058. begin
  2059. Desktop^.GetExtent(R); R.A.Y:=R.B.Y-18;
  2060. inherited Init(R, dialog_breakpointlist, wnNoNumber);
  2061. HelpCtx:=hcBreakpointListWindow;
  2062. GetExtent(R); R.Grow(-1,-1); R.B.Y:=R.A.Y+1;
  2063. S:=label_breakpointpropheader;
  2064. New(ST, Init(R,S));
  2065. ST^.GrowMode:=gfGrowHiX;
  2066. Insert(ST);
  2067. GetExtent(R); R.Grow(-1,-1); Inc(R.A.Y,1); R.B.Y:=R.A.Y+1;
  2068. New(ST, Init(R, CharStr('Ä', MaxViewWidth)));
  2069. ST^.GrowMode:=gfGrowHiX;
  2070. Insert(ST);
  2071. GetExtent(R); R.Grow(-1,-1); Inc(R.A.Y,2);Dec(R.B.Y,5);
  2072. R2.Copy(R); Inc(R2.B.Y); R2.A.Y:=R2.B.Y-1;
  2073. New(HSB, Init(R2)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiY+gfGrowHiX; Insert(HSB);
  2074. HSB^.SetStep(R.B.X-R.A.X-2,1);
  2075. R2.Copy(R); Inc(R2.B.X); R2.A.X:=R2.B.X-1;
  2076. New(VSB, Init(R2)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  2077. VSB^.SetStep(R.B.Y-R.A.Y-2,1);
  2078. New(BreakLB, Init(R,HSB,VSB));
  2079. BreakLB^.GrowMode:=gfGrowHiX+gfGrowHiY;
  2080. BreakLB^.Transparent:=true;
  2081. Insert(BreakLB);
  2082. GetExtent(R);R.Grow(-1,-1);
  2083. Dec(R.B.Y);
  2084. R.A.Y:=R.B.Y-2;
  2085. X:=(R.B.X-R.A.X) div NumButtons;
  2086. X1:=R.A.X+(X div 2);
  2087. R.A.X:=X1-3;R.B.X:=X1+7;
  2088. New(Btn, Init(R, button_Close, cmClose, bfDefault));
  2089. Btn^.GrowMode:=gfGrowLoY+gfGrowHiY;
  2090. Insert(Btn);
  2091. X1:=X1+X;
  2092. R.A.X:=X1-3;R.B.X:=X1+7;
  2093. New(Btn, Init(R, button_New, cmNewBreakpoint, bfNormal));
  2094. Btn^.GrowMode:=gfGrowLoY+gfGrowHiY;
  2095. Insert(Btn);
  2096. X1:=X1+X;
  2097. R.A.X:=X1-3;R.B.X:=X1+7;
  2098. New(Btn, Init(R, button_Edit, cmEditBreakpoint, bfNormal));
  2099. Btn^.GrowMode:=gfGrowLoY+gfGrowHiY;
  2100. Insert(Btn);
  2101. X1:=X1+X;
  2102. R.A.X:=X1-3;R.B.X:=X1+7;
  2103. New(Btn, Init(R, button_ToggleButton, cmToggleBreakInList, bfNormal));
  2104. Btn^.GrowMode:=gfGrowLoY+gfGrowHiY;
  2105. Insert(Btn);
  2106. X1:=X1+X;
  2107. R.A.X:=X1-3;R.B.X:=X1+7;
  2108. New(Btn, Init(R, button_Delete, cmDeleteBreakpoint, bfNormal));
  2109. Btn^.GrowMode:=gfGrowLoY+gfGrowHiY;
  2110. Insert(Btn);
  2111. BreakLB^.Select;
  2112. Update;
  2113. BreakpointsWindow:=@self;
  2114. end;
  2115. constructor TBreakpointsWindow.Load(var S: TStream);
  2116. begin
  2117. inherited Load(S);
  2118. GetSubViewPtr(S,BreakLB);
  2119. end;
  2120. procedure TBreakpointsWindow.Store(var S: TStream);
  2121. begin
  2122. inherited Store(S);
  2123. PutSubViewPtr(S,BreakLB);
  2124. end;
  2125. procedure TBreakpointsWindow.AddBreakpoint(ABreakpoint : PBreakpoint);
  2126. begin
  2127. BreakLB^.AddBreakpoint(New(PBreakpointItem, Init(ABreakpoint)));
  2128. end;
  2129. procedure TBreakpointsWindow.ClearBreakpoints;
  2130. begin
  2131. BreakLB^.Clear;
  2132. ReDraw;
  2133. end;
  2134. procedure TBreakpointsWindow.ReloadBreakpoints;
  2135. procedure InsertInBreakLB(P : PBreakpoint);
  2136. begin
  2137. BreakLB^.AddBreakpoint(New(PBreakpointItem, Init(P)));
  2138. end;
  2139. begin
  2140. If not assigned(BreakpointsCollection) then
  2141. exit;
  2142. BreakpointsCollection^.ForEach(@InsertInBreakLB);
  2143. ReDraw;
  2144. end;
  2145. procedure TBreakpointsWindow.SizeLimits(var Min, Max: TPoint);
  2146. begin
  2147. inherited SizeLimits(Min,Max);
  2148. Min.X:=40; Min.Y:=18;
  2149. end;
  2150. procedure TBreakpointsWindow.Close;
  2151. begin
  2152. Hide;
  2153. end;
  2154. procedure TBreakpointsWindow.HandleEvent(var Event: TEvent);
  2155. var DontClear : boolean;
  2156. begin
  2157. case Event.What of
  2158. evKeyDown :
  2159. begin
  2160. if (Event.KeyCode=kbEnter) or (Event.KeyCode=kbEsc) then
  2161. begin
  2162. ClearEvent(Event);
  2163. Hide;
  2164. end;
  2165. end;
  2166. evCommand :
  2167. begin
  2168. DontClear:=False;
  2169. case Event.Command of
  2170. cmNewBreakpoint :
  2171. BreakLB^.EditNew;
  2172. cmEditBreakpoint :
  2173. BreakLB^.EditCurrent;
  2174. cmDeleteBreakpoint :
  2175. BreakLB^.DeleteCurrent;
  2176. cmToggleBreakInList :
  2177. BreakLB^.ToggleCurrent;
  2178. cmClose :
  2179. Hide;
  2180. else
  2181. DontClear:=true;
  2182. end;
  2183. if not DontClear then
  2184. ClearEvent(Event);
  2185. end;
  2186. evBroadcast :
  2187. case Event.Command of
  2188. cmUpdate :
  2189. Update;
  2190. end;
  2191. end;
  2192. inherited HandleEvent(Event);
  2193. end;
  2194. procedure TBreakpointsWindow.Update;
  2195. var
  2196. StoreFocus : longint;
  2197. begin
  2198. StoreFocus:=BreakLB^.Focused;
  2199. ClearBreakpoints;
  2200. ReloadBreakpoints;
  2201. If StoreFocus<BreakLB^.Range then
  2202. BreakLB^.FocusItem(StoreFocus);
  2203. end;
  2204. destructor TBreakpointsWindow.Done;
  2205. begin
  2206. inherited Done;
  2207. BreakpointsWindow:=nil;
  2208. end;
  2209. {****************************************************************************
  2210. TBreakpointItemDialog
  2211. ****************************************************************************}
  2212. constructor TBreakpointItemDialog.Init(ABreakpoint: PBreakpoint);
  2213. var R,R2,R3: TRect;
  2214. Items: PSItem;
  2215. I : BreakpointType;
  2216. KeyCount: sw_integer;
  2217. begin
  2218. KeyCount:=longint(high(BreakpointType));
  2219. R.Assign(0,0,60,Max(9+KeyCount,18));
  2220. inherited Init(R,dialog_modifynewbreakpoint);
  2221. Breakpoint:=ABreakpoint;
  2222. GetExtent(R); R.Grow(-3,-2); R3.Copy(R);
  2223. Inc(R.A.Y); R.B.Y:=R.A.Y+1; R.B.X:=R.B.X-3;
  2224. New(NameIL, Init(R, 255)); Insert(NameIL);
  2225. R2.Copy(R); R2.A.X:=R2.B.X; R2.B.X:=R2.A.X+3;
  2226. Insert(New(PHistory, Init(R2, NameIL, hidWatchDialog)));
  2227. R.Copy(R3); Inc(R.A.Y); R.B.Y:=R.A.Y+1;
  2228. R2.Copy(R); R2.Move(-1,-1);
  2229. Insert(New(PLabel, Init(R2, label_breakpoint_name, NameIL)));
  2230. R.Move(0,3);
  2231. New(ConditionsIL, Init(R, 255)); Insert(ConditionsIL);
  2232. R2.Copy(R); R2.Move(-1,-1); Insert(New(PLabel, Init(R2, label_breakpoint_conditions, ConditionsIL)));
  2233. R.Move(0,3); R.B.X:=R.A.X+36;
  2234. New(LineIL, Init(R, 128)); Insert(LineIL);
  2235. LineIL^.SetValidator(New(PRangeValidator, Init(0,MaxInt)));
  2236. R2.Copy(R); R2.Move(-1,-1); Insert(New(PLabel, Init(R2, label_breakpoint_line, LineIL)));
  2237. R.Move(0,3);
  2238. New(IgnoreIL, Init(R, 128)); Insert(IgnoreIL);
  2239. IgnoreIL^.SetValidator(New(PRangeValidator, Init(0,MaxInt)));
  2240. R2.Copy(R); R2.Move(-1,-1); Insert(New(PLabel, Init(R2, label_breakpoint_ignorecount, IgnoreIL)));
  2241. R.Copy(R3); Inc(R.A.X,38); Inc(R.A.Y,7); R.B.Y:=R.A.Y+KeyCount;
  2242. Items:=nil;
  2243. { don't use invalid type }
  2244. for I:=pred(high(BreakpointType)) downto low(BreakpointType) do
  2245. Items:=NewSItem(BreakpointTypeStr[I], Items);
  2246. New(TypeRB, Init(R, Items));
  2247. R2.Copy(R); R2.Move(-1,-1); R2.B.Y:=R2.A.Y+1;
  2248. Insert(New(PLabel, Init(R2, label_breakpoint_type, TypeRB)));
  2249. Insert(TypeRB);
  2250. InsertButtons(@Self);
  2251. NameIL^.Select;
  2252. end;
  2253. function TBreakpointItemDialog.Execute: Word;
  2254. var R: word;
  2255. S1: string;
  2256. err: word;
  2257. L: longint;
  2258. begin
  2259. R:=longint(Breakpoint^.typ);
  2260. TypeRB^.SetData(R);
  2261. If Breakpoint^.typ=bt_file_line then
  2262. S1:=GetStr(Breakpoint^.FileName)
  2263. else
  2264. S1:=GetStr(Breakpoint^.name);
  2265. NameIL^.SetData(S1);
  2266. If Breakpoint^.typ=bt_file_line then
  2267. S1:=IntToStr(Breakpoint^.Line)
  2268. else
  2269. S1:='0';
  2270. LineIL^.SetData(S1);
  2271. S1:=IntToStr(Breakpoint^.IgnoreCount);
  2272. IgnoreIL^.SetData(S1);
  2273. S1:=GetStr(Breakpoint^.Conditions);
  2274. ConditionsIL^.SetData(S1);
  2275. if assigned(FirstEditorWindow) then
  2276. FindReplaceEditor:=FirstEditorWindow^.Editor;
  2277. R:=inherited Execute;
  2278. FindReplaceEditor:=nil;
  2279. if R=cmOK then
  2280. begin
  2281. TypeRB^.GetData(R);
  2282. L:=R;
  2283. Breakpoint^.typ:=BreakpointType(L);
  2284. NameIL^.GetData(S1);
  2285. If Breakpoint^.typ=bt_file_line then
  2286. begin
  2287. If assigned(Breakpoint^.FileName) then
  2288. DisposeStr(Breakpoint^.FileName);
  2289. Breakpoint^.FileName:=NewStr(S1);
  2290. end
  2291. else
  2292. begin
  2293. If assigned(Breakpoint^.Name) then
  2294. DisposeStr(Breakpoint^.Name);
  2295. Breakpoint^.name:=NewStr(S1);
  2296. end;
  2297. If Breakpoint^.typ=bt_file_line then
  2298. begin
  2299. LineIL^.GetData(S1);
  2300. Val(S1,L,err);
  2301. Breakpoint^.Line:=L;
  2302. end;
  2303. IgnoreIL^.GetData(S1);
  2304. Val(S1,L,err);
  2305. Breakpoint^.IgnoreCount:=L;
  2306. ConditionsIL^.GetData(S1);
  2307. If assigned(Breakpoint^.Conditions) then
  2308. DisposeStr(Breakpoint^.Conditions);
  2309. Breakpoint^.Conditions:=NewStr(S1);
  2310. end;
  2311. Execute:=R;
  2312. end;
  2313. {****************************************************************************
  2314. TWatch
  2315. ****************************************************************************}
  2316. constructor TWatch.Init(s : string);
  2317. begin
  2318. expr:=NewStr(s);
  2319. last_value:=nil;
  2320. current_value:=nil;
  2321. Get_new_value;
  2322. GDBRunCount:=-1;
  2323. end;
  2324. constructor TWatch.Load(var S: TStream);
  2325. begin
  2326. expr:=S.ReadStr;
  2327. last_value:=nil;
  2328. current_value:=nil;
  2329. Get_new_value;
  2330. GDBRunCount:=-1;
  2331. end;
  2332. procedure TWatch.Store(var S: TStream);
  2333. begin
  2334. S.WriteStr(expr);
  2335. end;
  2336. procedure TWatch.rename(s : string);
  2337. begin
  2338. if assigned(expr) then
  2339. begin
  2340. if GetStr(expr)=S then
  2341. exit;
  2342. DisposeStr(expr);
  2343. end;
  2344. expr:=NewStr(s);
  2345. if assigned(last_value) then
  2346. StrDispose(last_value);
  2347. last_value:=nil;
  2348. if assigned(current_value) then
  2349. StrDispose(current_value);
  2350. current_value:=nil;
  2351. GDBRunCount:=-1;
  2352. Get_new_value;
  2353. end;
  2354. procedure TWatch.Get_new_value;
  2355. {$ifndef NODEBUG}
  2356. var p, q : pchar;
  2357. i, j, curframe, startframe : longint;
  2358. s,s2 : string;
  2359. loop_higher, found : boolean;
  2360. last_removed : char;
  2361. function GetValue(var s : string) : boolean;
  2362. begin
  2363. Debugger^.command('p '+s);
  2364. if not Debugger^.Error then
  2365. begin
  2366. s:=StrPas(Debugger^.GetOutput);
  2367. GetValue:=true;
  2368. end
  2369. else
  2370. begin
  2371. s:=StrPas(Debugger^.GetError);
  2372. GetValue:=false;
  2373. { do not open a messagebox for such errors }
  2374. Debugger^.got_error:=false;
  2375. end;
  2376. end;
  2377. begin
  2378. If not assigned(Debugger) or Not Debugger^.HasExe or
  2379. (GDBRunCount=Debugger^.RunCount) then
  2380. exit;
  2381. GDBRunCount:=Debugger^.RunCount;
  2382. if assigned(last_value) then
  2383. strdispose(last_value);
  2384. last_value:=current_value;
  2385. s:=GetStr(expr);
  2386. found:=GetValue(s);
  2387. Debugger^.got_error:=false;
  2388. loop_higher:=not found;
  2389. if not found then
  2390. begin
  2391. curframe:=Debugger^.get_current_frame;
  2392. startframe:=curframe;
  2393. end
  2394. else
  2395. begin
  2396. curframe:=0;
  2397. startframe:=0;
  2398. end;
  2399. while loop_higher do
  2400. begin
  2401. s:='parent_ebp';
  2402. if GetValue(s) then
  2403. begin
  2404. repeat
  2405. inc(curframe);
  2406. if not Debugger^.set_current_frame(curframe) then
  2407. loop_higher:=false;
  2408. {$ifdef FrameNameKnown}
  2409. s2:='/x '+FrameName;
  2410. {$else not FrameNameKnown}
  2411. s2:='/x $ebp';
  2412. {$endif FrameNameKnown}
  2413. getValue(s2);
  2414. j:=pos('=',s2);
  2415. if j>0 then
  2416. s2:=copy(s2,j+1,length(s2));
  2417. while s2[1] in [' ',TAB] do
  2418. delete(s2,1,1);
  2419. if pos(s2,s)>0 then
  2420. loop_higher :=false;
  2421. until not loop_higher;
  2422. { try again at that level }
  2423. s:=GetStr(expr);
  2424. found:=GetValue(s);
  2425. loop_higher:=not found;
  2426. end
  2427. else
  2428. loop_higher:=false;
  2429. end;
  2430. if found then
  2431. p:=StrNew(Debugger^.GetOutput)
  2432. else
  2433. begin
  2434. { get a reasonable output at least }
  2435. s:=GetStr(expr);
  2436. GetValue(s);
  2437. p:=StrNew(Debugger^.GetError);
  2438. end;
  2439. Debugger^.got_error:=false;
  2440. { We should try here to find the expr in parent
  2441. procedure if there are
  2442. I will implement this as I added a
  2443. parent_ebp pseudo local var to local procedure
  2444. in stabs debug info PM }
  2445. { But there are some pitfalls like
  2446. locals redefined in other sublocals that call the function }
  2447. if curframe<>startframe then
  2448. Debugger^.set_current_frame(startframe);
  2449. q:=nil;
  2450. if assigned(p) and (p[0]='$') then
  2451. q:=StrPos(p,'=');
  2452. if not assigned(q) then
  2453. q:=p;
  2454. if assigned(q) then
  2455. i:=strlen(q)
  2456. else
  2457. i:=0;
  2458. if (i>0) and (q[i-1]=#10) then
  2459. begin
  2460. while (i>1) and ((q[i-2]=' ') or (q[i-2]=#9)) do
  2461. dec(i);
  2462. last_removed:=q[i-1];
  2463. q[i-1]:=#0;
  2464. end
  2465. else
  2466. last_removed:=#0;
  2467. if assigned(q) then
  2468. current_value:=strnew(q)
  2469. else
  2470. current_value:=strnew('');
  2471. if last_removed<>#0 then
  2472. q[i-1]:=last_removed;
  2473. strdispose(p);
  2474. GDBRunCount:=Debugger^.RunCount;
  2475. end;
  2476. {$else NODEBUG}
  2477. begin
  2478. end;
  2479. {$endif NODEBUG}
  2480. procedure TWatch.Force_new_value;
  2481. begin
  2482. GDBRunCount:=-1;
  2483. Get_new_value;
  2484. end;
  2485. destructor TWatch.Done;
  2486. begin
  2487. if assigned(expr) then
  2488. disposestr(expr);
  2489. if assigned(last_value) then
  2490. strdispose(last_value);
  2491. if assigned(current_value) then
  2492. strdispose(current_value);
  2493. inherited done;
  2494. end;
  2495. {****************************************************************************
  2496. TWatchesCollection
  2497. ****************************************************************************}
  2498. constructor TWatchesCollection.Init;
  2499. begin
  2500. inherited Init(10,10);
  2501. end;
  2502. procedure TWatchesCollection.Insert(Item: Pointer);
  2503. begin
  2504. PWatch(Item)^.Get_new_value;
  2505. Inherited Insert(Item);
  2506. Update;
  2507. end;
  2508. procedure TWatchesCollection.Update;
  2509. var
  2510. W,W1 : integer;
  2511. procedure GetMax(P : PWatch);
  2512. begin
  2513. if assigned(P^.Current_value) then
  2514. W1:=StrLen(P^.Current_value)+3+Length(GetStr(P^.expr))
  2515. else
  2516. W1:=2+Length(GetStr(P^.expr));
  2517. if W1>W then
  2518. W:=W1;
  2519. end;
  2520. begin
  2521. W:=0;
  2522. ForEach(@GetMax);
  2523. MaxW:=W;
  2524. If assigned(WatchesWindow) then
  2525. WatchesWindow^.WLB^.Update(MaxW);
  2526. end;
  2527. function TWatchesCollection.At(Index: Integer): PWatch;
  2528. begin
  2529. At:=Inherited At(Index);
  2530. end;
  2531. {****************************************************************************
  2532. TWatchesListBox
  2533. ****************************************************************************}
  2534. constructor TWatchesListBox.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  2535. begin
  2536. inherited Init(Bounds,1,AHScrollBar,AVScrollBar);
  2537. If assigned(List) then
  2538. dispose(list,done);
  2539. List:=WatchesCollection;
  2540. end;
  2541. procedure TWatchesListBox.Update(AMaxWidth : integer);
  2542. var R : TRect;
  2543. begin
  2544. GetExtent(R);
  2545. MaxWidth:=AMaxWidth;
  2546. if (HScrollBar<>nil) and (R.B.X-R.A.X<MaxWidth) then
  2547. HScrollBar^.SetRange(0,MaxWidth-(R.B.X-R.A.X))
  2548. else
  2549. HScrollBar^.SetRange(0,0);
  2550. if R.B.X-R.A.X>MaxWidth then
  2551. HScrollBar^.Hide
  2552. else
  2553. HScrollBar^.Show;
  2554. SetRange(List^.Count+1);
  2555. if R.B.Y-R.A.Y>Range then
  2556. VScrollBar^.Hide
  2557. else
  2558. VScrollBar^.Show;
  2559. {if Focused=List^.Count-1-1 then
  2560. FocusItem(List^.Count-1);
  2561. What was that for ?? PM }
  2562. DrawView;
  2563. end;
  2564. function TWatchesListBox.GetIndentedText(Item,Indent,MaxLen: Sw_Integer;var Modified : boolean): String;
  2565. var
  2566. PW : PWatch;
  2567. ValOffset : Sw_integer;
  2568. S : String;
  2569. begin
  2570. Modified:=false;
  2571. if Item>=WatchesCollection^.Count then
  2572. begin
  2573. GetIndentedText:='';
  2574. exit;
  2575. end;
  2576. PW:=WatchesCollection^.At(Item);
  2577. ValOffset:=Length(GetStr(PW^.Expr))+2;
  2578. if not assigned(PW^.expr) then
  2579. GetIndentedText:=''
  2580. else if Indent<ValOffset then
  2581. begin
  2582. S:=GetStr(PW^.Expr);
  2583. if Indent=0 then
  2584. S:=' '+S
  2585. else
  2586. S:=Copy(S,Indent,High(S));
  2587. if not assigned(PW^.current_value) then
  2588. S:=S+' <Unknown value>'
  2589. else
  2590. S:=S+' '+GetPChar(PW^.Current_value);
  2591. GetIndentedText:=Copy(S,1,MaxLen);
  2592. end
  2593. else
  2594. begin
  2595. if not assigned(PW^.Current_value) or
  2596. (StrLen(PW^.Current_value)<Indent-Valoffset) then
  2597. S:=''
  2598. else
  2599. S:=GetPchar(@(PW^.Current_Value[Indent-Valoffset]));
  2600. GetIndentedText:=Copy(S,1,MaxLen);
  2601. end;
  2602. if assigned(PW^.current_value) and
  2603. assigned(PW^.last_value) and
  2604. (strcomp(PW^.Last_value,PW^.Current_value)<>0) then
  2605. Modified:=true;
  2606. end;
  2607. procedure TWatchesListBox.EditCurrent;
  2608. var
  2609. P: PWatch;
  2610. begin
  2611. if Range=0 then Exit;
  2612. if Focused<WatchesCollection^.Count then
  2613. P:=WatchesCollection^.At(Focused)
  2614. else
  2615. P:=New(PWatch,Init(''));
  2616. Application^.ExecuteDialog(New(PWatchItemDialog,Init(P)),nil);
  2617. WatchesCollection^.Update;
  2618. end;
  2619. function TWatchesListBox.GetText (Item: Sw_Integer; MaxLen: Sw_Integer): String;
  2620. var
  2621. Dummy_Modified : boolean;
  2622. begin
  2623. GetText:=GetIndentedText(Item, 0, MaxLen, Dummy_Modified);
  2624. end;
  2625. procedure TWatchesListBox.DeleteCurrent;
  2626. var
  2627. P: PWatch;
  2628. begin
  2629. if (Range=0) or
  2630. (Focused>=WatchesCollection^.Count) then
  2631. exit;
  2632. P:=WatchesCollection^.At(Focused);
  2633. WatchesCollection^.free(P);
  2634. WatchesCollection^.Update;
  2635. end;
  2636. procedure TWatchesListBox.EditNew;
  2637. var
  2638. P: PWatch;
  2639. S : string;
  2640. begin
  2641. if Focused<WatchesCollection^.Count then
  2642. begin
  2643. P:=WatchesCollection^.At(Focused);
  2644. S:=GetStr(P^.expr);
  2645. end
  2646. else
  2647. S:='';
  2648. P:=New(PWatch,Init(S));
  2649. if Application^.ExecuteDialog(New(PWatchItemDialog,Init(P)),nil)<>cmCancel then
  2650. begin
  2651. WatchesCollection^.AtInsert(Focused,P);
  2652. WatchesCollection^.Update;
  2653. end
  2654. else
  2655. dispose(P,Done);
  2656. end;
  2657. procedure TWatchesListBox.Draw;
  2658. var
  2659. I, J, Item: Sw_Integer;
  2660. NormalColor, SelectedColor, FocusedColor, Color: Word;
  2661. ColWidth, CurCol, Indent: Integer;
  2662. B: TDrawBuffer;
  2663. Modified : boolean;
  2664. Text: String;
  2665. SCOff: Byte;
  2666. TC: byte;
  2667. procedure MT(var C: word);
  2668. begin
  2669. if TC<>0 then C:=(C and $ff0f) or (TC and $f0);
  2670. end;
  2671. begin
  2672. if (Owner<>nil) then TC:=ord(Owner^.GetColor(6)) else TC:=0;
  2673. if State and (sfSelected + sfActive) = (sfSelected + sfActive) then
  2674. begin
  2675. NormalColor := GetColor(1);
  2676. FocusedColor := GetColor(3);
  2677. SelectedColor := GetColor(4);
  2678. end else
  2679. begin
  2680. NormalColor := GetColor(2);
  2681. SelectedColor := GetColor(4);
  2682. end;
  2683. if Transparent then
  2684. begin MT(NormalColor); MT(SelectedColor); end;
  2685. (* if NoSelection then
  2686. SelectedColor:=NormalColor;*)
  2687. if HScrollBar <> nil then Indent := HScrollBar^.Value
  2688. else Indent := 0;
  2689. ColWidth := Size.X div NumCols + 1;
  2690. for I := 0 to Size.Y - 1 do
  2691. begin
  2692. for J := 0 to NumCols-1 do
  2693. begin
  2694. Item := J*Size.Y + I + TopItem;
  2695. CurCol := J*ColWidth;
  2696. if (State and (sfSelected + sfActive) = (sfSelected + sfActive)) and
  2697. (Focused = Item) and (Range > 0) then
  2698. begin
  2699. Color := FocusedColor;
  2700. SetCursor(CurCol+1,I);
  2701. SCOff := 0;
  2702. end
  2703. else if (Item < Range) and IsSelected(Item) then
  2704. begin
  2705. Color := SelectedColor;
  2706. SCOff := 2;
  2707. end
  2708. else
  2709. begin
  2710. Color := NormalColor;
  2711. SCOff := 4;
  2712. end;
  2713. MoveChar(B[CurCol], ' ', Color, ColWidth);
  2714. if Item < Range then
  2715. begin
  2716. (* Text := GetText(Item, ColWidth + Indent);
  2717. Text := Copy(Text,Indent,ColWidth); *)
  2718. Text:=GetIndentedText(Item,Indent,ColWidth,Modified);
  2719. if modified then
  2720. begin
  2721. SCOff:=0;
  2722. Color:=(Color and $fff0) or Red;
  2723. end;
  2724. MoveStr(B[CurCol], Text, Color);
  2725. if {ShowMarkers or } Modified then
  2726. begin
  2727. WordRec(B[CurCol]).Lo := Byte(SpecialChars[SCOff]);
  2728. WordRec(B[CurCol+ColWidth-2]).Lo := Byte(SpecialChars[SCOff+1]);
  2729. WordRec(B[CurCol+ColWidth-2]).Hi := Color and $ff;
  2730. end;
  2731. end;
  2732. MoveChar(B[CurCol+ColWidth-1], #179, GetColor(5), 1);
  2733. end;
  2734. WriteLine(0, I, Size.X, 1, B);
  2735. end;
  2736. end;
  2737. function TWatchesListBox.GetLocalMenu: PMenu;
  2738. var M: PMenu;
  2739. begin
  2740. if (Owner<>nil) and (Owner^.GetState(sfModal)) then M:=nil else
  2741. M:=NewMenu(
  2742. NewItem(menu_watchlocal_edit,'',kbNoKey,cmEdit,hcNoContext,
  2743. NewItem(menu_watchlocal_new,'',kbNoKey,cmNew,hcNoContext,
  2744. NewItem(menu_watchlocal_delete,'',kbNoKey,cmDelete,hcNoContext,
  2745. NewLine(
  2746. NewItem(menu_msglocal_saveas,'',kbNoKey,cmSaveAs,hcSaveAs,
  2747. nil))))));
  2748. GetLocalMenu:=M;
  2749. end;
  2750. procedure TWatchesListBox.HandleEvent(var Event: TEvent);
  2751. var DontClear: boolean;
  2752. begin
  2753. case Event.What of
  2754. evKeyDown :
  2755. begin
  2756. DontClear:=false;
  2757. case Event.KeyCode of
  2758. kbEnter :
  2759. Message(@Self,evCommand,cmEdit,nil);
  2760. kbIns :
  2761. Message(@Self,evCommand,cmNew,nil);
  2762. kbDel :
  2763. Message(@Self,evCommand,cmDelete,nil);
  2764. else
  2765. DontClear:=true;
  2766. end;
  2767. if not DontClear then
  2768. ClearEvent(Event);
  2769. end;
  2770. evBroadcast :
  2771. case Event.Command of
  2772. cmListItemSelected :
  2773. if Event.InfoPtr=@Self then
  2774. Message(@Self,evCommand,cmEdit,nil);
  2775. end;
  2776. evCommand :
  2777. begin
  2778. DontClear:=false;
  2779. case Event.Command of
  2780. cmEdit :
  2781. EditCurrent;
  2782. cmDelete :
  2783. DeleteCurrent;
  2784. cmNew :
  2785. EditNew;
  2786. else
  2787. DontClear:=true;
  2788. end;
  2789. if not DontClear then
  2790. ClearEvent(Event);
  2791. end;
  2792. end;
  2793. inherited HandleEvent(Event);
  2794. end;
  2795. constructor TWatchesListBox.Load(var S: TStream);
  2796. begin
  2797. inherited Load(S);
  2798. If assigned(List) then
  2799. dispose(list,done);
  2800. List:=WatchesCollection;
  2801. { we must set Range PM }
  2802. SetRange(List^.count+1);
  2803. end;
  2804. procedure TWatchesListBox.Store(var S: TStream);
  2805. var OL: PCollection;
  2806. OldRange : Sw_integer;
  2807. begin
  2808. OL:=List;
  2809. OldRange:=Range;
  2810. Range:=0;
  2811. New(List, Init(1,1));
  2812. inherited Store(S);
  2813. Dispose(List, Done);
  2814. List:=OL;
  2815. { ^^^ nasty trick - has anyone a better idea how to avoid storing the
  2816. collection? Pasting here a modified version of TListBox.Store+
  2817. TAdvancedListBox.Store isn't a better solution, since by eventually
  2818. changing the obj-hierarchy you'll always have to modify this, too - BG }
  2819. SetRange(OldRange);
  2820. end;
  2821. destructor TWatchesListBox.Done;
  2822. begin
  2823. List:=nil;
  2824. inherited Done;
  2825. end;
  2826. {****************************************************************************
  2827. TWatchesWindow
  2828. ****************************************************************************}
  2829. Constructor TWatchesWindow.Init;
  2830. var
  2831. HSB,VSB: PScrollBar;
  2832. R,R2 : trect;
  2833. begin
  2834. Desktop^.GetExtent(R);
  2835. R.A.Y:=R.B.Y-7;
  2836. inherited Init(R, dialog_watches,SearchFreeWindowNo);
  2837. Palette:=wpCyanWindow;
  2838. GetExtent(R);
  2839. HelpCtx:=hcWatchesWindow;
  2840. R.Grow(-1,-1);
  2841. R2.Copy(R);
  2842. Inc(R2.B.Y);
  2843. R2.A.Y:=R2.B.Y-1;
  2844. New(HSB, Init(R2));
  2845. HSB^.GrowMode:=gfGrowLoY+gfGrowHiY+gfGrowHiX;
  2846. HSB^.SetStep(R.B.X-R.A.X,1);
  2847. Insert(HSB);
  2848. R2.Copy(R);
  2849. Inc(R2.B.X);
  2850. R2.A.X:=R2.B.X-1;
  2851. New(VSB, Init(R2));
  2852. VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY;
  2853. Insert(VSB);
  2854. New(WLB,Init(R,HSB,VSB));
  2855. WLB^.GrowMode:=gfGrowHiX+gfGrowHiY;
  2856. WLB^.Transparent:=true;
  2857. Insert(WLB);
  2858. If assigned(WatchesWindow) then
  2859. dispose(WatchesWindow,done);
  2860. WatchesWindow:=@Self;
  2861. Update;
  2862. end;
  2863. procedure TWatchesWindow.Update;
  2864. begin
  2865. WatchesCollection^.Update;
  2866. Draw;
  2867. end;
  2868. constructor TWatchesWindow.Load(var S: TStream);
  2869. begin
  2870. inherited Load(S);
  2871. GetSubViewPtr(S,WLB);
  2872. If assigned(WatchesWindow) then
  2873. dispose(WatchesWindow,done);
  2874. WatchesWindow:=@Self;
  2875. end;
  2876. procedure TWatchesWindow.Store(var S: TStream);
  2877. begin
  2878. inherited Store(S);
  2879. PutSubViewPtr(S,WLB);
  2880. end;
  2881. Destructor TWatchesWindow.Done;
  2882. begin
  2883. WatchesWindow:=nil;
  2884. Dispose(WLB,done);
  2885. inherited done;
  2886. end;
  2887. {****************************************************************************
  2888. TWatchItemDialog
  2889. ****************************************************************************}
  2890. constructor TWatchItemDialog.Init(AWatch: PWatch);
  2891. var R,R2: TRect;
  2892. begin
  2893. R.Assign(0,0,50,10);
  2894. inherited Init(R,'Edit Watch');
  2895. Watch:=AWatch;
  2896. GetExtent(R); R.Grow(-3,-2);
  2897. Inc(R.A.Y); R.B.Y:=R.A.Y+1; R.B.X:=R.A.X+36;
  2898. New(NameIL, Init(R, 255)); Insert(NameIL);
  2899. R2.Copy(R); R2.A.X:=R2.B.X; R2.B.X:=R2.A.X+3;
  2900. Insert(New(PHistory, Init(R2, NameIL, hidWatchDialog)));
  2901. R2.Copy(R); R2.Move(-1,-1);
  2902. Insert(New(PLabel, Init(R2, label_watch_expressiontowatch, NameIL)));
  2903. GetExtent(R);
  2904. R.Grow(-3,-1);
  2905. R.A.Y:=R.A.Y+3;
  2906. TextST:=New(PAdvancedStaticText, Init(R, label_watch_values));
  2907. Insert(TextST);
  2908. InsertButtons(@Self);
  2909. NameIL^.Select;
  2910. end;
  2911. function TWatchItemDialog.Execute: Word;
  2912. var R: word;
  2913. S1,S2: string;
  2914. begin
  2915. S1:=GetStr(Watch^.expr);
  2916. NameIL^.SetData(S1);
  2917. S1:=GetPChar(Watch^.Current_value);
  2918. S2:=GetPChar(Watch^.Last_value);
  2919. ClearFormatParams;
  2920. AddFormatParamStr(S1);
  2921. AddFormatParamStr(S2);
  2922. if assigned(Watch^.Last_value) and
  2923. assigned(Watch^.Current_value) and
  2924. (strcomp(Watch^.Last_value,Watch^.Current_value)=0) then
  2925. S1:=FormatStrF(msg_watch_currentvalue,FormatParams)
  2926. else
  2927. S1:=FormatStrF(msg_watch_currentandpreviousvalue,FormatParams);
  2928. TextST^.SetText(S1);
  2929. if assigned(FirstEditorWindow) then
  2930. FindReplaceEditor:=FirstEditorWindow^.Editor;
  2931. R:=inherited Execute;
  2932. FindReplaceEditor:=nil;
  2933. if R=cmOK then
  2934. begin
  2935. NameIL^.GetData(S1);
  2936. Watch^.Rename(S1);
  2937. {$ifndef NODEBUG}
  2938. If assigned(Debugger) then
  2939. Debugger^.ReadWatches;
  2940. {$endif NODEBUG}
  2941. end;
  2942. Execute:=R;
  2943. end;
  2944. {****************************************************************************
  2945. TStackWindow
  2946. ****************************************************************************}
  2947. constructor TFramesListBox.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  2948. begin
  2949. Inherited Init(Bounds,AHScrollBar,AVScrollBar);
  2950. end;
  2951. procedure TFramesListBox.Update;
  2952. var i : longint;
  2953. W : PSourceWindow;
  2954. begin
  2955. {$ifndef NODEBUG}
  2956. { call backtrace command }
  2957. If not assigned(Debugger) then
  2958. exit;
  2959. DeskTop^.Lock;
  2960. Clear;
  2961. { forget all old frames }
  2962. Debugger^.clear_frames;
  2963. if Debugger^.WindowWidth<>-1 then
  2964. Debugger^.Command('set width 0xffffffff');
  2965. Debugger^.Command('backtrace');
  2966. { generate list }
  2967. { all is in tframeentry }
  2968. for i:=0 to Debugger^.frame_count-1 do
  2969. begin
  2970. with Debugger^.frames[i]^ do
  2971. begin
  2972. if assigned(file_name) then
  2973. AddItem(new(PMessageItem,init(0,GetPChar(function_name)+GetPChar(args),
  2974. AddModuleName(GetPChar(file_name)),line_number,1)))
  2975. else
  2976. AddItem(new(PMessageItem,init(0,HexStr(address,8)+' '+GetPChar(function_name)+GetPChar(args),
  2977. AddModuleName(''),line_number,1)));
  2978. W:=SearchOnDesktop(GetPChar(file_name),false);
  2979. { First reset all Debugger rows }
  2980. If assigned(W) then
  2981. begin
  2982. W^.Editor^.SetLineFlagExclusive(lfDebuggerRow,-1);
  2983. W^.Editor^.DebuggerRow:=-1;
  2984. end;
  2985. end;
  2986. end;
  2987. { Now set all Debugger rows }
  2988. for i:=0 to Debugger^.frame_count-1 do
  2989. begin
  2990. with Debugger^.frames[i]^ do
  2991. begin
  2992. W:=SearchOnDesktop(GetPChar(file_name),false);
  2993. If assigned(W) then
  2994. begin
  2995. If W^.Editor^.DebuggerRow=-1 then
  2996. begin
  2997. W^.Editor^.SetLineFlagState(line_number-1,lfDebuggerRow,true);
  2998. W^.Editor^.DebuggerRow:=line_number-1;
  2999. end;
  3000. end;
  3001. end;
  3002. end;
  3003. if Assigned(list) and (List^.Count > 0) then
  3004. FocusItem(0);
  3005. if Debugger^.WindowWidth<>-1 then
  3006. Debugger^.Command('set width '+IntToStr(Debugger^.WindowWidth));
  3007. DeskTop^.Unlock;
  3008. {$endif NODEBUG}
  3009. end;
  3010. function TFramesListBox.GetLocalMenu: PMenu;
  3011. begin
  3012. GetLocalMenu:=Inherited GetLocalMenu;
  3013. end;
  3014. procedure TFramesListBox.GotoSource;
  3015. begin
  3016. {$ifndef NODEBUG}
  3017. { select frame for watches }
  3018. If not assigned(Debugger) then
  3019. exit;
  3020. Debugger^.Command('f '+IntToStr(Focused));
  3021. { for local vars }
  3022. Debugger^.RereadWatches;
  3023. {$endif NODEBUG}
  3024. { goto source }
  3025. inherited GotoSource;
  3026. end;
  3027. procedure TFramesListBox.GotoAssembly;
  3028. begin
  3029. {$ifndef NODEBUG}
  3030. { select frame for watches }
  3031. If not assigned(Debugger) then
  3032. exit;
  3033. Debugger^.Command('f '+IntToStr(Focused));
  3034. { for local vars }
  3035. Debugger^.RereadWatches;
  3036. {$endif}
  3037. { goto source/assembly mixture }
  3038. InitDisassemblyWindow;
  3039. DisassemblyWindow^.LoadFunction('');
  3040. {$ifndef NODEBUG}
  3041. DisassemblyWindow^.SetCurAddress(Debugger^.frames[Focused]^.address);
  3042. DisassemblyWindow^.SelectInDebugSession;
  3043. {$endif NODEBUG}
  3044. end;
  3045. procedure TFramesListBox.HandleEvent(var Event: TEvent);
  3046. begin
  3047. if ((Event.What=EvKeyDown) and (Event.CharCode='i')) or
  3048. ((Event.What=EvCommand) and (Event.Command=cmDisassemble)) then
  3049. GotoAssembly;
  3050. inherited HandleEvent(Event);
  3051. end;
  3052. destructor TFramesListBox.Done;
  3053. begin
  3054. Inherited Done;
  3055. end;
  3056. Constructor TStackWindow.Init;
  3057. var
  3058. HSB,VSB: PScrollBar;
  3059. R,R2 : trect;
  3060. begin
  3061. Desktop^.GetExtent(R);
  3062. R.A.Y:=R.B.Y-5;
  3063. inherited Init(R, dialog_callstack, wnNoNumber);
  3064. Palette:=wpCyanWindow;
  3065. GetExtent(R);
  3066. HelpCtx:=hcStackWindow;
  3067. R.Grow(-1,-1);
  3068. R2.Copy(R);
  3069. Inc(R2.B.Y);
  3070. R2.A.Y:=R2.B.Y-1;
  3071. New(HSB, Init(R2));
  3072. HSB^.GrowMode:=gfGrowLoY+gfGrowHiY+gfGrowHiX;
  3073. Insert(HSB);
  3074. R2.Copy(R);
  3075. Inc(R2.B.X);
  3076. R2.A.X:=R2.B.X-1;
  3077. New(VSB, Init(R2));
  3078. VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY;
  3079. Insert(VSB);
  3080. New(FLB,Init(R,HSB,VSB));
  3081. FLB^.GrowMode:=gfGrowHiX+gfGrowHiY;
  3082. Insert(FLB);
  3083. If assigned(StackWindow) then
  3084. dispose(StackWindow,done);
  3085. StackWindow:=@Self;
  3086. Update;
  3087. end;
  3088. procedure TStackWindow.Update;
  3089. begin
  3090. FLB^.Update;
  3091. DrawView;
  3092. end;
  3093. constructor TStackWindow.Load(var S: TStream);
  3094. begin
  3095. inherited Load(S);
  3096. GetSubViewPtr(S,FLB);
  3097. If assigned(StackWindow) then
  3098. dispose(StackWindow,done);
  3099. StackWindow:=@Self;
  3100. end;
  3101. procedure TStackWindow.Store(var S: TStream);
  3102. begin
  3103. inherited Store(S);
  3104. PutSubViewPtr(S,FLB);
  3105. end;
  3106. Destructor TStackWindow.Done;
  3107. begin
  3108. StackWindow:=nil;
  3109. Dispose(FLB,done);
  3110. inherited done;
  3111. end;
  3112. {****************************************************************************
  3113. Init/Final
  3114. ****************************************************************************}
  3115. function GetGDBTargetShortName : string;
  3116. begin
  3117. {$ifdef SUPPORT_REMOTE}
  3118. {$ifdef PALMOSGDB}
  3119. GetGDBTargetShortName:='palmos';
  3120. {$else}
  3121. GetGDBTargetShortName:='linux';
  3122. {$endif PALMOSGDB}
  3123. {$else not SUPPORT_REMOTE}
  3124. GetGDBTargetShortName:=source_info.shortname
  3125. {$endif not SUPPORT_REMOTE}
  3126. end;
  3127. procedure InitDebugger;
  3128. {$ifdef DEBUG}
  3129. var s : string;
  3130. i,p : longint;
  3131. {$endif DEBUG}
  3132. var
  3133. NeedRecompileExe : boolean;
  3134. cm : longint;
  3135. begin
  3136. {$ifdef DEBUG}
  3137. if not use_gdb_file then
  3138. begin
  3139. Assign(gdb_file,GDBOutFileName);
  3140. {$I-}
  3141. Rewrite(gdb_file);
  3142. if InOutRes<>0 then
  3143. begin
  3144. s:=GDBOutFileName;
  3145. p:=pos('.',s);
  3146. if p>1 then
  3147. for i:=0 to 9 do
  3148. begin
  3149. s:=copy(s,1,p-2)+chr(i+ord('0'))+copy(s,p,length(s));
  3150. InOutRes:=0;
  3151. Assign(gdb_file,s);
  3152. rewrite(gdb_file);
  3153. if InOutRes=0 then
  3154. break;
  3155. end;
  3156. end;
  3157. if IOResult=0 then
  3158. Use_gdb_file:=true;
  3159. end;
  3160. {$I+}
  3161. {$endif}
  3162. NeedRecompileExe:=false;
  3163. if UpCaseStr(TargetSwitches^.GetCurrSelParam)<>UpCaseStr(GetGDBTargetShortName) then
  3164. begin
  3165. ClearFormatParams;
  3166. AddFormatParamStr(TargetSwitches^.GetCurrSelParam);
  3167. AddFormatParamStr(GetGDBTargetShortName);
  3168. cm:=ConfirmBox(msg_cantdebugchangetargetto,@FormatParams,true);
  3169. if cm=cmCancel then
  3170. Exit;
  3171. if cm=cmYes then
  3172. begin
  3173. { force recompilation }
  3174. PrevMainFile:='';
  3175. NeedRecompileExe:=true;
  3176. TargetSwitches^.SetCurrSelParam(GetGDBTargetShortName);
  3177. If DebugInfoSwitches^.GetCurrSelParam='-' then
  3178. DebugInfoSwitches^.SetCurrSelParam('l');
  3179. IDEApp.UpdateTarget;
  3180. end;
  3181. end;
  3182. if not NeedRecompileExe then
  3183. NeedRecompileExe:=(not ExistsFile(ExeFile)) or (CompilationPhase<>cpDone) or
  3184. (PrevMainFile<>MainFile) or NeedRecompile(cRun,false);
  3185. if Not NeedRecompileExe and Not MainHasDebugInfo then
  3186. begin
  3187. ClearFormatParams;
  3188. cm:=ConfirmBox(msg_compiledwithoutdebuginforecompile,nil,true);
  3189. if cm=cmCancel then
  3190. Exit;
  3191. if cm=cmYes then
  3192. begin
  3193. { force recompilation }
  3194. PrevMainFile:='';
  3195. NeedRecompileExe:=true;
  3196. DebugInfoSwitches^.SetCurrSelParam('l');
  3197. end;
  3198. end;
  3199. if NeedRecompileExe then
  3200. DoCompile(cRun);
  3201. if CompilationPhase<>cpDone then
  3202. Exit;
  3203. if (EXEFile='') then
  3204. begin
  3205. ErrorBox(msg_nothingtodebug,nil);
  3206. Exit;
  3207. end;
  3208. { init debugcontroller }
  3209. {$ifndef NODEBUG}
  3210. if not assigned(Debugger) then
  3211. begin
  3212. PushStatus(msg_startingdebugger);
  3213. new(Debugger,Init);
  3214. PopStatus;
  3215. end;
  3216. Debugger^.SetExe(ExeFile);
  3217. {$endif NODEBUG}
  3218. {$ifdef GDBWINDOW}
  3219. InitGDBWindow;
  3220. {$endif def GDBWINDOW}
  3221. end;
  3222. procedure DoneDebugger;
  3223. begin
  3224. {$ifdef DEBUG}
  3225. If IDEApp.IsRunning then
  3226. PushStatus('Closing debugger');
  3227. {$endif}
  3228. {$ifndef NODEBUG}
  3229. if assigned(Debugger) then
  3230. dispose(Debugger,Done);
  3231. Debugger:=nil;
  3232. {$endif NODEBUG}
  3233. {$ifdef DOS}
  3234. If assigned(UserScreen) then
  3235. PDosScreen(UserScreen)^.FreeGraphBuffer;
  3236. {$endif DOS}
  3237. {$ifdef DEBUG}
  3238. If Use_gdb_file then
  3239. begin
  3240. Use_gdb_file:=false;
  3241. Close(GDB_file);
  3242. end;
  3243. If IDEApp.IsRunning then
  3244. PopStatus;
  3245. {$endif DEBUG}
  3246. end;
  3247. procedure InitGDBWindow;
  3248. var
  3249. R : TRect;
  3250. begin
  3251. if GDBWindow=nil then
  3252. begin
  3253. DeskTop^.GetExtent(R);
  3254. new(GDBWindow,init(R));
  3255. DeskTop^.Insert(GDBWindow);
  3256. end;
  3257. end;
  3258. procedure DoneGDBWindow;
  3259. begin
  3260. If IDEApp.IsRunning and
  3261. assigned(GDBWindow) then
  3262. begin
  3263. DeskTop^.Delete(GDBWindow);
  3264. end;
  3265. GDBWindow:=nil;
  3266. end;
  3267. procedure InitDisassemblyWindow;
  3268. var
  3269. R : TRect;
  3270. begin
  3271. if DisassemblyWindow=nil then
  3272. begin
  3273. DeskTop^.GetExtent(R);
  3274. new(DisassemblyWindow,init(R));
  3275. DeskTop^.Insert(DisassemblyWindow);
  3276. end;
  3277. end;
  3278. procedure DoneDisassemblyWindow;
  3279. begin
  3280. if assigned(DisassemblyWindow) then
  3281. begin
  3282. DeskTop^.Delete(DisassemblyWindow);
  3283. Dispose(DisassemblyWindow,Done);
  3284. DisassemblyWindow:=nil;
  3285. end;
  3286. end;
  3287. procedure InitStackWindow;
  3288. begin
  3289. if StackWindow=nil then
  3290. begin
  3291. new(StackWindow,init);
  3292. DeskTop^.Insert(StackWindow);
  3293. end;
  3294. end;
  3295. procedure DoneStackWindow;
  3296. begin
  3297. if assigned(StackWindow) then
  3298. begin
  3299. DeskTop^.Delete(StackWindow);
  3300. StackWindow:=nil;
  3301. end;
  3302. end;
  3303. procedure InitBreakpoints;
  3304. begin
  3305. New(BreakpointsCollection,init(10,10));
  3306. end;
  3307. procedure DoneBreakpoints;
  3308. begin
  3309. Dispose(BreakpointsCollection,Done);
  3310. BreakpointsCollection:=nil;
  3311. end;
  3312. procedure InitWatches;
  3313. begin
  3314. New(WatchesCollection,init);
  3315. end;
  3316. procedure DoneWatches;
  3317. begin
  3318. Dispose(WatchesCollection,Done);
  3319. WatchesCollection:=nil;
  3320. end;
  3321. procedure RegisterFPDebugViews;
  3322. begin
  3323. RegisterType(RWatchesWindow);
  3324. RegisterType(RBreakpointsWindow);
  3325. RegisterType(RWatchesListBox);
  3326. RegisterType(RBreakpointsListBox);
  3327. RegisterType(RStackWindow);
  3328. RegisterType(RFramesListBox);
  3329. RegisterType(RBreakpoint);
  3330. RegisterType(RWatch);
  3331. RegisterType(RBreakpointCollection);
  3332. RegisterType(RWatchesCollection);
  3333. end;
  3334. end.
  3335. {
  3336. $Log$
  3337. Revision 1.55 2004-11-11 15:20:52 florian
  3338. * applied Peter's patch from yesterday
  3339. Revision 1.54 2004/11/08 21:55:09 peter
  3340. * fixed run directory
  3341. * Open dialog starts in dir of last editted file
  3342. Revision 1.53 2004/11/08 20:28:26 peter
  3343. * Breakpoints are now deleted when removed from source, disabling is
  3344. still possible from the breakpoint list
  3345. * COMPILER_1_0, FVISION, GABOR defines removed, only support new
  3346. FV and 1.9.x compilers
  3347. * Run directory added to Run menu
  3348. * Useless programinfo window removed
  3349. Revision 1.52 2004/11/06 17:22:52 peter
  3350. * fixes for new fv
  3351. Revision 1.51 2004/07/09 23:17:25 peter
  3352. * revert isatty patch
  3353. Revision 1.49 2004/02/20 21:46:06 peter
  3354. * fix compile with 1.0.x
  3355. Revision 1.48 2003/11/19 17:11:39 marco
  3356. * termio unit
  3357. Revision 1.47 2003/11/17 10:05:51 marco
  3358. * threads for FreeBSD. Not working tho
  3359. Revision 1.46 2003/03/30 12:12:12 armin
  3360. * allow local and remote debugging if SUPPORT_REMOTE is given
  3361. Revision 1.45 2003/03/27 14:10:55 pierre
  3362. * fix problem with mixed case target names as suggested by Armin Diehl
  3363. Revision 1.44 2003/01/14 16:25:23 pierre
  3364. + small palmos specific additions
  3365. Revision 1.43 2002/12/18 01:20:12 pierre
  3366. + Use TEditorInputLine instead of TInputLine
  3367. Revision 1.42 2002/12/16 15:15:40 pierre
  3368. * Added TBreakpointCollection.FindBreakpointAt method
  3369. Revision 1.41 2002/12/16 09:05:28 pierre
  3370. * sanity ceck in ToggleFileLine method
  3371. Revision 1.40 2002/02/09 02:04:46 pierre
  3372. * fix problem with disable all invalid breakpoints
  3373. Revision 1.39 2002/12/12 00:05:57 pierre
  3374. * add code for breakpoint moves + registers in fprags.pas unit
  3375. Revision 1.38 2002/11/30 01:56:52 pierre
  3376. + powerpc cpu support started
  3377. Revision 1.37 2002/11/28 13:00:25 pierre
  3378. + remote support
  3379. Revision 1.36 2002/11/21 17:52:28 pierre
  3380. * some crossgdb infos added
  3381. Revision 1.35 2002/11/21 15:48:39 pierre
  3382. * fix several problems related to remote cross debugging
  3383. Revision 1.34 2002/11/21 00:37:56 pierre
  3384. + some cross gdb enhancements
  3385. Revision 1.33 2002/09/21 22:23:49 pierre
  3386. * restore text mode on reset for Dos apps
  3387. Revision 1.32 2002/09/17 21:58:45 pierre
  3388. * correct last fpu patch so 'info all' is called only once
  3389. Revision 1.31 2002/09/17 21:48:41 pierre
  3390. * allow fpu window to be resized
  3391. Revision 1.30 2002/09/17 21:20:07 pierre
  3392. * fix infinite recursion if GDB window and register window open
  3393. Revision 1.29 2002/09/13 22:30:50 pierre
  3394. * only fpc uses video unit
  3395. Revision 1.28 2002/09/13 08:13:07 pierre
  3396. * avoid RTE 201 in hexstr calls
  3397. Revision 1.27 2002/09/07 21:04:41 carl
  3398. * fix range check errors for version 1.1 compilation
  3399. Revision 1.26 2002/09/07 15:40:42 peter
  3400. * old logs removed and tabs fixed
  3401. Revision 1.25 2002/09/03 13:59:47 pierre
  3402. + added history for watches and breakpoints
  3403. Revision 1.24 2002/09/02 10:18:09 pierre
  3404. * fix problems with breakpoint lists
  3405. Revision 1.23 2002/08/13 08:59:12 pierre
  3406. + Run menu changes depending on wether the debuggee is running or not
  3407. Revision 1.22 2002/08/13 07:15:02 pierre
  3408. + Disable all invalid breakpoints feature added
  3409. Revision 1.21 2002/06/10 19:26:48 pierre
  3410. * check if DebuggeTTY is a valid terminal
  3411. Revision 1.20 2002/06/06 14:11:25 pierre
  3412. * handle win32 Ctrl-C change for graphic version
  3413. Revision 1.19 2002/06/06 08:16:18 pierre
  3414. * avoid crashes if quitting while debuggee is running
  3415. Revision 1.18 2002/04/25 13:33:31 pierre
  3416. * fix the problem with dirs containing asterisks
  3417. Revision 1.17 2002/04/17 11:11:54 pierre
  3418. * avoid problems for ClassVariable in Watches window
  3419. Revision 1.16 2002/04/11 06:41:13 pierre
  3420. * fix problem of TWatchesListBox with fvision
  3421. Revision 1.15 2002/04/03 06:18:30 pierre
  3422. * fix some win32 GDB filename problems
  3423. Revision 1.14 2002/04/02 15:09:38 pierre
  3424. * fixed wrong exit without unlock
  3425. Revision 1.13 2002/04/02 13:23:54 pierre
  3426. * Use StrToCard and HexToCard functions to avoid signed/unsigned overflows
  3427. Revision 1.12 2002/04/02 12:20:58 pierre
  3428. * fix problem with breakpoints in subdirs
  3429. Revision 1.11 2002/04/02 11:10:29 pierre
  3430. * fix FPC_BREAK_ERROR problem and avoid blinking J
  3431. Revision 1.10 2002/03/27 11:24:09 pierre
  3432. * fix several problems related to long file nmze support for win32 exes
  3433. Revision 1.9 2002/02/06 14:45:00 pierre
  3434. + handle signals
  3435. }