fpdebug.pas 97 KB

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