fpdebug.pas 97 KB

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