fpdebug.pas 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  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. uses
  15. Objects,Dialogs,Drivers,Views,
  16. GDBCon,GDBInt,Menus,
  17. WViews,
  18. FPViews;
  19. type
  20. PDebugController=^TDebugController;
  21. TDebugController=object(TGDBController)
  22. InvalidSourceLine : boolean;
  23. LastFileName : string;
  24. LastSource : PView; {PsourceWindow !! }
  25. HiddenStepsCount : longint;
  26. { no need to switch if using another terminal }
  27. NoSwitch : boolean;
  28. constructor Init(const exefn:string);
  29. destructor Done;
  30. procedure DoSelectSourceline(const fn:string;line:longint);virtual;
  31. { procedure DoStartSession;virtual;
  32. procedure DoBreakSession;virtual;}
  33. procedure DoEndSession(code:longint);virtual;
  34. procedure AnnotateError;
  35. procedure InsertBreakpoints;
  36. procedure RemoveBreakpoints;
  37. procedure ReadWatches;
  38. procedure ResetBreakpointsValues;
  39. procedure DoDebuggerScreen;virtual;
  40. procedure DoUserScreen;virtual;
  41. procedure Reset;virtual;
  42. procedure ResetDebuggerRows;
  43. procedure Run;virtual;
  44. procedure Continue;virtual;
  45. procedure UntilReturn;virtual;
  46. procedure CommandBegin(const s:string);virtual;
  47. procedure CommandEnd(const s:string);virtual;
  48. function AllowQuit : boolean;virtual;
  49. end;
  50. BreakpointType = (bt_function,bt_file_line,bt_watch,bt_awatch,bt_rwatch,bt_invalid);
  51. BreakpointState = (bs_enabled,bs_disabled,bs_deleted);
  52. PBreakpointCollection=^TBreakpointCollection;
  53. PBreakpoint=^TBreakpoint;
  54. TBreakpoint=object(TObject)
  55. typ : BreakpointType;
  56. state : BreakpointState;
  57. owner : PBreakpointCollection;
  58. Name : PString; { either function name or expr to watch }
  59. FileName : PString;
  60. OldValue,CurrentValue : Pstring;
  61. Line : Longint; { only used for bt_file_line type }
  62. Conditions : PString; { conditions relative to that breakpoint }
  63. IgnoreCount : Longint; { how many counts should be ignored }
  64. Commands : pchar; { commands that should be executed on breakpoint }
  65. GDBIndex : longint;
  66. GDBState : BreakpointState;
  67. constructor Init_function(Const AFunc : String);
  68. constructor Init_Empty;
  69. constructor Init_file_line(AFile : String; ALine : longint);
  70. constructor Init_type(atyp : BreakpointType;Const AnExpr : String);
  71. constructor Load(var S: TStream);
  72. procedure Store(var S: TStream);
  73. procedure Insert;
  74. procedure Remove;
  75. procedure Enable;
  76. procedure Disable;
  77. procedure ResetValues;
  78. destructor Done;virtual;
  79. end;
  80. TBreakpointCollection=object(TCollection)
  81. function At(Index: Integer): PBreakpoint;
  82. function GetGDB(index : longint) : PBreakpoint;
  83. function GetType(typ : BreakpointType;Const s : String) : PBreakpoint;
  84. function ToggleFileLine(Const FileName: String;LineNr : Longint) : boolean;
  85. procedure Update;
  86. procedure ShowBreakpoints(W : PSourceWindow);
  87. end;
  88. PBreakpointItem = ^TBreakpointItem;
  89. TBreakpointItem = object(TObject)
  90. Breakpoint : PBreakpoint;
  91. constructor Init(ABreakpoint : PBreakpoint);
  92. function GetText(MaxLen: Sw_integer): string; virtual;
  93. procedure Selected; virtual;
  94. function GetModuleName: string; virtual;
  95. end;
  96. PBreakpointsListBox = ^TBreakpointsListBox;
  97. TBreakpointsListBox = object(THSListBox)
  98. Transparent : boolean;
  99. NoSelection : boolean;
  100. MaxWidth : Sw_integer;
  101. (* ModuleNames : PStoreCollection; *)
  102. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  103. procedure AddBreakpoint(P: PBreakpointItem); virtual;
  104. function GetText(Item,MaxLen: Sw_Integer): String; virtual;
  105. function GetLocalMenu: PMenu;virtual;
  106. procedure Clear; virtual;
  107. procedure TrackSource; virtual;
  108. procedure EditNew; virtual;
  109. procedure EditCurrent; virtual;
  110. procedure DeleteCurrent; virtual;
  111. procedure ToggleCurrent;
  112. procedure Draw; virtual;
  113. procedure HandleEvent(var Event: TEvent); virtual;
  114. constructor Load(var S: TStream);
  115. procedure Store(var S: TStream);
  116. destructor Done; virtual;
  117. end;
  118. PBreakpointsWindow = ^TBreakpointsWindow;
  119. TBreakpointsWindow = object(TDlgWindow)
  120. BreakLB : PBreakpointsListBox;
  121. constructor Init;
  122. procedure AddBreakpoint(ABreakpoint : PBreakpoint);
  123. procedure ClearBreakpoints;
  124. procedure ReloadBreakpoints;
  125. procedure Close; virtual;
  126. procedure SizeLimits(var Min, Max: TPoint);virtual;
  127. procedure HandleEvent(var Event: TEvent); virtual;
  128. procedure Update; virtual;
  129. constructor Load(var S: TStream);
  130. procedure Store(var S: TStream);
  131. destructor Done; virtual;
  132. end;
  133. PBreakpointItemDialog = ^TBreakpointItemDialog;
  134. TBreakpointItemDialog = object(TCenterDialog)
  135. constructor Init(ABreakpoint: PBreakpoint);
  136. function Execute: Word; virtual;
  137. private
  138. Breakpoint : PBreakpoint;
  139. TypeRB : PRadioButtons;
  140. NameIL : PInputLine;
  141. ConditionsIL: PInputLine;
  142. LineIL : PInputLine;
  143. IgnoreIL : PInputLine;
  144. end;
  145. PWatch = ^TWatch;
  146. TWatch = Object(TObject)
  147. constructor Init(s : string);
  148. constructor Load(var S: TStream);
  149. procedure Store(var S: TStream);
  150. procedure rename(s : string);
  151. procedure Get_new_value;
  152. destructor done;virtual;
  153. private
  154. expr : pstring;
  155. last_value,current_value : pchar;
  156. end;
  157. PWatchesCollection = ^TWatchesCollection;
  158. TWatchesCollection = Object(TCollection)
  159. constructor Init;
  160. procedure Insert(Item: Pointer); virtual;
  161. function At(Index: Integer): PWatch;
  162. procedure Update;
  163. private
  164. MaxW : integer;
  165. end;
  166. PWatchesListBox = ^TWatchesListBox;
  167. TWatchesListBox = object(THSListBox)
  168. Transparent : boolean;
  169. MaxWidth : Sw_integer;
  170. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  171. (* procedure AddWatch(P: PWatch); virtual; *)
  172. procedure Update(AMaxWidth : integer);
  173. function GetIndentedText(Item,Indent,MaxLen: Sw_Integer): String; virtual;
  174. function GetLocalMenu: PMenu;virtual;
  175. (* procedure Clear; virtual;
  176. procedure TrackSource; virtual;*)
  177. procedure EditNew; virtual;
  178. procedure EditCurrent; virtual;
  179. procedure DeleteCurrent; virtual;
  180. (*procedure ToggleCurrent; *)
  181. procedure Draw; virtual;
  182. procedure HandleEvent(var Event: TEvent); virtual;
  183. constructor Load(var S: TStream);
  184. procedure Store(var S: TStream);
  185. destructor Done; virtual;
  186. end;
  187. PWatchItemDialog = ^TWatchItemDialog;
  188. TWatchItemDialog = object(TCenterDialog)
  189. constructor Init(AWatch: PWatch);
  190. function Execute: Word; virtual;
  191. private
  192. Watch : PWatch;
  193. NameIL : PInputLine;
  194. TextST : PAdvancedStaticText;
  195. end;
  196. PWatchesWindow = ^TWatchesWindow;
  197. TWatchesWindow = Object(TDlgWindow)
  198. WLB : PWatchesListBox;
  199. Constructor Init;
  200. constructor Load(var S: TStream);
  201. procedure Store(var S: TStream);
  202. procedure Update; virtual;
  203. destructor Done; virtual;
  204. end;
  205. PFramesListBox = ^TFramesListBox;
  206. TFramesListBox = object(TMessageListBox)
  207. constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  208. procedure Update;
  209. function GetLocalMenu: PMenu;virtual;
  210. procedure GotoSource; virtual;
  211. procedure HandleEvent(var Event: TEvent); virtual;
  212. destructor Done; virtual;
  213. end;
  214. PStackWindow = ^TStackWindow;
  215. TStackWindow = Object(TDlgWindow)
  216. FLB : PFramesListBox;
  217. Constructor Init;
  218. constructor Load(var S: TStream);
  219. procedure Store(var S: TStream);
  220. procedure Update; virtual;
  221. destructor Done; virtual;
  222. end;
  223. const
  224. StackWindow : PStackWindow = nil;
  225. procedure InitStackWindow;
  226. procedure DoneStackWindow;
  227. const
  228. BreakpointTypeStr : Array[BreakpointType] of String[9]
  229. = ( 'function','file-line','watch','awatch','rwatch','invalid' );
  230. BreakpointStateStr : Array[BreakpointState] of String[8]
  231. = ( 'enabled','disabled','invalid' );
  232. DebuggeeTTY : string = '';
  233. var
  234. Debugger : PDebugController;
  235. BreakpointsCollection : PBreakpointCollection;
  236. WatchesCollection : PwatchesCollection;
  237. procedure InitDebugger;
  238. procedure DoneDebugger;
  239. procedure InitGDBWindow;
  240. procedure DoneGDBWindow;
  241. procedure InitBreakpoints;
  242. procedure DoneBreakpoints;
  243. procedure InitWatches;
  244. procedure DoneWatches;
  245. procedure RegisterFPDebugViews;
  246. implementation
  247. uses
  248. Dos,Mouse,Video,
  249. App,Commands,Strings,
  250. FPVars,FPUtils,FPConst,
  251. FPIntf,FPCompile,FPIde,FPHelp,
  252. Validate,WEditor,WUtils;
  253. const
  254. RBreakpointsWindow: TStreamRec = (
  255. ObjType: 1701;
  256. VmtLink: Ofs(TypeOf(TBreakpointsWindow)^);
  257. Load: @TBreakpointsWindow.Load;
  258. Store: @TBreakpointsWindow.Store
  259. );
  260. RBreakpointsListBox : TStreamRec = (
  261. ObjType: 1702;
  262. VmtLink: Ofs(TypeOf(TBreakpointsListBox)^);
  263. Load: @TBreakpointsListBox.Load;
  264. Store: @TBreakpointsListBox.Store
  265. );
  266. RWatchesWindow: TStreamRec = (
  267. ObjType: 1703;
  268. VmtLink: Ofs(TypeOf(TWatchesWindow)^);
  269. Load: @TWatchesWindow.Load;
  270. Store: @TWatchesWindow.Store
  271. );
  272. RWatchesListBox: TStreamRec = (
  273. ObjType: 1704;
  274. VmtLink: Ofs(TypeOf(TWatchesListBox)^);
  275. Load: @TWatchesListBox.Load;
  276. Store: @TWatchesListBox.Store
  277. );
  278. RStackWindow: TStreamRec = (
  279. ObjType: 1705;
  280. VmtLink: Ofs(TypeOf(TStackWindow)^);
  281. Load: @TStackWindow.Load;
  282. Store: @TStackWindow.Store
  283. );
  284. RFramesListBox: TStreamRec = (
  285. ObjType: 1706;
  286. VmtLink: Ofs(TypeOf(TFramesListBox)^);
  287. Load: @TFramesListBox.Load;
  288. Store: @TFramesListBox.Store
  289. );
  290. RBreakpoint: TStreamRec = (
  291. ObjType: 1707;
  292. VmtLink: Ofs(TypeOf(TBreakpoint)^);
  293. Load: @TBreakpoint.Load;
  294. Store: @TBreakpoint.Store
  295. );
  296. RWatch: TStreamRec = (
  297. ObjType: 1708;
  298. VmtLink: Ofs(TypeOf(TWatch)^);
  299. Load: @TWatch.Load;
  300. Store: @TWatch.Store
  301. );
  302. RBreakpointCollection: TStreamRec = (
  303. ObjType: 1709;
  304. VmtLink: Ofs(TypeOf(TBreakpointCollection)^);
  305. Load: @TBreakpointCollection.Load;
  306. Store: @TBreakpointCollection.Store
  307. );
  308. RWatchesCollection: TStreamRec = (
  309. ObjType: 1710;
  310. VmtLink: Ofs(TypeOf(TWatchesCollection)^);
  311. Load: @TWatchesCollection.Load;
  312. Store: @TWatchesCollection.Store
  313. );
  314. {****************************************************************************
  315. TDebugController
  316. ****************************************************************************}
  317. constructor TDebugController.Init(const exefn:string);
  318. var f: string;
  319. begin
  320. inherited Init;
  321. f := exefn;
  322. NoSwitch:=False;
  323. LoadFile(f);
  324. SetArgs(GetRunParameters);
  325. Debugger:=@self;
  326. {$ifndef GABOR}
  327. switch_to_user:=true;
  328. {$endif}
  329. InsertBreakpoints;
  330. ReadWatches;
  331. end;
  332. procedure TDebugController.InsertBreakpoints;
  333. procedure DoInsert(PB : PBreakpoint);
  334. begin
  335. PB^.Insert;
  336. end;
  337. begin
  338. BreakpointsCollection^.ForEach(@DoInsert);
  339. end;
  340. procedure TDebugController.ReadWatches;
  341. procedure DoRead(PB : PWatch);
  342. begin
  343. PB^.Get_new_value;
  344. end;
  345. begin
  346. WatchesCollection^.ForEach(@DoRead);
  347. If Assigned(WatchesWindow) then
  348. WatchesWindow^.Update;
  349. end;
  350. procedure TDebugController.RemoveBreakpoints;
  351. procedure DoDelete(PB : PBreakpoint);
  352. begin
  353. PB^.Remove;
  354. end;
  355. begin
  356. BreakpointsCollection^.ForEach(@DoDelete);
  357. end;
  358. procedure TDebugController.ResetBreakpointsValues;
  359. procedure DoResetVal(PB : PBreakpoint);
  360. begin
  361. PB^.ResetValues;
  362. end;
  363. begin
  364. BreakpointsCollection^.ForEach(@DoResetVal);
  365. end;
  366. destructor TDebugController.Done;
  367. begin
  368. { kill the program if running }
  369. Reset;
  370. RemoveBreakpoints;
  371. inherited Done;
  372. end;
  373. procedure TDebugController.Run;
  374. begin
  375. ResetBreakpointsValues;
  376. {$ifdef win32}
  377. { Run the debugge in another console }
  378. if DebuggeeTTY<>'' then
  379. Command('set new-console on')
  380. else
  381. Command('set new-console off');
  382. NoSwitch:=DebuggeeTTY<>'';
  383. {$endif win32}
  384. {$ifdef linux}
  385. { Run the debugge in another tty }
  386. Command('set tty '+DebuggeeTTY);
  387. NoSwitch:=DebuggeeTTY<>'';
  388. {$endif win32}
  389. { Switch to user screen to get correct handles }
  390. UserScreen;
  391. inherited Run;
  392. DebuggerScreen;
  393. IDEApp.SetCmdState([cmResetDebugger,cmUntilReturn],true);
  394. If assigned(StackWindow) then
  395. StackWindow^.Update;
  396. end;
  397. procedure TDebugController.Continue;
  398. begin
  399. {$ifdef NODEBUG}
  400. NoDebugger;
  401. {$else}
  402. if not debuggee_started then
  403. Run
  404. else
  405. inherited Continue;
  406. If assigned(StackWindow) then
  407. StackWindow^.Update;
  408. {$endif NODEBUG}
  409. end;
  410. procedure TDebugController.UntilReturn;
  411. begin
  412. Command('finish');
  413. If assigned(StackWindow) then
  414. StackWindow^.Update;
  415. { We could try to get the return value !
  416. Not done yet }
  417. end;
  418. procedure TDebugController.CommandBegin(const s:string);
  419. begin
  420. if assigned(GDBWindow) and (in_command>1) then
  421. begin
  422. { We should do something special for errors !! }
  423. If StrLen(GetError)>0 then
  424. GDBWindow^.WriteErrorText(GetError);
  425. GDBWindow^.WriteOutputText(GetOutput);
  426. end;
  427. if assigned(GDBWindow) then
  428. GDBWindow^.WriteString(S);
  429. end;
  430. procedure TDebugController.CommandEnd(const s:string);
  431. begin
  432. if assigned(GDBWindow) and (in_command=0) then
  433. begin
  434. { We should do something special for errors !! }
  435. If StrLen(GetError)>0 then
  436. GDBWindow^.WriteErrorText(GetError);
  437. GDBWindow^.WriteOutputText(GetOutput);
  438. GDBWindow^.Editor^.TextEnd;
  439. end;
  440. end;
  441. function TDebugController.AllowQuit : boolean;
  442. begin
  443. if ConfirmBox('Really quit editor ?',nil,true)=cmOK then
  444. begin
  445. Message(@IDEApp,evCommand,cmQuit,nil);
  446. end
  447. else
  448. AllowQuit:=false;
  449. end;
  450. procedure TDebugController.ResetDebuggerRows;
  451. procedure ResetDebuggerRow(P: PView); {$ifndef FPC}far;{$endif}
  452. begin
  453. if assigned(P) and
  454. (TypeOf(P^)=TypeOf(TSourceWindow)) then
  455. PSourceWindow(P)^.Editor^.SetDebuggerRow(-1);
  456. end;
  457. begin
  458. Desktop^.ForEach(@ResetDebuggerRow);
  459. end;
  460. procedure TDebugController.Reset;
  461. begin
  462. inherited Reset;
  463. NoSwitch:=false;
  464. IDEApp.SetCmdState([cmResetDebugger,cmUntilReturn],false);
  465. ResetDebuggerRows;
  466. end;
  467. procedure TDebugController.AnnotateError;
  468. var errornb : longint;
  469. begin
  470. if error then
  471. begin
  472. errornb:=error_num;
  473. ReadWatches;
  474. If assigned(StackWindow) then
  475. StackWindow^.Update;
  476. ErrorBox(#3'Error within GDB'#13#3'Error code = %d',@errornb);
  477. end;
  478. end;
  479. procedure TDebugController.DoSelectSourceLine(const fn:string;line:longint);
  480. var
  481. W: PSourceWindow;
  482. Found : boolean;
  483. PB : PBreakpoint;
  484. S : String;
  485. BreakIndex : longint;
  486. begin
  487. BreakIndex:=stop_breakpoint_number;
  488. Desktop^.Lock;
  489. { 0 based line count in Editor }
  490. if Line>0 then
  491. dec(Line);
  492. if (fn=LastFileName) then
  493. begin
  494. W:=PSourceWindow(LastSource);
  495. if assigned(W) then
  496. begin
  497. W^.Editor^.SetCurPtr(0,Line);
  498. W^.Editor^.TrackCursor(true);
  499. W^.Editor^.SetDebuggerRow(Line);
  500. ReadWatches;
  501. If assigned(StackWindow) then
  502. StackWindow^.Update;
  503. if Not assigned(GDBWindow) or not GDBWindow^.GetState(sfActive) then
  504. W^.Select;
  505. InvalidSourceLine:=false;
  506. end
  507. else
  508. InvalidSourceLine:=true;
  509. end
  510. else
  511. begin
  512. W:=TryToOpenFile(nil,fn,0,Line,false);
  513. if assigned(W) then
  514. begin
  515. W^.Editor^.SetDebuggerRow(Line);
  516. W^.Editor^.TrackCursor(true);
  517. If assigned(StackWindow) then
  518. StackWindow^.Update;
  519. ReadWatches;
  520. if Not assigned(GDBWindow) or not GDBWindow^.GetState(sfActive) then
  521. W^.Select;
  522. LastSource:=W;
  523. InvalidSourceLine:=false;
  524. end
  525. { only search a file once }
  526. else
  527. begin
  528. Desktop^.UnLock;
  529. Found:=IDEApp.OpenSearch(fn);
  530. Desktop^.Lock;
  531. if not Found then
  532. begin
  533. InvalidSourceLine:=true;
  534. LastSource:=Nil;
  535. end
  536. else
  537. begin
  538. { should now be open }
  539. W:=TryToOpenFile(nil,fn,0,Line,true);
  540. W^.Editor^.SetDebuggerRow(Line);
  541. W^.Editor^.TrackCursor(true);
  542. ReadWatches;
  543. If assigned(StackWindow) then
  544. StackWindow^.Update;
  545. if Not assigned(GDBWindow) or not GDBWindow^.GetState(sfActive) then
  546. W^.Select;
  547. LastSource:=W;
  548. InvalidSourceLine:=false;
  549. end;
  550. end;
  551. end;
  552. LastFileName:=fn;
  553. Desktop^.UnLock;
  554. if BreakIndex>0 then
  555. begin
  556. PB:=BreakpointsCollection^.GetGDB(BreakIndex);
  557. { For watch we should get old and new value !! }
  558. if (Not assigned(GDBWindow) or not GDBWindow^.GetState(sfActive)) and
  559. (PB^.typ<>bt_file_line) and (PB^.typ<>bt_function) then
  560. begin
  561. Command('p '+GetStr(PB^.Name));
  562. S:=GetPChar(GetOutput);
  563. got_error:=false;
  564. If Pos('=',S)>0 then
  565. S:=Copy(S,Pos('=',S)+1,255);
  566. If S[Length(S)]=#10 then
  567. Delete(S,Length(S),1);
  568. if Assigned(PB^.OldValue) then
  569. DisposeStr(PB^.OldValue);
  570. PB^.OldValue:=PB^.CurrentValue;
  571. PB^.CurrentValue:=NewStr(S);
  572. If PB^.typ=bt_function then
  573. WarningBox(#3'GDB stopped due to'#13+
  574. #3+BreakpointTypeStr[PB^.typ]+' '+GetStr(PB^.Name),nil)
  575. else if (GetStr(PB^.OldValue)<>S) then
  576. WarningBox(#3'GDB stopped due to'#13+
  577. #3+BreakpointTypeStr[PB^.typ]+' '+GetStr(PB^.Name)+#13+
  578. #3+'Old value = '+GetStr(PB^.OldValue)+#13+
  579. #3+'New value = '+GetStr(PB^.CurrentValue),nil)
  580. else
  581. WarningBox(#3'GDB stopped due to'#13+
  582. #3+BreakpointTypeStr[PB^.typ]+' '+GetStr(PB^.Name)+#13+
  583. #3+' value = '+GetStr(PB^.CurrentValue),nil);
  584. end;
  585. end;
  586. end;
  587. procedure TDebugController.DoEndSession(code:longint);
  588. var P :Array[1..2] of longint;
  589. W : PSourceWindow;
  590. begin
  591. IDEApp.SetCmdState([cmResetDebugger],false);
  592. ResetDebuggerRows;
  593. LastExitCode:=Code;
  594. If HiddenStepsCount=0 then
  595. InformationBox(#3'Program exited with '#13#3'exitcode = %d',@code)
  596. else
  597. begin
  598. P[1]:=code;
  599. P[2]:=HiddenStepsCount;
  600. WarningBox(#3'Program exited with '#13+
  601. #3'exitcode = %d'#13+
  602. #3'hidden steps = %d',@P);
  603. end;
  604. end;
  605. procedure TDebugController.DoDebuggerScreen;
  606. begin
  607. if NoSwitch then
  608. PopStatus
  609. else
  610. IDEApp.ShowIDEScreen;
  611. end;
  612. procedure TDebugController.DoUserScreen;
  613. begin
  614. if NoSwitch then
  615. PushStatus('Executable running in another window..')
  616. else
  617. IDEApp.ShowUserScreen;
  618. end;
  619. {****************************************************************************
  620. TBreakpoint
  621. ****************************************************************************}
  622. constructor TBreakpoint.Init_function(Const AFunc : String);
  623. begin
  624. typ:=bt_function;
  625. state:=bs_enabled;
  626. GDBState:=bs_deleted;
  627. Name:=NewStr(AFunc);
  628. FileName:=nil;
  629. Line:=0;
  630. IgnoreCount:=0;
  631. Commands:=nil;
  632. Conditions:=nil;
  633. OldValue:=nil;
  634. CurrentValue:=nil;
  635. end;
  636. constructor TBreakpoint.Init_Empty;
  637. begin
  638. typ:=bt_function;
  639. state:=bs_enabled;
  640. GDBState:=bs_deleted;
  641. Name:=Nil;
  642. FileName:=nil;
  643. Line:=0;
  644. IgnoreCount:=0;
  645. Commands:=nil;
  646. Conditions:=nil;
  647. OldValue:=nil;
  648. CurrentValue:=nil;
  649. end;
  650. constructor TBreakpoint.Init_type(atyp : BreakpointType;Const AnExpr : String);
  651. begin
  652. typ:=atyp;
  653. state:=bs_enabled;
  654. GDBState:=bs_deleted;
  655. Name:=NewStr(AnExpr);
  656. IgnoreCount:=0;
  657. Commands:=nil;
  658. Conditions:=nil;
  659. OldValue:=nil;
  660. CurrentValue:=nil;
  661. end;
  662. constructor TBreakpoint.Init_file_line(AFile : String; ALine : longint);
  663. begin
  664. typ:=bt_file_line;
  665. state:=bs_enabled;
  666. GDBState:=bs_deleted;
  667. { d:test.pas:12 does not work !! }
  668. { I do not know how to solve this if
  669. if (Length(AFile)>1) and (AFile[2]=':') then
  670. AFile:=Copy(AFile,3,255);
  671. Only use base name for now !! PM }
  672. FileName:=NewStr(AFile);
  673. Name:=nil;
  674. Line:=ALine;
  675. IgnoreCount:=0;
  676. Commands:=nil;
  677. Conditions:=nil;
  678. OldValue:=nil;
  679. CurrentValue:=nil;
  680. end;
  681. constructor TBreakpoint.Load(var S: TStream);
  682. begin
  683. S.Read(typ,SizeOf(BreakpointType));
  684. S.Read(state,SizeOf(BreakpointState));
  685. GDBState:=bs_deleted;
  686. case typ of
  687. bt_file_line :
  688. begin
  689. FileName:=S.ReadStr;
  690. S.Read(Line,SizeOf(Line));
  691. Name:=nil;
  692. end;
  693. else
  694. begin
  695. Name:=S.ReadStr;
  696. Line:=0;
  697. FileName:=nil;
  698. end;
  699. end;
  700. S.Read(IgnoreCount,SizeOf(IgnoreCount));
  701. Commands:=S.StrRead;
  702. Conditions:=S.ReadStr;
  703. OldValue:=nil;
  704. CurrentValue:=nil;
  705. end;
  706. procedure TBreakpoint.Store(var S: TStream);
  707. begin
  708. S.Write(typ,SizeOf(BreakpointType));
  709. S.Write(state,SizeOf(BreakpointState));
  710. case typ of
  711. bt_file_line :
  712. begin
  713. S.WriteStr(FileName);
  714. S.Write(Line,SizeOf(Line));
  715. end;
  716. else
  717. begin
  718. S.WriteStr(Name);
  719. end;
  720. end;
  721. S.Write(IgnoreCount,SizeOf(IgnoreCount));
  722. S.StrWrite(Commands);
  723. S.WriteStr(Conditions);
  724. end;
  725. procedure TBreakpoint.Insert;
  726. begin
  727. If not assigned(Debugger) then Exit;
  728. Remove;
  729. Debugger^.last_breakpoint_number:=0;
  730. if (GDBState=bs_deleted) and (state=bs_enabled) then
  731. begin
  732. if (typ=bt_file_line) and assigned(FileName) then
  733. Debugger^.Command('break '+NameAndExtOf(FileName^)+':'+IntToStr(Line))
  734. else if (typ=bt_function) and assigned(name) then
  735. Debugger^.Command('break '+name^)
  736. else if (typ=bt_watch) and assigned(name) then
  737. Debugger^.Command('watch '+name^)
  738. else if (typ=bt_awatch) and assigned(name) then
  739. Debugger^.Command('awatch '+name^)
  740. else if (typ=bt_rwatch) and assigned(name) then
  741. Debugger^.Command('rwatch '+name^);
  742. if Debugger^.last_breakpoint_number<>0 then
  743. begin
  744. GDBIndex:=Debugger^.last_breakpoint_number;
  745. GDBState:=bs_enabled;
  746. Debugger^.Command('cond '+IntToStr(GDBIndex)+' '+GetStr(Conditions));
  747. If IgnoreCount>0 then
  748. Debugger^.Command('ignore '+IntToStr(GDBIndex)+' '+IntToStr(IgnoreCount));
  749. If Assigned(Commands) then
  750. begin
  751. {Commands are not handled yet }
  752. end;
  753. end
  754. else
  755. { Here there was a problem !! }
  756. begin
  757. GDBIndex:=0;
  758. ErrorBox(#3'Could not set Breakpoint'#13+
  759. #3+BreakpointTypeStr[typ]+' '+GetStr(Name),nil);
  760. state:=bs_disabled;
  761. end;
  762. end
  763. else if (GDBState=bs_disabled) and (state=bs_enabled) then
  764. Enable
  765. else if (GDBState=bs_enabled) and (state=bs_disabled) then
  766. Disable;
  767. end;
  768. procedure TBreakpoint.Remove;
  769. begin
  770. If not assigned(Debugger) then Exit;
  771. if GDBIndex>0 then
  772. Debugger^.Command('delete '+IntToStr(GDBIndex));
  773. GDBIndex:=0;
  774. GDBState:=bs_deleted;
  775. end;
  776. procedure TBreakpoint.Enable;
  777. begin
  778. If not assigned(Debugger) then Exit;
  779. if GDBIndex>0 then
  780. Debugger^.Command('enable '+IntToStr(GDBIndex))
  781. else
  782. Insert;
  783. GDBState:=bs_enabled;
  784. end;
  785. procedure TBreakpoint.Disable;
  786. begin
  787. If not assigned(Debugger) then Exit;
  788. if GDBIndex>0 then
  789. Debugger^.Command('disable '+IntToStr(GDBIndex));
  790. GDBState:=bs_disabled;
  791. end;
  792. procedure TBreakpoint.ResetValues;
  793. begin
  794. if assigned(OldValue) then
  795. DisposeStr(OldValue);
  796. OldValue:=nil;
  797. if assigned(CurrentValue) then
  798. DisposeStr(CurrentValue);
  799. CurrentValue:=nil;
  800. end;
  801. destructor TBreakpoint.Done;
  802. begin
  803. Remove;
  804. ResetValues;
  805. if assigned(Name) then
  806. DisposeStr(Name);
  807. if assigned(FileName) then
  808. DisposeStr(FileName);
  809. if assigned(Conditions) then
  810. DisposeStr(Conditions);
  811. if assigned(Commands) then
  812. StrDispose(Commands);
  813. inherited Done;
  814. end;
  815. {****************************************************************************
  816. TBreakpointCollection
  817. ****************************************************************************}
  818. function TBreakpointCollection.At(Index: Integer): PBreakpoint;
  819. begin
  820. At:=inherited At(Index);
  821. end;
  822. procedure TBreakpointCollection.Update;
  823. begin
  824. if assigned(Debugger) then
  825. begin
  826. Debugger^.RemoveBreakpoints;
  827. Debugger^.InsertBreakpoints;
  828. end;
  829. if assigned(BreakpointsWindow) then
  830. BreakpointsWindow^.Update;
  831. end;
  832. function TBreakpointCollection.GetGDB(index : longint) : PBreakpoint;
  833. function IsNum(P : PBreakpoint) : boolean;{$ifndef FPC}far;{$endif}
  834. begin
  835. IsNum:=P^.GDBIndex=index;
  836. end;
  837. begin
  838. if index=0 then
  839. GetGDB:=nil
  840. else
  841. GetGDB:=FirstThat(@IsNum);
  842. end;
  843. procedure TBreakpointCollection.ShowBreakpoints(W : PSourceWindow);
  844. procedure SetInSource(P : PBreakpoint);{$ifndef FPC}far;{$endif}
  845. begin
  846. If assigned(P^.FileName) and (P^.FileName^=W^.Editor^.FileName) then
  847. W^.Editor^.SetLineBreakState(P^.Line,P^.state=bs_enabled);
  848. end;
  849. begin
  850. ForEach(@SetInSource);
  851. end;
  852. function TBreakpointCollection.GetType(typ : BreakpointType;Const s : String) : PBreakpoint;
  853. function IsThis(P : PBreakpoint) : boolean;{$ifndef FPC}far;{$endif}
  854. begin
  855. IsThis:=(P^.typ=typ) and (GetStr(P^.Name)=S);
  856. end;
  857. begin
  858. GetType:=FirstThat(@IsThis);
  859. end;
  860. function TBreakpointCollection.ToggleFileLine(Const FileName: String;LineNr : Longint) : boolean;
  861. var PB : PBreakpoint;
  862. function IsThere(P : PBreakpoint) : boolean;{$ifndef FPC}far;{$endif}
  863. begin
  864. IsThere:=(P^.typ=bt_file_line) and (P^.FileName^=FileName) and (P^.Line=LineNr);
  865. end;
  866. begin
  867. PB:=FirstThat(@IsThere);
  868. ToggleFileLine:=false;
  869. If Assigned(PB) then
  870. if PB^.state=bs_disabled then
  871. begin
  872. PB^.state:=bs_enabled;
  873. ToggleFileLine:=true;
  874. end
  875. else if PB^.state=bs_enabled then
  876. PB^.state:=bs_disabled;
  877. If not assigned(PB) then
  878. begin
  879. PB:= New(PBreakpoint,Init_file_line(FileName,LineNr));
  880. if assigned(PB) then
  881. Begin
  882. Insert(PB);
  883. ToggleFileLine:=true;
  884. End;
  885. end;
  886. Update;
  887. end;
  888. {****************************************************************************
  889. TBreakpointItem
  890. ****************************************************************************}
  891. constructor TBreakpointItem.Init(ABreakpoint : PBreakpoint);
  892. begin
  893. inherited Init;
  894. Breakpoint:=ABreakpoint;
  895. end;
  896. function TBreakpointItem.GetText(MaxLen: Sw_integer): string;
  897. var S: string;
  898. begin
  899. with Breakpoint^ do
  900. begin
  901. S:=BreakpointTypeStr[typ];
  902. While Length(S)<10 do
  903. S:=S+' ';
  904. S:=S+'|';
  905. S:=S+BreakpointStateStr[state]+' ';
  906. While Length(S)<20 do
  907. S:=S+' ';
  908. S:=S+'|';
  909. if (typ=bt_file_line) then
  910. S:=S+NameAndExtOf(GetStr(FileName))+':'+IntToStr(Line)
  911. else
  912. S:=S+GetStr(name);
  913. While Length(S)<40 do
  914. S:=S+' ';
  915. S:=S+'|';
  916. if IgnoreCount>0 then
  917. S:=S+IntToStr(IgnoreCount);
  918. While Length(S)<49 do
  919. S:=S+' ';
  920. S:=S+'|';
  921. if assigned(Conditions) then
  922. S:=S+' '+GetStr(Conditions);
  923. if length(S)>MaxLen then S:=copy(S,1,MaxLen-2)+'..';
  924. GetText:=S;
  925. end;
  926. end;
  927. procedure TBreakpointItem.Selected;
  928. begin
  929. end;
  930. function TBreakpointItem.GetModuleName: string;
  931. begin
  932. if breakpoint^.typ=bt_file_line then
  933. GetModuleName:=GetStr(breakpoint^.FileName)
  934. else
  935. GetModuleName:='';
  936. end;
  937. {****************************************************************************
  938. TBreakpointsListBox
  939. ****************************************************************************}
  940. constructor TBreakpointsListBox.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  941. begin
  942. inherited Init(Bounds,1,AHScrollBar, AVScrollBar);
  943. GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY;
  944. NoSelection:=true;
  945. end;
  946. function TBreakpointsListBox.GetLocalMenu: PMenu;
  947. var M: PMenu;
  948. begin
  949. if (Owner<>nil) and (Owner^.GetState(sfModal)) then M:=nil else
  950. M:=NewMenu(
  951. NewItem('~G~oto source','',kbNoKey,cmMsgGotoSource,hcMsgGotoSource,
  952. NewItem('~E~dit breakpoint','',kbNoKey,cmEditBreakpoint,hcEditBreakpoint,
  953. NewItem('~N~ew breakpoint','',kbNoKey,cmNewBreakpoint,hcNewBreakpoint,
  954. NewItem('~D~elete breakpoint','',kbNoKey,cmDeleteBreakpoint,hcDeleteBreakpoint,
  955. NewItem('~T~oggle state','',kbNoKey,cmToggleBreakpoint,hcToggleBreakpoint,
  956. nil))))));
  957. GetLocalMenu:=M;
  958. end;
  959. procedure TBreakpointsListBox.HandleEvent(var Event: TEvent);
  960. var DontClear: boolean;
  961. begin
  962. case Event.What of
  963. evKeyDown :
  964. begin
  965. DontClear:=false;
  966. case Event.KeyCode of
  967. kbEnter :
  968. Message(@Self,evCommand,cmMsgGotoSource,nil);
  969. else
  970. DontClear:=true;
  971. end;
  972. if not DontClear then
  973. ClearEvent(Event);
  974. end;
  975. evBroadcast :
  976. case Event.Command of
  977. cmListItemSelected :
  978. if Event.InfoPtr=@Self then
  979. Message(@Self,evCommand,cmEditBreakpoint,nil);
  980. end;
  981. evCommand :
  982. begin
  983. DontClear:=false;
  984. case Event.Command of
  985. cmMsgTrackSource :
  986. if Range>0 then
  987. TrackSource;
  988. cmEditBreakpoint :
  989. EditCurrent;
  990. cmToggleBreakpoint :
  991. ToggleCurrent;
  992. cmDeleteBreakpoint :
  993. DeleteCurrent;
  994. cmNewBreakpoint :
  995. EditNew;
  996. cmMsgClear :
  997. Clear;
  998. else
  999. DontClear:=true;
  1000. end;
  1001. if not DontClear then
  1002. ClearEvent(Event);
  1003. end;
  1004. end;
  1005. inherited HandleEvent(Event);
  1006. end;
  1007. procedure TBreakpointsListBox.AddBreakpoint(P: PBreakpointItem);
  1008. var W : integer;
  1009. begin
  1010. if List=nil then New(List, Init(20,20));
  1011. W:=length(P^.GetText(255));
  1012. if W>MaxWidth then
  1013. begin
  1014. MaxWidth:=W;
  1015. if HScrollBar<>nil then
  1016. HScrollBar^.SetRange(0,MaxWidth);
  1017. end;
  1018. List^.Insert(P);
  1019. SetRange(List^.Count);
  1020. if Focused=List^.Count-1-1 then
  1021. FocusItem(List^.Count-1);
  1022. DrawView;
  1023. end;
  1024. (* function TBreakpointsListBox.AddModuleName(const Name: string): PString;
  1025. var P: PString;
  1026. begin
  1027. if ModuleNames<>nil then
  1028. P:=ModuleNames^.Add(Name)
  1029. else
  1030. P:=nil;
  1031. AddModuleName:=P;
  1032. end; *)
  1033. function TBreakpointsListBox.GetText(Item,MaxLen: Sw_Integer): String;
  1034. var P: PBreakpointItem;
  1035. S: string;
  1036. begin
  1037. P:=List^.At(Item);
  1038. S:=P^.GetText(MaxLen);
  1039. GetText:=copy(S,1,MaxLen);
  1040. end;
  1041. procedure TBreakpointsListBox.Clear;
  1042. begin
  1043. if assigned(List) then
  1044. Dispose(List, Done);
  1045. List:=nil;
  1046. MaxWidth:=0;
  1047. (* if assigned(ModuleNames) then
  1048. ModuleNames^.FreeAll; *)
  1049. SetRange(0); DrawView;
  1050. Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  1051. end;
  1052. procedure TBreakpointsListBox.TrackSource;
  1053. var W: PSourceWindow;
  1054. P: PBreakpointItem;
  1055. R: TRect;
  1056. (* Row,Col: sw_integer; *)
  1057. begin
  1058. (*Message(Application,evBroadcast,cmClearLineHighlights,@Self);
  1059. if Range=0 then Exit;*)
  1060. P:=List^.At(Focused);
  1061. if P^.GetModuleName='' then Exit;
  1062. Desktop^.Lock;
  1063. GetNextEditorBounds(R);
  1064. R.B.Y:=Owner^.Origin.Y;
  1065. W:=EditorWindowFile(P^.GetModuleName);
  1066. if assigned(W) then
  1067. begin
  1068. W^.GetExtent(R);
  1069. R.B.Y:=Owner^.Origin.Y;
  1070. W^.ChangeBounds(R);
  1071. W^.Editor^.SetCurPtr(1,P^.Breakpoint^.Line);
  1072. end
  1073. else
  1074. W:=TryToOpenFile(@R,P^.GetModuleName,1,P^.Breakpoint^.Line,true);
  1075. if W<>nil then
  1076. begin
  1077. W^.Select;
  1078. W^.Editor^.TrackCursor(true);
  1079. W^.Editor^.SetHighlightRow(P^.Breakpoint^.Line);
  1080. end;
  1081. if Assigned(Owner) then
  1082. Owner^.Select;
  1083. Desktop^.UnLock;
  1084. end;
  1085. procedure TBreakpointsListBox.ToggleCurrent;
  1086. var W: PSourceWindow;
  1087. P: PBreakpointItem;
  1088. b : boolean;
  1089. (* Row,Col: sw_integer; *)
  1090. begin
  1091. if Range=0 then Exit;
  1092. P:=List^.At(Focused);
  1093. if P=nil then Exit;
  1094. if P^.Breakpoint^.state=bs_enabled then
  1095. P^.Breakpoint^.state:=bs_disabled
  1096. else if P^.Breakpoint^.state=bs_disabled then
  1097. P^.Breakpoint^.state:=bs_enabled;
  1098. BreakpointsCollection^.Update;
  1099. if P^.Breakpoint^.typ=bt_file_line then
  1100. begin
  1101. W:=TryToOpenFile(nil,GetStr(P^.Breakpoint^.FileName),1,P^.Breakpoint^.Line,false);
  1102. If assigned(W) then
  1103. begin
  1104. if P^.Breakpoint^.state=bs_enabled then
  1105. b:=true
  1106. else
  1107. b:=false;
  1108. W^.Editor^.SetLineBreakState(P^.Breakpoint^.Line,b);
  1109. end;
  1110. end;
  1111. end;
  1112. procedure TBreakpointsListBox.EditCurrent;
  1113. var
  1114. P: PBreakpointItem;
  1115. begin
  1116. if Range=0 then Exit;
  1117. P:=List^.At(Focused);
  1118. if P=nil then Exit;
  1119. Application^.ExecuteDialog(New(PBreakpointItemDialog,Init(P^.Breakpoint)),nil);
  1120. BreakpointsCollection^.Update;
  1121. end;
  1122. procedure TBreakpointsListBox.DeleteCurrent;
  1123. var
  1124. P: PBreakpointItem;
  1125. begin
  1126. if Range=0 then Exit;
  1127. P:=List^.At(Focused);
  1128. if P=nil then Exit;
  1129. BreakpointsCollection^.free(P^.Breakpoint);
  1130. List^.free(P);
  1131. BreakpointsCollection^.Update;
  1132. end;
  1133. procedure TBreakpointsListBox.EditNew;
  1134. var
  1135. P: PBreakpoint;
  1136. begin
  1137. P:=New(PBreakpoint,Init_Empty);
  1138. if Application^.ExecuteDialog(New(PBreakpointItemDialog,Init(P)),nil)<>cmCancel then
  1139. begin
  1140. BreakpointsCollection^.Insert(P);
  1141. BreakpointsCollection^.Update;
  1142. end
  1143. else
  1144. dispose(P,Done);
  1145. end;
  1146. procedure TBreakpointsListBox.Draw;
  1147. var
  1148. I, J, Item: Sw_Integer;
  1149. NormalColor, SelectedColor, FocusedColor, Color: Word;
  1150. ColWidth, CurCol, Indent: Integer;
  1151. B: TDrawBuffer;
  1152. Text: String;
  1153. SCOff: Byte;
  1154. TC: byte;
  1155. procedure MT(var C: word); begin if TC<>0 then C:=(C and $ff0f) or (TC and $f0); end;
  1156. begin
  1157. if (Owner<>nil) then TC:=ord(Owner^.GetColor(6)) else TC:=0;
  1158. if State and (sfSelected + sfActive) = (sfSelected + sfActive) then
  1159. begin
  1160. NormalColor := GetColor(1);
  1161. FocusedColor := GetColor(3);
  1162. SelectedColor := GetColor(4);
  1163. end else
  1164. begin
  1165. NormalColor := GetColor(2);
  1166. SelectedColor := GetColor(4);
  1167. end;
  1168. if Transparent then
  1169. begin MT(NormalColor); MT(SelectedColor); end;
  1170. if NoSelection then
  1171. SelectedColor:=NormalColor;
  1172. if HScrollBar <> nil then Indent := HScrollBar^.Value
  1173. else Indent := 0;
  1174. ColWidth := Size.X div NumCols + 1;
  1175. for I := 0 to Size.Y - 1 do
  1176. begin
  1177. for J := 0 to NumCols-1 do
  1178. begin
  1179. Item := J*Size.Y + I + TopItem;
  1180. CurCol := J*ColWidth;
  1181. if (State and (sfSelected + sfActive) = (sfSelected + sfActive)) and
  1182. (Focused = Item) and (Range > 0) then
  1183. begin
  1184. Color := FocusedColor;
  1185. SetCursor(CurCol+1,I);
  1186. SCOff := 0;
  1187. end
  1188. else if (Item < Range) and IsSelected(Item) then
  1189. begin
  1190. Color := SelectedColor;
  1191. SCOff := 2;
  1192. end
  1193. else
  1194. begin
  1195. Color := NormalColor;
  1196. SCOff := 4;
  1197. end;
  1198. MoveChar(B[CurCol], ' ', Color, ColWidth);
  1199. if Item < Range then
  1200. begin
  1201. Text := GetText(Item, ColWidth + Indent);
  1202. Text := Copy(Text,Indent,ColWidth);
  1203. MoveStr(B[CurCol+1], Text, Color);
  1204. if ShowMarkers then
  1205. begin
  1206. WordRec(B[CurCol]).Lo := Byte(SpecialChars[SCOff]);
  1207. WordRec(B[CurCol+ColWidth-2]).Lo := Byte(SpecialChars[SCOff+1]);
  1208. end;
  1209. end;
  1210. MoveChar(B[CurCol+ColWidth-1], #179, GetColor(5), 1);
  1211. end;
  1212. WriteLine(0, I, Size.X, 1, B);
  1213. end;
  1214. end;
  1215. constructor TBreakpointsListBox.Load(var S: TStream);
  1216. begin
  1217. inherited Load(S);
  1218. end;
  1219. procedure TBreakpointsListBox.Store(var S: TStream);
  1220. var OL: PCollection;
  1221. OldR : integer;
  1222. begin
  1223. OL:=List;
  1224. OldR:=Range;
  1225. Range:=0;
  1226. New(List, Init(1,1));
  1227. inherited Store(S);
  1228. Dispose(List, Done);
  1229. Range:=OldR;
  1230. List:=OL;
  1231. { ^^^ nasty trick - has anyone a better idea how to avoid storing the
  1232. collection? Pasting here a modified version of TListBox.Store+
  1233. TAdvancedListBox.Store isn't a better solution, since by eventually
  1234. changing the obj-hierarchy you'll always have to modify this, too - BG }
  1235. end;
  1236. destructor TBreakpointsListBox.Done;
  1237. begin
  1238. inherited Done;
  1239. if List<>nil then Dispose(List, Done);
  1240. (* if ModuleNames<>nil then Dispose(ModuleNames, Done);*)
  1241. end;
  1242. {****************************************************************************
  1243. TBreakpointsWindow
  1244. ****************************************************************************}
  1245. constructor TBreakpointsWindow.Init;
  1246. var R,R2: TRect;
  1247. HSB,VSB: PScrollBar;
  1248. ST: PStaticText;
  1249. S: String;
  1250. X,X1 : Sw_integer;
  1251. const White = 15;
  1252. begin
  1253. Desktop^.GetExtent(R); R.A.Y:=R.B.Y-18;
  1254. inherited Init(R, 'Breakpoint list', wnNoNumber);
  1255. HelpCtx:=hcBreakpointListWindow;
  1256. GetExtent(R); R.Grow(-1,-1); R.B.Y:=R.A.Y+1;
  1257. S:=' Type | State | Position | Ignore | Conditions ';
  1258. New(ST, Init(R,S));
  1259. ST^.GrowMode:=gfGrowHiX;
  1260. Insert(ST);
  1261. GetExtent(R); R.Grow(-1,-1); Inc(R.A.Y,1); R.B.Y:=R.A.Y+1;
  1262. New(ST, Init(R, CharStr('Ä', MaxViewWidth)));
  1263. ST^.GrowMode:=gfGrowHiX;
  1264. Insert(ST);
  1265. GetExtent(R); R.Grow(-1,-1); Inc(R.A.Y,2);Dec(R.B.Y,5);
  1266. R2.Copy(R); Inc(R2.B.Y); R2.A.Y:=R2.B.Y-1;
  1267. New(HSB, Init(R2)); HSB^.GrowMode:=gfGrowLoY+gfGrowHiY+gfGrowHiX; Insert(HSB);
  1268. R2.Copy(R); Inc(R2.B.X); R2.A.X:=R2.B.X-1;
  1269. New(VSB, Init(R2)); VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY; Insert(VSB);
  1270. New(BreakLB, Init(R,HSB,VSB));
  1271. BreakLB^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1272. BreakLB^.Transparent:=true;
  1273. Insert(BreakLB);
  1274. GetExtent(R);R.Grow(-1,-1);
  1275. Dec(R.B.Y);
  1276. R.A.Y:=R.B.Y-2;
  1277. X:=(R.B.X-R.A.X) div 4;
  1278. X1:=R.A.X+(X div 2);
  1279. R.A.X:=X1-3;R.B.X:=X1+7;
  1280. Insert(New(PButton, Init(R, '~C~lose', cmClose, bfDefault)));
  1281. X1:=X1+X;
  1282. R.A.X:=X1-3;R.B.X:=X1+7;
  1283. Insert(New(PButton, Init(R, '~N~ew', cmNewBreakpoint, bfNormal)));
  1284. X1:=X1+X;
  1285. R.A.X:=X1-3;R.B.X:=X1+7;
  1286. Insert(New(PButton, Init(R, '~E~dit', cmEditBreakpoint, bfNormal)));
  1287. X1:=X1+X;
  1288. R.A.X:=X1-3;R.B.X:=X1+7;
  1289. Insert(New(PButton, Init(R, '~D~elete', cmDeleteBreakpoint, bfNormal)));
  1290. BreakLB^.Select;
  1291. Update;
  1292. BreakpointsWindow:=@self;
  1293. end;
  1294. constructor TBreakpointsWindow.Load(var S: TStream);
  1295. begin
  1296. inherited Load(S);
  1297. GetSubViewPtr(S,BreakLB);
  1298. end;
  1299. procedure TBreakpointsWindow.Store(var S: TStream);
  1300. begin
  1301. inherited Store(S);
  1302. PutSubViewPtr(S,BreakLB);
  1303. end;
  1304. procedure TBreakpointsWindow.AddBreakpoint(ABreakpoint : PBreakpoint);
  1305. begin
  1306. BreakLB^.AddBreakpoint(New(PBreakpointItem, Init(ABreakpoint)));
  1307. end;
  1308. procedure TBreakpointsWindow.ClearBreakpoints;
  1309. begin
  1310. BreakLB^.Clear;
  1311. ReDraw;
  1312. end;
  1313. procedure TBreakpointsWindow.ReloadBreakpoints;
  1314. procedure InsertInBreakLB(P : PBreakpoint);
  1315. begin
  1316. BreakLB^.AddBreakpoint(New(PBreakpointItem, Init(P)));
  1317. end;
  1318. begin
  1319. If not assigned(BreakpointsCollection) then
  1320. exit;
  1321. BreakpointsCollection^.ForEach(@InsertInBreakLB);
  1322. ReDraw;
  1323. end;
  1324. procedure TBreakpointsWindow.SizeLimits(var Min, Max: TPoint);
  1325. begin
  1326. inherited SizeLimits(Min,Max);
  1327. Min.X:=40; Min.Y:=18;
  1328. end;
  1329. procedure TBreakpointsWindow.Close;
  1330. begin
  1331. Hide;
  1332. end;
  1333. procedure TBreakpointsWindow.HandleEvent(var Event: TEvent);
  1334. var DontClear : boolean;
  1335. begin
  1336. case Event.What of
  1337. evKeyDown :
  1338. begin
  1339. if (Event.KeyCode=kbEnter) or (Event.KeyCode=kbEsc) then
  1340. begin
  1341. ClearEvent(Event);
  1342. Hide;
  1343. end;
  1344. end;
  1345. evCommand :
  1346. begin
  1347. DontClear:=False;
  1348. case Event.Command of
  1349. cmNewBreakpoint :
  1350. BreakLB^.EditNew;
  1351. cmEditBreakpoint :
  1352. BreakLB^.EditCurrent;
  1353. cmDeleteBreakpoint :
  1354. BreakLB^.DeleteCurrent;
  1355. cmClose :
  1356. Hide;
  1357. else
  1358. DontClear:=true;
  1359. end;
  1360. if not DontClear then
  1361. ClearEvent(Event);
  1362. end;
  1363. evBroadcast :
  1364. case Event.Command of
  1365. cmUpdate :
  1366. Update;
  1367. end;
  1368. end;
  1369. inherited HandleEvent(Event);
  1370. end;
  1371. procedure TBreakpointsWindow.Update;
  1372. begin
  1373. ClearBreakpoints;
  1374. ReloadBreakpoints;
  1375. end;
  1376. destructor TBreakpointsWindow.Done;
  1377. begin
  1378. inherited Done;
  1379. BreakpointsWindow:=nil;
  1380. end;
  1381. {****************************************************************************
  1382. TBreakpointItemDialog
  1383. ****************************************************************************}
  1384. constructor TBreakpointItemDialog.Init(ABreakpoint: PBreakpoint);
  1385. var R,R2,R3: TRect;
  1386. Items: PSItem;
  1387. I : BreakpointType;
  1388. KeyCount: sw_integer;
  1389. begin
  1390. KeyCount:=longint(high(BreakpointType));
  1391. R.Assign(0,0,60,Max(3+KeyCount,18));
  1392. inherited Init(R,'Modify/New Breakpoint');
  1393. Breakpoint:=ABreakpoint;
  1394. GetExtent(R); R.Grow(-3,-2); R3.Copy(R);
  1395. Inc(R.A.Y); R.B.Y:=R.A.Y+1; R.B.X:=R.A.X+36;
  1396. New(NameIL, Init(R, 128)); Insert(NameIL);
  1397. R2.Copy(R); R2.Move(-1,-1); Insert(New(PLabel, Init(R2, '~N~ame', NameIL)));
  1398. R.Move(0,3);
  1399. New(LineIL, Init(R, 128)); Insert(LineIL);
  1400. LineIL^.SetValidator(New(PRangeValidator, Init(0,MaxInt)));
  1401. R2.Copy(R); R2.Move(-1,-1); Insert(New(PLabel, Init(R2, '~L~ine', LineIL)));
  1402. R.Move(0,3);
  1403. New(ConditionsIL, Init(R, 128)); Insert(ConditionsIL);
  1404. R2.Copy(R); R2.Move(-1,-1); Insert(New(PLabel, Init(R2, 'Conditions', ConditionsIL)));
  1405. R.Move(0,3);
  1406. New(IgnoreIL, Init(R, 128)); Insert(IgnoreIL);
  1407. IgnoreIL^.SetValidator(New(PRangeValidator, Init(0,MaxInt)));
  1408. R2.Copy(R); R2.Move(-1,-1); Insert(New(PLabel, Init(R2, '~I~gnore count', IgnoreIL)));
  1409. R.Copy(R3); Inc(R.A.X,38); R.B.Y:=R.A.Y+KeyCount;
  1410. Items:=nil;
  1411. for I:=high(BreakpointType) downto low(BreakpointType) do
  1412. Items:=NewSItem(BreakpointTypeStr[I], Items);
  1413. New(TypeRB, Init(R, Items));
  1414. Insert(TypeRB);
  1415. InsertButtons(@Self);
  1416. NameIL^.Select;
  1417. end;
  1418. function TBreakpointItemDialog.Execute: Word;
  1419. var R: word;
  1420. S1: string;
  1421. err: word;
  1422. L: longint;
  1423. begin
  1424. R:=longint(Breakpoint^.typ);
  1425. TypeRB^.SetData(R);
  1426. If Breakpoint^.typ=bt_file_line then
  1427. S1:=GetStr(Breakpoint^.FileName)
  1428. else
  1429. S1:=GetStr(Breakpoint^.name);
  1430. NameIL^.SetData(S1);
  1431. If Breakpoint^.typ=bt_file_line then
  1432. S1:=IntToStr(Breakpoint^.Line)
  1433. else
  1434. S1:='0';
  1435. LineIL^.SetData(S1);
  1436. S1:=IntToStr(Breakpoint^.IgnoreCount);
  1437. IgnoreIL^.SetData(S1);
  1438. S1:=GetStr(Breakpoint^.Conditions);
  1439. ConditionsIL^.SetData(S1);
  1440. R:=inherited Execute;
  1441. if R=cmOK then
  1442. begin
  1443. TypeRB^.GetData(R);
  1444. L:=R;
  1445. Breakpoint^.typ:=BreakpointType(L);
  1446. NameIL^.GetData(S1);
  1447. If Breakpoint^.typ=bt_file_line then
  1448. begin
  1449. If assigned(Breakpoint^.FileName) then
  1450. DisposeStr(Breakpoint^.FileName);
  1451. Breakpoint^.FileName:=NewStr(S1);
  1452. end
  1453. else
  1454. begin
  1455. If assigned(Breakpoint^.Name) then
  1456. DisposeStr(Breakpoint^.Name);
  1457. Breakpoint^.name:=NewStr(S1);
  1458. end;
  1459. If Breakpoint^.typ=bt_file_line then
  1460. begin
  1461. LineIL^.GetData(S1);
  1462. Val(S1,L,err);
  1463. Breakpoint^.Line:=L;
  1464. end;
  1465. IgnoreIL^.GetData(S1);
  1466. Val(S1,L,err);
  1467. Breakpoint^.IgnoreCount:=L;
  1468. ConditionsIL^.GetData(S1);
  1469. If assigned(Breakpoint^.Conditions) then
  1470. DisposeStr(Breakpoint^.Conditions);
  1471. Breakpoint^.Conditions:=NewStr(S1);
  1472. end;
  1473. Execute:=R;
  1474. end;
  1475. {****************************************************************************
  1476. TWatch
  1477. ****************************************************************************}
  1478. constructor TWatch.Init(s : string);
  1479. begin
  1480. expr:=NewStr(s);
  1481. last_value:=nil;
  1482. current_value:=nil;
  1483. Get_new_value;
  1484. end;
  1485. constructor TWatch.Load(var S: TStream);
  1486. begin
  1487. expr:=S.ReadStr;
  1488. last_value:=nil;
  1489. current_value:=nil;
  1490. Get_new_value;
  1491. end;
  1492. procedure TWatch.Store(var S: TStream);
  1493. begin
  1494. S.WriteStr(expr);
  1495. end;
  1496. procedure TWatch.rename(s : string);
  1497. begin
  1498. if assigned(expr) then
  1499. begin
  1500. if GetStr(expr)=S then
  1501. exit;
  1502. DisposeStr(expr);
  1503. end;
  1504. expr:=NewStr(s);
  1505. if assigned(last_value) then
  1506. StrDispose(last_value);
  1507. last_value:=nil;
  1508. if assigned(current_value) then
  1509. StrDispose(current_value);
  1510. current_value:=nil;
  1511. Get_new_value;
  1512. end;
  1513. procedure TWatch.Get_new_value;
  1514. var p,q : pchar;
  1515. i : longint;
  1516. last_removed : boolean;
  1517. begin
  1518. If not assigned(Debugger) then
  1519. exit;
  1520. if assigned(last_value) then
  1521. strdispose(last_value);
  1522. last_value:=current_value;
  1523. Debugger^.Command('p '+GetStr(expr));
  1524. if Debugger^.Error then
  1525. p:=StrNew(Debugger^.GetError)
  1526. else
  1527. p:=StrNew(Debugger^.GetOutput);
  1528. { do not open a messagebox for such errors }
  1529. Debugger^.got_error:=false;
  1530. q:=nil;
  1531. if assigned(p) and (p[0]='$') then
  1532. q:=StrPos(p,'=');
  1533. if not assigned(q) then
  1534. q:=p;
  1535. if assigned(q) then
  1536. i:=strlen(q)
  1537. else
  1538. i:=0;
  1539. if (i>0) and (q[i-1]=#10) then
  1540. begin
  1541. q[i-1]:=#0;
  1542. last_removed:=true;
  1543. end
  1544. else
  1545. last_removed:=false;
  1546. if assigned(q) then
  1547. current_value:=strnew(q)
  1548. else
  1549. current_value:=strnew('');
  1550. if last_removed then
  1551. q[i-1]:=#10;
  1552. strdispose(p);
  1553. end;
  1554. destructor TWatch.Done;
  1555. begin
  1556. if assigned(expr) then
  1557. disposestr(expr);
  1558. if assigned(last_value) then
  1559. strdispose(last_value);
  1560. if assigned(current_value) then
  1561. strdispose(current_value);
  1562. inherited done;
  1563. end;
  1564. {****************************************************************************
  1565. TWatchesCollection
  1566. ****************************************************************************}
  1567. constructor TWatchesCollection.Init;
  1568. begin
  1569. inherited Init(10,10);
  1570. end;
  1571. procedure TWatchesCollection.Insert(Item: Pointer);
  1572. begin
  1573. PWatch(Item)^.Get_new_value;
  1574. Inherited Insert(Item);
  1575. Update;
  1576. end;
  1577. procedure TWatchesCollection.Update;
  1578. var
  1579. W,W1 : integer;
  1580. procedure GetMax(P : PWatch);
  1581. begin
  1582. if assigned(P^.Current_value) then
  1583. begin
  1584. W1:=StrLen(P^.Current_value)+2+Length(GetStr(P^.expr));
  1585. if W1>W then
  1586. W:=W1;
  1587. end;
  1588. end;
  1589. begin
  1590. W:=0;
  1591. ForEach(@GetMax);
  1592. MaxW:=W;
  1593. If assigned(WatchesWindow) then
  1594. WatchesWindow^.WLB^.Update(MaxW);
  1595. end;
  1596. function TWatchesCollection.At(Index: Integer): PWatch;
  1597. begin
  1598. At:=Inherited At(Index);
  1599. end;
  1600. {****************************************************************************
  1601. TWatchesListBox
  1602. ****************************************************************************}
  1603. constructor TWatchesListBox.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  1604. begin
  1605. inherited Init(Bounds,1,AHScrollBar,AVScrollBar);
  1606. If assigned(List) then
  1607. dispose(list,done);
  1608. List:=WatchesCollection;
  1609. end;
  1610. procedure TWatchesListBox.Update(AMaxWidth : integer);
  1611. var R : TRect;
  1612. begin
  1613. GetExtent(R);
  1614. MaxWidth:=AMaxWidth;
  1615. if HScrollBar<>nil then
  1616. HScrollBar^.SetRange(0,MaxWidth);
  1617. if R.B.X-R.A.X>MaxWidth then
  1618. HScrollBar^.Hide
  1619. else
  1620. HScrollBar^.Show;
  1621. SetRange(List^.Count);
  1622. if R.B.Y-R.A.Y>Range then
  1623. VScrollBar^.Hide
  1624. else
  1625. VScrollBar^.Show;
  1626. if Focused=List^.Count-1-1 then
  1627. FocusItem(List^.Count-1);
  1628. DrawView;
  1629. end;
  1630. function TWatchesListBox.GetIndentedText(Item,Indent,MaxLen: Sw_Integer): String;
  1631. var
  1632. PW : PWatch;
  1633. ValOffset : Sw_integer;
  1634. S : String;
  1635. begin
  1636. PW:=WatchesCollection^.At(Item);
  1637. ValOffset:=Length(GetStr(PW^.Expr))+2;
  1638. if Indent<ValOffset then
  1639. begin
  1640. if not assigned(PW^.current_value) then
  1641. S:=' '+GetStr(PW^.Expr)+' <Unknown value>'
  1642. else if not assigned(PW^.last_value) or
  1643. (strcomp(PW^.Last_value,PW^.Current_value)=0) then
  1644. S:=' '+GetStr(PW^.Expr)+' '+GetPChar(PW^.Current_value)
  1645. else
  1646. S:='!'+GetStr(PW^.Expr)+'!'+GetPchar(PW^.Current_value);
  1647. GetIndentedText:=Copy(S,Indent,MaxLen);
  1648. end
  1649. else
  1650. begin
  1651. if not assigned(PW^.Current_value) or
  1652. (StrLen(PW^.Current_value)<Indent-Valoffset) then
  1653. S:=''
  1654. else
  1655. S:=GetStr(@(PW^.Current_Value[Indent-Valoffset]));
  1656. GetIndentedText:=Copy(S,1,MaxLen);
  1657. end;
  1658. end;
  1659. procedure TWatchesListBox.EditCurrent;
  1660. var
  1661. P: PWatch;
  1662. begin
  1663. if Range=0 then Exit;
  1664. P:=WatchesCollection^.At(Focused);
  1665. if P=nil then Exit;
  1666. Application^.ExecuteDialog(New(PWatchItemDialog,Init(P)),nil);
  1667. WatchesCollection^.Update;
  1668. end;
  1669. procedure TWatchesListBox.DeleteCurrent;
  1670. var
  1671. P: PWatch;
  1672. begin
  1673. if Range=0 then Exit;
  1674. P:=WatchesCollection^.At(Focused);
  1675. if P=nil then Exit;
  1676. WatchesCollection^.free(P);
  1677. WatchesCollection^.Update;
  1678. end;
  1679. procedure TWatchesListBox.EditNew;
  1680. var
  1681. P: PWatch;
  1682. begin
  1683. P:=New(PWatch,Init(''));
  1684. if Application^.ExecuteDialog(New(PWatchItemDialog,Init(P)),nil)<>cmCancel then
  1685. begin
  1686. WatchesCollection^.Insert(P);
  1687. WatchesCollection^.Update;
  1688. end
  1689. else
  1690. dispose(P,Done);
  1691. end;
  1692. procedure TWatchesListBox.Draw;
  1693. var
  1694. I, J, Item: Sw_Integer;
  1695. NormalColor, SelectedColor, FocusedColor, Color: Word;
  1696. ColWidth, CurCol, Indent: Integer;
  1697. B: TDrawBuffer;
  1698. Text: String;
  1699. SCOff: Byte;
  1700. TC: byte;
  1701. procedure MT(var C: word); begin if TC<>0 then C:=(C and $ff0f) or (TC and $f0); end;
  1702. begin
  1703. if (Owner<>nil) then TC:=ord(Owner^.GetColor(6)) else TC:=0;
  1704. if State and (sfSelected + sfActive) = (sfSelected + sfActive) then
  1705. begin
  1706. NormalColor := GetColor(1);
  1707. FocusedColor := GetColor(3);
  1708. SelectedColor := GetColor(4);
  1709. end else
  1710. begin
  1711. NormalColor := GetColor(2);
  1712. SelectedColor := GetColor(4);
  1713. end;
  1714. if Transparent then
  1715. begin MT(NormalColor); MT(SelectedColor); end;
  1716. (* if NoSelection then
  1717. SelectedColor:=NormalColor;*)
  1718. if HScrollBar <> nil then Indent := HScrollBar^.Value
  1719. else Indent := 0;
  1720. ColWidth := Size.X div NumCols + 1;
  1721. for I := 0 to Size.Y - 1 do
  1722. begin
  1723. for J := 0 to NumCols-1 do
  1724. begin
  1725. Item := J*Size.Y + I + TopItem;
  1726. CurCol := J*ColWidth;
  1727. if (State and (sfSelected + sfActive) = (sfSelected + sfActive)) and
  1728. (Focused = Item) and (Range > 0) then
  1729. begin
  1730. Color := FocusedColor;
  1731. SetCursor(CurCol+1,I);
  1732. SCOff := 0;
  1733. end
  1734. else if (Item < Range) and IsSelected(Item) then
  1735. begin
  1736. Color := SelectedColor;
  1737. SCOff := 2;
  1738. end
  1739. else
  1740. begin
  1741. Color := NormalColor;
  1742. SCOff := 4;
  1743. end;
  1744. MoveChar(B[CurCol], ' ', Color, ColWidth);
  1745. if Item < Range then
  1746. begin
  1747. (* Text := GetText(Item, ColWidth + Indent);
  1748. Text := Copy(Text,Indent,ColWidth); *)
  1749. Text:=GetIndentedText(Item,Indent,ColWidth);
  1750. MoveStr(B[CurCol+1], Text, Color);
  1751. if ShowMarkers then
  1752. begin
  1753. WordRec(B[CurCol]).Lo := Byte(SpecialChars[SCOff]);
  1754. WordRec(B[CurCol+ColWidth-2]).Lo := Byte(SpecialChars[SCOff+1]);
  1755. end;
  1756. end;
  1757. MoveChar(B[CurCol+ColWidth-1], #179, GetColor(5), 1);
  1758. end;
  1759. WriteLine(0, I, Size.X, 1, B);
  1760. end;
  1761. end;
  1762. function TWatchesListBox.GetLocalMenu: PMenu;
  1763. var M: PMenu;
  1764. begin
  1765. if (Owner<>nil) and (Owner^.GetState(sfModal)) then M:=nil else
  1766. M:=NewMenu(
  1767. NewItem('~E~dit watch','',kbNoKey,cmEdit,hcNoContext,
  1768. NewItem('~N~ew watch','',kbNoKey,cmNew,hcNoContext,
  1769. NewItem('~D~elete watch','',kbNoKey,cmDelete,hcNoContext,
  1770. nil))));
  1771. GetLocalMenu:=M;
  1772. end;
  1773. procedure TWatchesListBox.HandleEvent(var Event: TEvent);
  1774. var DontClear: boolean;
  1775. begin
  1776. case Event.What of
  1777. evKeyDown :
  1778. begin
  1779. DontClear:=false;
  1780. case Event.KeyCode of
  1781. kbEnter :
  1782. Message(@Self,evCommand,cmEdit,nil);
  1783. kbIns :
  1784. Message(@Self,evCommand,cmNew,nil);
  1785. kbDel :
  1786. Message(@Self,evCommand,cmDelete,nil);
  1787. else
  1788. DontClear:=true;
  1789. end;
  1790. if not DontClear then
  1791. ClearEvent(Event);
  1792. end;
  1793. evBroadcast :
  1794. case Event.Command of
  1795. cmListItemSelected :
  1796. if Event.InfoPtr=@Self then
  1797. Message(@Self,evCommand,cmEdit,nil);
  1798. end;
  1799. evCommand :
  1800. begin
  1801. DontClear:=false;
  1802. case Event.Command of
  1803. cmEdit :
  1804. EditCurrent;
  1805. cmDelete :
  1806. DeleteCurrent;
  1807. cmNew :
  1808. EditNew;
  1809. else
  1810. DontClear:=true;
  1811. end;
  1812. if not DontClear then
  1813. ClearEvent(Event);
  1814. end;
  1815. end;
  1816. inherited HandleEvent(Event);
  1817. end;
  1818. constructor TWatchesListBox.Load(var S: TStream);
  1819. begin
  1820. inherited Load(S);
  1821. If assigned(List) then
  1822. dispose(list,done);
  1823. List:=WatchesCollection;
  1824. { we must set Range PM }
  1825. SetRange(List^.count);
  1826. end;
  1827. procedure TWatchesListBox.Store(var S: TStream);
  1828. var OL: PCollection;
  1829. OldRange : Sw_integer;
  1830. begin
  1831. OL:=List;
  1832. OldRange:=Range;
  1833. Range:=0;
  1834. New(List, Init(1,1));
  1835. inherited Store(S);
  1836. Dispose(List, Done);
  1837. List:=OL;
  1838. { ^^^ nasty trick - has anyone a better idea how to avoid storing the
  1839. collection? Pasting here a modified version of TListBox.Store+
  1840. TAdvancedListBox.Store isn't a better solution, since by eventually
  1841. changing the obj-hierarchy you'll always have to modify this, too - BG }
  1842. SetRange(OldRange);
  1843. end;
  1844. destructor TWatchesListBox.Done;
  1845. begin
  1846. List:=nil;
  1847. inherited Done;
  1848. end;
  1849. {****************************************************************************
  1850. TWatchesWindow
  1851. ****************************************************************************}
  1852. Constructor TWatchesWindow.Init;
  1853. var
  1854. HSB,VSB: PScrollBar;
  1855. R,R2 : trect;
  1856. begin
  1857. Desktop^.GetExtent(R);
  1858. R.A.Y:=R.B.Y-5;
  1859. inherited Init(R, 'Watches', wnNoNumber);
  1860. GetExtent(R);
  1861. HelpCtx:=hcWatches;
  1862. R.Grow(-1,-1);
  1863. R2.Copy(R);
  1864. Inc(R2.B.Y);
  1865. R2.A.Y:=R2.B.Y-1;
  1866. New(HSB, Init(R2));
  1867. HSB^.GrowMode:=gfGrowLoY+gfGrowHiY+gfGrowHiX;
  1868. Insert(HSB);
  1869. R2.Copy(R);
  1870. Inc(R2.B.X);
  1871. R2.A.X:=R2.B.X-1;
  1872. New(VSB, Init(R2));
  1873. VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY;
  1874. Insert(VSB);
  1875. New(WLB,Init(R,HSB,VSB));
  1876. WLB^.GrowMode:=gfGrowHiX+gfGrowHiY;
  1877. WLB^.Transparent:=true;
  1878. Insert(WLB);
  1879. If assigned(WatchesWindow) then
  1880. dispose(WatchesWindow,done);
  1881. WatchesWindow:=@Self;
  1882. Update;
  1883. end;
  1884. procedure TWatchesWindow.Update;
  1885. begin
  1886. WatchesCollection^.Update;
  1887. Draw;
  1888. end;
  1889. constructor TWatchesWindow.Load(var S: TStream);
  1890. begin
  1891. inherited Load(S);
  1892. GetSubViewPtr(S,WLB);
  1893. end;
  1894. procedure TWatchesWindow.Store(var S: TStream);
  1895. begin
  1896. inherited Store(S);
  1897. PutSubViewPtr(S,WLB);
  1898. end;
  1899. Destructor TWatchesWindow.Done;
  1900. begin
  1901. WatchesWindow:=nil;
  1902. Dispose(WLB,done);
  1903. inherited done;
  1904. end;
  1905. {****************************************************************************
  1906. TWatchItemDialog
  1907. ****************************************************************************}
  1908. constructor TWatchItemDialog.Init(AWatch: PWatch);
  1909. var R,R2: TRect;
  1910. begin
  1911. R.Assign(0,0,50,10);
  1912. inherited Init(R,'Edit Watch');
  1913. Watch:=AWatch;
  1914. GetExtent(R); R.Grow(-3,-2);
  1915. Inc(R.A.Y); R.B.Y:=R.A.Y+1; R.B.X:=R.A.X+36;
  1916. New(NameIL, Init(R, 255)); Insert(NameIL);
  1917. R2.Copy(R); R2.Move(-1,-1);
  1918. Insert(New(PLabel, Init(R2, '~E~xpression to watch', NameIL)));
  1919. GetExtent(R);
  1920. R.Grow(-1,-1);
  1921. R.A.Y:=R.A.Y+3;
  1922. R.B.X:=R.A.X+36;
  1923. TextST:=New(PAdvancedStaticText, Init(R, 'Watch values'));
  1924. Insert(TextST);
  1925. InsertButtons(@Self);
  1926. NameIL^.Select;
  1927. end;
  1928. function TWatchItemDialog.Execute: Word;
  1929. var R: word;
  1930. S1,S2: string;
  1931. begin
  1932. S1:=GetStr(Watch^.expr);
  1933. NameIL^.SetData(S1);
  1934. if assigned(Watch^.Current_value) then
  1935. S1:=GetPChar(Watch^.Current_value)
  1936. else
  1937. S1:='';
  1938. if assigned(Watch^.Last_value) then
  1939. S2:=GetPChar(Watch^.Last_value)
  1940. else
  1941. S2:='';
  1942. if assigned(Watch^.Last_value) and
  1943. assigned(Watch^.Current_value) and
  1944. (strcomp(Watch^.Last_value,Watch^.Current_value)=0) then
  1945. S1:='Current value: '+#13+S1
  1946. else
  1947. S1:='Current value: '+#13+S1+#13+
  1948. 'Previous value: '+#13+S2;
  1949. TextST^.SetText(S1);
  1950. R:=inherited Execute;
  1951. if R=cmOK then
  1952. begin
  1953. NameIL^.GetData(S1);
  1954. Watch^.Rename(S1);
  1955. If assigned(Debugger) then
  1956. Debugger^.ReadWatches;
  1957. end;
  1958. Execute:=R;
  1959. end;
  1960. {****************************************************************************
  1961. TStackWindow
  1962. ****************************************************************************}
  1963. constructor TFramesListBox.Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar);
  1964. begin
  1965. Inherited Init(Bounds,AHScrollBar,AVScrollBar);
  1966. end;
  1967. procedure TFramesListBox.Update;
  1968. var i : longint;
  1969. W : PSourceWindow;
  1970. begin
  1971. { call backtrace command }
  1972. If not assigned(Debugger) then
  1973. exit;
  1974. {$ifndef NODEBUG}
  1975. Clear;
  1976. { forget all old frames }
  1977. Debugger^.clear_frames;
  1978. Debugger^.Command('backtrace');
  1979. { generate list }
  1980. { all is in tframeentry }
  1981. for i:=Debugger^.frame_count-1 downto 0 do
  1982. begin
  1983. with Debugger^.frames[i]^ do
  1984. begin
  1985. AddItem(new(PMessageItem,init(0,GetPChar(function_name)+GetPChar(args),
  1986. AddModuleName(GetPChar(file_name)),line_number,1)));
  1987. W:=SearchOnDesktop(GetPChar(file_name),false);
  1988. If assigned(W) then
  1989. begin
  1990. W^.editor^.SetDebuggerRow(line_number);
  1991. end;
  1992. end;
  1993. end;
  1994. if List^.Count > 0 then
  1995. FocusItem(0);
  1996. {$endif}
  1997. end;
  1998. function TFramesListBox.GetLocalMenu: PMenu;
  1999. begin
  2000. GetLocalMenu:=Inherited GetLocalMenu;
  2001. end;
  2002. procedure TFramesListBox.GotoSource;
  2003. begin
  2004. { select frame for watches }
  2005. If not assigned(Debugger) then
  2006. exit;
  2007. {$ifdef NODEBUG}
  2008. Debugger^.Command('f '+IntToStr(Focused));
  2009. { for local vars }
  2010. Debugger^.ReadWatches;
  2011. {$endif}
  2012. { goto source }
  2013. inherited GotoSource;
  2014. end;
  2015. procedure TFramesListBox.HandleEvent(var Event: TEvent);
  2016. begin
  2017. inherited HandleEvent(Event);
  2018. end;
  2019. destructor TFramesListBox.Done;
  2020. begin
  2021. Inherited Done;
  2022. end;
  2023. Constructor TStackWindow.Init;
  2024. var
  2025. HSB,VSB: PScrollBar;
  2026. R,R2 : trect;
  2027. begin
  2028. Desktop^.GetExtent(R);
  2029. R.A.Y:=R.B.Y-5;
  2030. inherited Init(R, 'Call Stack', wnNoNumber);
  2031. GetExtent(R);
  2032. HelpCtx:=hcStack;
  2033. R.Grow(-1,-1);
  2034. R2.Copy(R);
  2035. Inc(R2.B.Y);
  2036. R2.A.Y:=R2.B.Y-1;
  2037. New(HSB, Init(R2));
  2038. HSB^.GrowMode:=gfGrowLoY+gfGrowHiY+gfGrowHiX;
  2039. Insert(HSB);
  2040. R2.Copy(R);
  2041. Inc(R2.B.X);
  2042. R2.A.X:=R2.B.X-1;
  2043. New(VSB, Init(R2));
  2044. VSB^.GrowMode:=gfGrowLoX+gfGrowHiX+gfGrowHiY;
  2045. Insert(VSB);
  2046. New(FLB,Init(R,HSB,VSB));
  2047. FLB^.GrowMode:=gfGrowHiX+gfGrowHiY;
  2048. Insert(FLB);
  2049. If assigned(StackWindow) then
  2050. dispose(StackWindow,done);
  2051. StackWindow:=@Self;
  2052. Update;
  2053. end;
  2054. procedure TStackWindow.Update;
  2055. begin
  2056. FLB^.Update;
  2057. DrawView;
  2058. end;
  2059. constructor TStackWindow.Load(var S: TStream);
  2060. begin
  2061. inherited Load(S);
  2062. GetSubViewPtr(S,FLB);
  2063. end;
  2064. procedure TStackWindow.Store(var S: TStream);
  2065. begin
  2066. inherited Store(S);
  2067. PutSubViewPtr(S,FLB);
  2068. end;
  2069. Destructor TStackWindow.Done;
  2070. begin
  2071. StackWindow:=nil;
  2072. Dispose(FLB,done);
  2073. inherited done;
  2074. end;
  2075. {****************************************************************************
  2076. Init/Final
  2077. ****************************************************************************}
  2078. procedure InitDebugger;
  2079. begin
  2080. {$ifdef DEBUG}
  2081. Assign(gdb_file,GDBOutFileName);
  2082. Rewrite(gdb_file);
  2083. Use_gdb_file:=true;
  2084. {$endif}
  2085. if (not ExistsFile(ExeFile)) or (CompilationPhase<>cpDone) then
  2086. DoCompile(cRun);
  2087. if CompilationPhase<>cpDone then
  2088. Exit;
  2089. if (EXEFile='') then
  2090. begin
  2091. ErrorBox('Oooops, nothing to debug.',nil);
  2092. Exit;
  2093. end;
  2094. { init debugcontroller }
  2095. if assigned(Debugger) then
  2096. dispose(Debugger,Done);
  2097. new(Debugger,Init(ExeFile));
  2098. {$ifdef GDBWINDOW}
  2099. InitGDBWindow;
  2100. {$endif def GDBWINDOW}
  2101. end;
  2102. procedure DoneDebugger;
  2103. begin
  2104. if assigned(Debugger) then
  2105. dispose(Debugger,Done);
  2106. Debugger:=nil;
  2107. {$ifdef DEBUG}
  2108. If Use_gdb_file then
  2109. Close(GDB_file);
  2110. Use_gdb_file:=false;
  2111. {$endif}
  2112. {DoneGDBWindow;}
  2113. end;
  2114. procedure InitGDBWindow;
  2115. var
  2116. R : TRect;
  2117. begin
  2118. if GDBWindow=nil then
  2119. begin
  2120. DeskTop^.GetExtent(R);
  2121. new(GDBWindow,init(R));
  2122. DeskTop^.Insert(GDBWindow);
  2123. end;
  2124. end;
  2125. procedure DoneGDBWindow;
  2126. begin
  2127. if assigned(GDBWindow) then
  2128. begin
  2129. DeskTop^.Delete(GDBWindow);
  2130. GDBWindow:=nil;
  2131. end;
  2132. end;
  2133. procedure InitStackWindow;
  2134. begin
  2135. if StackWindow=nil then
  2136. begin
  2137. new(StackWindow,init);
  2138. DeskTop^.Insert(StackWindow);
  2139. end;
  2140. end;
  2141. procedure DoneStackWindow;
  2142. begin
  2143. if assigned(StackWindow) then
  2144. begin
  2145. DeskTop^.Delete(StackWindow);
  2146. StackWindow:=nil;
  2147. end;
  2148. end;
  2149. procedure InitBreakpoints;
  2150. begin
  2151. New(BreakpointsCollection,init(10,10));
  2152. end;
  2153. procedure DoneBreakpoints;
  2154. begin
  2155. Dispose(BreakpointsCollection,Done);
  2156. BreakpointsCollection:=nil;
  2157. end;
  2158. procedure InitWatches;
  2159. begin
  2160. New(WatchesCollection,init);
  2161. end;
  2162. procedure DoneWatches;
  2163. begin
  2164. Dispose(WatchesCollection,Done);
  2165. WatchesCollection:=nil;
  2166. end;
  2167. procedure RegisterFPDebugViews;
  2168. begin
  2169. RegisterType(RWatchesWindow);
  2170. RegisterType(RBreakpointsWindow);
  2171. RegisterType(RWatchesListBox);
  2172. RegisterType(RBreakpointsListBox);
  2173. RegisterType(RStackWindow);
  2174. RegisterType(RFramesListBox);
  2175. RegisterType(RBreakpoint);
  2176. RegisterType(RWatch);
  2177. RegisterType(RBreakpointCollection);
  2178. RegisterType(RWatchesCollection);
  2179. end;
  2180. end.
  2181. {
  2182. $Log$
  2183. Revision 1.36 1999-12-20 14:23:16 pierre
  2184. * MyApp renamed IDEApp
  2185. * TDebugController.ResetDebuggerRows added to
  2186. get resetting of debugger rows
  2187. Revision 1.35 1999/11/24 14:03:16 pierre
  2188. + Executing... in status line if in another window
  2189. Revision 1.34 1999/11/10 17:19:58 pierre
  2190. + Other window for Debuggee code
  2191. Revision 1.33 1999/10/25 16:39:03 pierre
  2192. + GetPChar to avoid nil pointer problems
  2193. Revision 1.32 1999/09/16 14:34:57 pierre
  2194. + TBreakpoint and TWatch registering
  2195. + WatchesCollection and BreakpointsCollection stored in desk file
  2196. * Syntax highlighting was broken
  2197. Revision 1.31 1999/09/13 16:24:43 peter
  2198. + clock
  2199. * backspace unident like tp7
  2200. Revision 1.30 1999/09/09 16:36:30 pierre
  2201. * Breakpoint storage problem corrected
  2202. Revision 1.29 1999/09/09 16:31:45 pierre
  2203. * some breakpoint related fixes and Help contexts
  2204. Revision 1.28 1999/09/09 14:20:05 pierre
  2205. + Stack Window
  2206. Revision 1.27 1999/08/24 22:04:33 pierre
  2207. + TCodeEditor.SetDebuggerRow
  2208. works like SetHighlightRow but is only disposed by a SetDebuggerRow(-1)
  2209. so the current stop point in debugging is not lost if
  2210. we move the cursor
  2211. Revision 1.26 1999/08/22 22:26:48 pierre
  2212. + Registration of Breakpoint/Watches windows
  2213. Revision 1.25 1999/08/16 18:25:15 peter
  2214. * Adjusting the selection when the editor didn't contain any line.
  2215. * Reserved word recognition redesigned, but this didn't affect the overall
  2216. syntax highlight speed remarkably (at least not on my Amd-K6/350).
  2217. The syntax scanner loop is a bit slow but the main problem is the
  2218. recognition of special symbols. Switching off symbol processing boosts
  2219. the performance up to ca. 200%...
  2220. * The editor didn't allow copying (for ex to clipboard) of a single character
  2221. * 'File|Save as' caused permanently run-time error 3. Not any more now...
  2222. * Compiler Messages window (actually the whole desktop) did not act on any
  2223. keypress when compilation failed and thus the window remained visible
  2224. + Message windows are now closed upon pressing Esc
  2225. + At 'Run' the IDE checks whether any sources are modified, and recompiles
  2226. only when neccessary
  2227. + BlockRead and BlockWrite (Ctrl+K+R/W) implemented in TCodeEditor
  2228. + LineSelect (Ctrl+K+L) implemented
  2229. * The IDE had problems closing help windows before saving the desktop
  2230. Revision 1.24 1999/08/03 20:22:28 peter
  2231. + TTab acts now on Ctrl+Tab and Ctrl+Shift+Tab...
  2232. + Desktop saving should work now
  2233. - History saved
  2234. - Clipboard content saved
  2235. - Desktop saved
  2236. - Symbol info saved
  2237. * syntax-highlight bug fixed, which compared special keywords case sensitive
  2238. (for ex. 'asm' caused asm-highlighting, while 'ASM' didn't)
  2239. * with 'whole words only' set, the editor didn't found occourences of the
  2240. searched text, if the text appeared previously in the same line, but didn't
  2241. satisfied the 'whole-word' condition
  2242. * ^QB jumped to (SelStart.X,SelEnd.X) instead of (SelStart.X,SelStart.Y)
  2243. (ie. the beginning of the selection)
  2244. * when started typing in a new line, but not at the start (X=0) of it,
  2245. the editor inserted the text one character more to left as it should...
  2246. * TCodeEditor.HideSelection (Ctrl-K+H) didn't update the screen
  2247. * Shift shouldn't cause so much trouble in TCodeEditor now...
  2248. * Syntax highlight had problems recognizing a special symbol if it was
  2249. prefixed by another symbol character in the source text
  2250. * Auto-save also occours at Dos shell, Tool execution, etc. now...
  2251. Revision 1.23 1999/07/28 23:11:17 peter
  2252. * fixes from gabor
  2253. Revision 1.22 1999/07/12 13:14:15 pierre
  2254. * LineEnd bug corrected, now goes end of text even if selected
  2255. + Until Return for debugger
  2256. + Code for Quit inside GDB Window
  2257. Revision 1.21 1999/07/11 00:35:14 pierre
  2258. * fix problems for wrong watches
  2259. Revision 1.20 1999/07/10 01:24:14 pierre
  2260. + First implementation of watches window
  2261. Revision 1.19 1999/06/30 23:58:12 pierre
  2262. + BreakpointsList Window implemented
  2263. with Edit/New/Delete functions
  2264. + Individual breakpoint dialog with support for all types
  2265. ignorecount and conditions
  2266. (commands are not yet implemented, don't know if this wolud be useful)
  2267. awatch and rwatch have problems because GDB does not annotate them
  2268. I fixed v4.16 for this
  2269. Revision 1.18 1999/03/16 00:44:42 peter
  2270. * forgotten in last commit :(
  2271. Revision 1.17 1999/03/02 13:48:28 peter
  2272. * fixed far problem is fpdebug
  2273. * tile/cascading with message window
  2274. * grep fixes
  2275. Revision 1.16 1999/03/01 15:41:52 peter
  2276. + Added dummy entries for functions not yet implemented
  2277. * MenuBar didn't update itself automatically on command-set changes
  2278. * Fixed Debugging/Profiling options dialog
  2279. * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
  2280. set
  2281. * efBackSpaceUnindents works correctly
  2282. + 'Messages' window implemented
  2283. + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros
  2284. + Added TP message-filter support (for ex. you can call GREP thru
  2285. GREP2MSG and view the result in the messages window - just like in TP)
  2286. * A 'var' was missing from the param-list of THelpFacility.TopicSearch,
  2287. so topic search didn't work...
  2288. * In FPHELP.PAS there were still context-variables defined as word instead
  2289. of THelpCtx
  2290. * StdStatusKeys() was missing from the statusdef for help windows
  2291. + Topic-title for index-table can be specified when adding a HTML-files
  2292. Revision 1.15 1999/02/20 15:18:29 peter
  2293. + ctrl-c capture with confirm dialog
  2294. + ascii table in the tools menu
  2295. + heapviewer
  2296. * empty file fixed
  2297. * fixed callback routines in fpdebug to have far for tp7
  2298. Revision 1.14 1999/02/16 12:47:36 pierre
  2299. * GDBWindow does not popup on F7 or F8 anymore
  2300. Revision 1.13 1999/02/16 10:43:54 peter
  2301. * use -dGDB for the compiler
  2302. * only use gdb_file when -dDEBUG is used
  2303. * profiler switch is now a toggle instead of radiobutton
  2304. Revision 1.12 1999/02/11 19:07:20 pierre
  2305. * GDBWindow redesigned :
  2306. normal editor apart from
  2307. that any kbEnter will send the line (for begin to cursor)
  2308. to GDB command !
  2309. GDBWindow opened in Debugger Menu
  2310. still buggy :
  2311. -echo should not be present if at end of text
  2312. -GDBWindow becomes First after each step (I don't know why !)
  2313. Revision 1.11 1999/02/11 13:10:03 pierre
  2314. + GDBWindow only with -dGDBWindow for now : still buggy !!
  2315. Revision 1.10 1999/02/10 09:55:07 pierre
  2316. + added OldValue and CurrentValue field for watchpoints
  2317. + InitBreakpoints and DoneBreakpoints
  2318. + MessageBox if GDB stops bacause of a watchpoint !
  2319. Revision 1.9 1999/02/08 17:43:43 pierre
  2320. * RestDebugger or multiple running of debugged program now works
  2321. + added DoContToCursor(F4)
  2322. * Breakpoints are now inserted correctly (was mainlyy a problem
  2323. of directories)
  2324. Revision 1.8 1999/02/05 17:21:52 pierre
  2325. Invalid_line renamed InvalidSourceLine
  2326. Revision 1.7 1999/02/05 13:08:41 pierre
  2327. + new breakpoint types added
  2328. Revision 1.6 1999/02/05 12:11:53 pierre
  2329. + SourceDir that stores directories for sources that the
  2330. compiler should not know about
  2331. Automatically asked for addition when a new file that
  2332. needed filedialog to be found is in an unknown directory
  2333. Stored and retrieved from INIFile
  2334. + Breakpoints conditions added to INIFile
  2335. * Breakpoints insterted and removed at debin and end of debug session
  2336. Revision 1.5 1999/02/04 17:54:22 pierre
  2337. + several commands added
  2338. Revision 1.4 1999/02/04 13:32:02 pierre
  2339. * Several things added (I cannot commit them independently !)
  2340. + added TBreakpoint and TBreakpointCollection
  2341. + added cmResetDebugger,cmGrep,CmToggleBreakpoint
  2342. + Breakpoint list in INIFile
  2343. * Select items now also depend of SwitchMode
  2344. * Reading of option '-g' was not possible !
  2345. + added search for -Fu args pathes in TryToOpen
  2346. + added code for automatic opening of FileDialog
  2347. if source not found
  2348. Revision 1.3 1999/02/02 16:41:38 peter
  2349. + automatic .pas/.pp adding by opening of file
  2350. * better debuggerscreen changes
  2351. Revision 1.2 1999/01/22 18:14:09 pierre
  2352. * adaptd to changes in gdbint and gdbcon for to /
  2353. Revision 1.1 1999/01/22 10:24:03 peter
  2354. * first debugger things
  2355. }