diff --git a/debugger/assemblerdlg.pp b/debugger/assemblerdlg.pp index 4da520394b..50ad1f8f98 100644 --- a/debugger/assemblerdlg.pp +++ b/debugger/assemblerdlg.pp @@ -87,7 +87,8 @@ type FDebugManager: TBaseDebugManager; FDisassembler: TIDEDisassembler; FDisassemblerNotification: TIDEDisassemblerNotification; - FCurrentLocation, FLocation: TDBGPtr; + FCurrentLocation: TDBGPtr; // current view location (lines are relative to this location) + FLocation: TDBGPtr; // the actual PC, green "=>" execution mark FMouseIsDown: Boolean; FIsVScrollTrack: Boolean; FVScrollCounter, FVScrollPos: Integer; @@ -148,7 +149,7 @@ type constructor Create(AOwner: TComponent); override; destructor Destroy; override; - procedure SetLocation(ADebugger: TDebugger; const AAddr: TDBGPtr); + procedure SetLocation(ADebugger: TDebugger; const AAddr: TDBGPtr; const ADispAddr: TDBGPtr = 0); property Disassembler: TIDEDisassembler read FDisassembler write SetDisassembler; property DebugManager: TBaseDebugManager read FDebugManager write FDebugManager; property BreakPoints; @@ -428,7 +429,9 @@ begin if AnAsmDlgLineEntry.ImageIndex > 0 then exit; if not (AnAsmDlgLineEntry.State in [lmsStatement, lmsSource]) then exit; - AnAsmDlgLineEntry.ImageIndex := GetBreakPointImageIndex(GetBreakpointFor(AnAsmDlgLineEntry), AnAsmDlgLineEntry.Addr = FLocation); + AnAsmDlgLineEntry.ImageIndex := GetBreakPointImageIndex(GetBreakpointFor(AnAsmDlgLineEntry), + (AnAsmDlgLineEntry.State = lmsStatement) and + (AnAsmDlgLineEntry.Addr = FLocation)); if AnAsmDlgLineEntry.ImageIndex >= 0 then exit; @@ -819,13 +822,15 @@ begin SetLineCount(pbAsm.Height div FLineHeight); end; -procedure TAssemblerDlg.SetLocation(ADebugger: TDebugger; const AAddr: TDBGPtr); +procedure TAssemblerDlg.SetLocation(ADebugger: TDebugger; const AAddr: TDBGPtr; const ADispAddr: TDBGPtr = 0); var i: Integer; begin SetDebugger(ADebugger); - FCurrentLocation := AAddr; + if ADispAddr <> 0 + then FCurrentLocation := ADispAddr + else FCurrentLocation := AAddr; FLocation := AAddr; FLastTopLineValid := False; diff --git a/debugger/callstackdlg.lfm b/debugger/callstackdlg.lfm index fe6f79eabc..3ee6932ae6 100644 --- a/debugger/callstackdlg.lfm +++ b/debugger/callstackdlg.lfm @@ -173,6 +173,9 @@ inherited CallStackDlg: TCallStackDlg Default = True OnClick = actShowClick end + object popShowDisass: TMenuItem + Action = actShowDisass + end object popToggle: TMenuItem Action = actToggleBreakPoint OnClick = actToggleBreakPointExecute @@ -238,6 +241,10 @@ inherited CallStackDlg: TCallStackDlg OnExecute = actToggleBreakPointExecute ShortCut = 116 end + object actShowDisass: TAction + Caption = 'actShowDisass' + OnExecute = actShowDisassExecute + end end object mnuLimit: TPopupMenu[4] left = 136 diff --git a/debugger/callstackdlg.pp b/debugger/callstackdlg.pp index 71506fe1f7..b9845521f6 100644 --- a/debugger/callstackdlg.pp +++ b/debugger/callstackdlg.pp @@ -47,6 +47,7 @@ type TCallStackDlg = class(TDebuggerDlg) aclActions: TActionList; actCopyAll: TAction; + actShowDisass: TAction; actToggleBreakPoint: TAction; actViewBottom: TAction; actViewTop: TAction; @@ -55,6 +56,7 @@ type actViewMore: TAction; actSetCurrent: TAction; actShow: TAction; + popShowDisass: TMenuItem; popToggle: TMenuItem; ToolButtonPower: TToolButton; ToolButton2: TToolButton; @@ -82,6 +84,7 @@ type ToolButtonMore: TToolButton; ToolButtonMax: TToolButton; ToolButtonGoto: TToolButton; + procedure actShowDisassExecute(Sender: TObject); procedure actToggleBreakPointExecute(Sender: TObject); procedure actViewBottomExecute(Sender: TObject); procedure actViewGotoExecute(Sender: TObject); @@ -568,6 +571,15 @@ begin ToggleBreakpoint(lvCallStack.Selected); end; +procedure TCallStackDlg.actShowDisassExecute(Sender: TObject); +var + Entry: TCallStackEntry; +begin + Entry := GetCurrentEntry; + if (Entry = nil) or (Entry.Address = 0) then Exit; + DebugBoss.ViewDisassembler(Entry.Address); +end; + procedure TCallStackDlg.actViewGotoExecute(Sender: TObject); begin try @@ -641,6 +653,7 @@ begin actViewBottom.Caption := lisBottom; actViewGoto.Caption := lisGotoSelectedSourceLine; actShow.Caption := lisViewSource; + actShowDisass.Caption := lisViewSourceDisass; actToggleBreakPoint.Caption := uemToggleBreakpoint; actSetCurrent.Caption := lisCurrent; actCopyAll.Caption := lisCopyAll; diff --git a/ide/basedebugmanager.pas b/ide/basedebugmanager.pas index fc0b0747d2..34805ea894 100644 --- a/ide/basedebugmanager.pas +++ b/ide/basedebugmanager.pas @@ -174,6 +174,9 @@ type procedure ViewDebugDialog(const ADialogType: TDebugDialogType; BringToFront: Boolean = True; Show: Boolean = true; DoDisableAutoSizing: boolean = false); virtual; abstract; + procedure ViewDisassembler(AnAddr: TDBGPtr; + BringToFront: Boolean = True; Show: Boolean = true; + DoDisableAutoSizing: boolean = false); virtual; abstract; public property Commands: TDBGCommands read GetCommands; // All current available commands of the debugger property Debuggers[const AIndex: Integer]: TDebuggerClass read GetDebuggerClass; diff --git a/ide/debugmanager.pas b/ide/debugmanager.pas index 8256029226..caae868839 100644 --- a/ide/debugmanager.pas +++ b/ide/debugmanager.pas @@ -228,6 +228,9 @@ type function ShowWatchProperties(const AWatch: TCurrentWatch; AWatchExpression: String = ''): TModalresult; override; procedure ViewDebugDialog(const ADialogType: TDebugDialogType; BringToFront: Boolean = true; Show: Boolean = true; DoDisableAutoSizing: boolean = false); override; + procedure ViewDisassembler(AnAddr: TDBGPtr; + BringToFront: Boolean = True; Show: Boolean = true; + DoDisableAutoSizing: boolean = false); override; end; implementation @@ -1376,6 +1379,14 @@ begin end; end; +procedure TDebugManager.ViewDisassembler(AnAddr: TDBGPtr; BringToFront: Boolean; + Show: Boolean; DoDisableAutoSizing: boolean); +begin + ViewDebugDialog(ddtAssembler, BringToFront, Show, DoDisableAutoSizing); + if FDialogs[ddtAssembler] <> nil + then TAssemblerDlg(FDialogs[ddtAssembler]).SetLocation(FDebugger, FCurrentLocation.Address, AnAddr); +end; + procedure TDebugManager.DestroyDebugDialog(const ADialogType: TDebugDialogType); begin if FDialogs[ADialogType] = nil then Exit; diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index 09ace23ef4..41d8fa4652 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -4585,6 +4585,7 @@ resourcestring // Call Stack Dialog lisCurrent = 'Current'; lisViewSource = 'View Source'; + lisViewSourceDisass = 'View Assembler'; lisMaxS = 'Max %d'; lisMore = 'More'; lisTop = 'Top';