Browse Source

parallel stacks v0.2

pull/15/head
Eusebiu Marcu 15 years ago
parent
commit
5feb6386c5
  1. 4
      src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs
  2. 6
      src/AddIns/Debugger/Debugger.AddIn/Pads/ParallelPad/DrawSurface.xaml
  3. 15
      src/AddIns/Debugger/Debugger.AddIn/Pads/ParallelPad/DrawSurface.xaml.cs
  4. 34
      src/AddIns/Debugger/Debugger.AddIn/Pads/ParallelPad/ParallelStackPad.cs
  5. 14
      src/AddIns/Debugger/Debugger.AddIn/Pads/ParallelPad/ThreadStack.xaml
  6. 69
      src/AddIns/Debugger/Debugger.AddIn/Pads/ParallelPad/ThreadStack.xaml.cs

4
src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs

@ -164,13 +164,13 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
} }
} }
string GetFullName(StackFrame frame) internal static string GetFullName(StackFrame frame)
{ {
bool showArgumentNames = DebuggingOptions.Instance.ShowArgumentNames; bool showArgumentNames = DebuggingOptions.Instance.ShowArgumentNames;
bool showArgumentValues = DebuggingOptions.Instance.ShowArgumentValues; bool showArgumentValues = DebuggingOptions.Instance.ShowArgumentValues;
StringBuilder name = new StringBuilder(); StringBuilder name = new StringBuilder();
name.Append(frame.MethodInfo.DeclaringType.Name); name.Append(frame.MethodInfo.DeclaringType.FullName);
name.Append('.'); name.Append('.');
name.Append(frame.MethodInfo.Name); name.Append(frame.MethodInfo.Name);
if (showArgumentNames || showArgumentValues) { if (showArgumentNames || showArgumentValues) {

6
src/AddIns/Debugger/Debugger.AddIn/Pads/ParallelPad/DrawSurface.xaml

@ -43,7 +43,7 @@
<TextBlock <TextBlock
Canvas.Top="2" Canvas.Top="2"
Canvas.Left="1" Canvas.Left="1"
Text="100%" Text="Reset"
FontSize="9" FontSize="9"
Foreground="LightGray" /> Foreground="LightGray" />
</Canvas> </Canvas>
@ -127,6 +127,10 @@
<local:ParallelStacksGraphLayout <local:ParallelStacksGraphLayout
x:Name="ParallelStacksLayout" x:Name="ParallelStacksLayout"
LayoutAlgorithmType = "Tree" LayoutAlgorithmType = "Tree"
IsAnimationEnabled="False"
EdgeRoutingAlgorithmType="Automatic"
EdgeRoutingConstraint="Automatic"
OverlapRemovalConstraint="Automatic"
OverlapRemovalAlgorithmType = "FSA"/> OverlapRemovalAlgorithmType = "FSA"/>
</Canvas> </Canvas>
</Grid> </Grid>

15
src/AddIns/Debugger/Debugger.AddIn/Pads/ParallelPad/DrawSurface.xaml.cs

@ -32,7 +32,6 @@ namespace Debugger.AddIn.Pads.ParallelPad
public void SetGraph(ParallelStacksGraph graph) public void SetGraph(ParallelStacksGraph graph)
{ {
this.ParallelStacksLayout.Graph = graph; this.ParallelStacksLayout.Graph = graph;
this.ParallelStacksLayout.Relayout();
} }
#region Pan #region Pan
@ -50,10 +49,10 @@ namespace Debugger.AddIn.Pads.ParallelPad
void DrawSurface_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) void DrawSurface_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{ {
drawingSurface.ReleaseMouseCapture();
if (e.OriginalSource is Slider || e.OriginalSource is Button) if (e.OriginalSource is Slider || e.OriginalSource is Button)
return; return;
drawingSurface.ReleaseMouseCapture();
this.PreviewMouseMove -= DrawSurface_PreviewMouseMove; this.PreviewMouseMove -= DrawSurface_PreviewMouseMove;
Cursor = Cursors.Arrow; Cursor = Cursors.Arrow;
} }
@ -67,10 +66,11 @@ namespace Debugger.AddIn.Pads.ParallelPad
if (e.OriginalSource is Slider || e.OriginalSource is Button) if (e.OriginalSource is Slider || e.OriginalSource is Button)
return; return;
Cursor = Cursors.ScrollAll; Cursor = Cursors.SizeAll;
Vector v = dragStartedPoint - e.GetPosition(drawingSurface); var point = e.GetPosition(drawingSurface);
translate.X = v.X / 5; Vector v = dragStartedPoint - point;
translate.Y = v.Y / 5; translate.X += v.X / 200;
translate.Y += v.Y / 200;
e.Handled = true; e.Handled = true;
} }
} }
@ -98,6 +98,9 @@ namespace Debugger.AddIn.Pads.ParallelPad
void Reset_Click(object sender, RoutedEventArgs e) void Reset_Click(object sender, RoutedEventArgs e)
{ {
this.SliderControl.Value = 5; this.SliderControl.Value = 5;
translate.X = 0;
translate.Y = 0;
} }
#endregion #endregion

34
src/AddIns/Debugger/Debugger.AddIn/Pads/ParallelPad/ParallelStackPad.cs

@ -12,6 +12,7 @@ using System.Windows.Media;
using Debugger.AddIn.TreeModel; using Debugger.AddIn.TreeModel;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
using ICSharpCode.SharpDevelop.Debugging; using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Gui.Pads; using ICSharpCode.SharpDevelop.Gui.Pads;
using ICSharpCode.SharpDevelop.Services; using ICSharpCode.SharpDevelop.Services;
@ -68,7 +69,7 @@ namespace Debugger.AddIn.Pads.ParallelPad
return; return;
} }
using(new PrintTimes("Threads refresh")) { using(new PrintTimes("Parallel stack refresh")) {
try { try {
OnReset(null, EventArgs.Empty); OnReset(null, EventArgs.Empty);
// create all simple ThreadStacks // create all simple ThreadStacks
@ -90,11 +91,13 @@ namespace Debugger.AddIn.Pads.ParallelPad
throw; throw;
} }
} }
}
using(new PrintTimes("Graph refresh")) {
// paint the ThreadStaks // paint the ThreadStaks
graph = new ParallelStacksGraph(); graph = new ParallelStacksGraph();
foreach (var stack in this.currentThreadStacks) foreach (var stack in this.currentThreadStacks)
{ {
if (stack == null) if (stack == null)
continue; continue;
if (stack.ThreadStackParent != null && if (stack.ThreadStackParent != null &&
@ -105,13 +108,14 @@ namespace Debugger.AddIn.Pads.ParallelPad
// add the children // add the children
AddChildren(stack); AddChildren(stack);
} }
surface.SetGraph(graph); surface.SetGraph(graph);
} }
} }
ParallelStacksGraph graph; ParallelStacksGraph graph;
void AddChildren(ThreadStack parent) void AddChildren(ThreadStack parent)
{ {
if(parent.ThreadStackChildren == null || parent.ThreadStackChildren.Length == 0) if(parent.ThreadStackChildren == null || parent.ThreadStackChildren.Length == 0)
@ -245,6 +249,7 @@ namespace Debugger.AddIn.Pads.ParallelPad
commonParent.ThreadIds = threadIds; commonParent.ThreadIds = threadIds;
commonParent.ItemCollection = parentItems.ToObservable(); commonParent.ItemCollection = parentItems.ToObservable();
commonParent.Process = debuggedProcess; commonParent.Process = debuggedProcess;
commonParent.FrameSelected += threadStack_FrameSelected;
commonParent.IsSelected = commonParent.ThreadIds.Contains(debuggedProcess.SelectedThread.ID); commonParent.IsSelected = commonParent.ThreadIds.Contains(debuggedProcess.SelectedThread.ID);
// add new children // add new children
foreach (var stack in listOfCurrentStacks) { foreach (var stack in listOfCurrentStacks) {
@ -283,6 +288,7 @@ namespace Debugger.AddIn.Pads.ParallelPad
return; return;
ThreadStack threadStack = new ThreadStack(); ThreadStack threadStack = new ThreadStack();
threadStack.FrameSelected += threadStack_FrameSelected;
threadStack.ThreadIds = new List<uint>(); threadStack.ThreadIds = new List<uint>();
threadStack.ThreadIds.Add(thread.ID); threadStack.ThreadIds.Add(thread.ID);
threadStack.Process = debuggedProcess; threadStack.Process = debuggedProcess;
@ -292,6 +298,14 @@ namespace Debugger.AddIn.Pads.ParallelPad
if (debuggedProcess.SelectedThread != null) if (debuggedProcess.SelectedThread != null)
threadStack.IsSelected = threadStack.ThreadIds.Contains(debuggedProcess.SelectedThread.ID); threadStack.IsSelected = threadStack.ThreadIds.Contains(debuggedProcess.SelectedThread.ID);
} }
void threadStack_FrameSelected(object sender, EventArgs e)
{
foreach (var ts in this.currentThreadStacks) {
ts.IsSelected = false;
ts.ClearImages();
}
}
private ObservableCollection<ExpandoObject> CreateItems(Thread thread) private ObservableCollection<ExpandoObject> CreateItems(Thread thread)
{ {
@ -315,7 +329,14 @@ namespace Debugger.AddIn.Pads.ParallelPad
lastItemIsExternalMethod = true; lastItemIsExternalMethod = true;
} }
obj.Image = null; if (thread.SelectedStackFrame != null &&
thread.ID == debuggedProcess.SelectedThread.ID &&
thread.SelectedStackFrame.IP == frame.IP &&
thread.SelectedStackFrame.GetMethodName() == frame.GetMethodName())
obj.Image = PresentationResourceService.GetImage("Bookmarks.CurrentLine").Source;
else
obj.Image = null;
obj.MethodName = fullName; obj.MethodName = fullName;
result.Add(obj); result.Add(obj);
@ -331,6 +352,9 @@ namespace Debugger.AddIn.Pads.ParallelPad
{ {
internal static string GetMethodName(this StackFrame frame) internal static string GetMethodName(this StackFrame frame)
{ {
if (frame == null)
return null;
StringBuilder name = new StringBuilder(); StringBuilder name = new StringBuilder();
name.Append(frame.MethodInfo.DeclaringType.FullName); name.Append(frame.MethodInfo.DeclaringType.FullName);
name.Append('.'); name.Append('.');

14
src/AddIns/Debugger/Debugger.AddIn/Pads/ParallelPad/ThreadStack.xaml

@ -78,16 +78,26 @@
</Style.Triggers> </Style.Triggers>
</Style> </Style>
</DataGrid.CellStyle> </DataGrid.CellStyle>
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="White"></Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="LightGray" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTemplateColumn> <DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Border BorderBrush="Gray" BorderThickness="0,1,1,0" Width="25" Height="22"> <Border BorderBrush="Gray" BorderThickness="0,1,1,0" Width="25" Height="22">
<Image VerticalAlignment="Center" HorizontalAlignment="Center" <Image VerticalAlignment="Center" Margin="0,-5,0,0" Width="14" Height="14" HorizontalAlignment="Center"
Source="{Binding Image}" /> Source="{Binding Image}" />
</Border> </Border>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn>
<DataGridTemplateColumn <DataGridTemplateColumn
Width="Auto"> Width="Auto">

69
src/AddIns/Debugger/Debugger.AddIn/Pads/ParallelPad/ThreadStack.xaml.cs

@ -10,6 +10,11 @@ using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.Core.Presentation;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Gui.Pads;
using ICSharpCode.SharpDevelop.Services;
namespace Debugger.AddIn.Pads.ParallelPad namespace Debugger.AddIn.Pads.ParallelPad
{ {
public partial class ThreadStack : UserControl public partial class ThreadStack : UserControl
@ -20,15 +25,20 @@ namespace Debugger.AddIn.Pads.ParallelPad
DependencyProperty.Register("IsSelected", typeof(bool), typeof(ThreadStack), DependencyProperty.Register("IsSelected", typeof(bool), typeof(ThreadStack),
new FrameworkPropertyMetadata()); new FrameworkPropertyMetadata());
public event EventHandler FrameSelected;
private ObservableCollection<ExpandoObject> itemCollection = new ObservableCollection<ExpandoObject>(); private ObservableCollection<ExpandoObject> itemCollection = new ObservableCollection<ExpandoObject>();
private ToolTip toolTip = new ToolTip();
public ThreadStack() public ThreadStack()
{ {
InitializeComponent(); InitializeComponent();
ToolTip = toolTip;
ToolTipOpening += new ToolTipEventHandler(OnToolTipOpening);
} }
internal bool IsAdded { get; set; }
public Process Process { get; set; } public Process Process { get; set; }
public bool IsSelected { public bool IsSelected {
@ -71,7 +81,14 @@ namespace Debugger.AddIn.Pads.ParallelPad
} }
} }
private void SelectParent(bool isSelected) public void ClearImages()
{
foreach(dynamic item in itemCollection) {
item.Image = null;
}
}
void SelectParent(bool isSelected)
{ {
var ts = this.ThreadStackParent; var ts = this.ThreadStackParent;
while(ts != null) { while(ts != null) {
@ -99,9 +116,18 @@ namespace Debugger.AddIn.Pads.ParallelPad
void SelectFrame(uint threadId, ExpandoObject selectedItem) void SelectFrame(uint threadId, ExpandoObject selectedItem)
{ {
if (selectedItem == null)
return;
var thread = Process.Threads.Find(t => t.ID == threadId); var thread = Process.Threads.Find(t => t.ID == threadId);
if (thread == null) if (thread == null)
return; return;
if (FrameSelected != null)
FrameSelected(this, EventArgs.Empty);
this.IsSelected = true;
dynamic obj = selectedItem; dynamic obj = selectedItem;
Process.SelectedThread = thread; Process.SelectedThread = thread;
foreach(var frame in thread.Callstack) foreach(var frame in thread.Callstack)
@ -109,11 +135,11 @@ namespace Debugger.AddIn.Pads.ParallelPad
if (frame.GetMethodName() == obj.MethodName) if (frame.GetMethodName() == obj.MethodName)
{ {
Process.SelectedThread.SelectedStackFrame = frame; Process.SelectedThread.SelectedStackFrame = frame;
obj.Image = PresentationResourceService.GetImage("Bookmarks.CurrentLine").Source;
((WindowsDebugger)DebuggerService.CurrentDebugger).JumpToCurrentLine();
break; break;
} }
} }
Process.OnPaused();
} }
void Datagrid_MouseRightButtonUp(object sender, MouseButtonEventArgs e) void Datagrid_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
@ -138,7 +164,7 @@ namespace Debugger.AddIn.Pads.ParallelPad
MenuItem m = new MenuItem(); MenuItem m = new MenuItem();
m.IsCheckable = true; m.IsCheckable = true;
m.IsChecked = id == Process.SelectedThread.ID; m.IsChecked = id == Process.SelectedThread.ID;
m.Checked += delegate(object sender, RoutedEventArgs e) { m.Click += delegate(object sender, RoutedEventArgs e) {
var menuItem = e.OriginalSource as MenuItem; var menuItem = e.OriginalSource as MenuItem;
SelectFrame((uint)menuItem.Tag, item); SelectFrame((uint)menuItem.Tag, item);
}; };
@ -150,5 +176,36 @@ namespace Debugger.AddIn.Pads.ParallelPad
return menu; return menu;
} }
void OnToolTipOpening(object sender, ToolTipEventArgs e)
{
StackPanel panel = new StackPanel();
dynamic selectedItem = datagrid.SelectedItem;
if (selectedItem == null) {
panel.Children.Add(new TextBlock { Text = "No item selected" });
this.toolTip.Content = panel;
return;
}
foreach(var thread in Process.Threads)
{
if (ThreadIds.Contains(thread.ID))
{
foreach (var frame in thread.Callstack)
{
if (selectedItem.MethodName == frame.GetMethodName())
{
// TODO : get method parameter values
TextBlock tb = new TextBlock();
tb.Text = thread.ID + ": " + CallStackPadContent.GetFullName(frame);
panel.Children.Add(tb);
}
}
}
}
this.toolTip.Content = panel;
}
} }
} }
Loading…
Cancel
Save