Skip to content

Commit 5762333

Browse files
authored
Add "resolve clipboard contents" functionality (#114)
Implements #113
1 parent 5986d5f commit 5762333

3 files changed

Lines changed: 72 additions & 32 deletions

File tree

GUI/MainForm.Designer.cs

Lines changed: 30 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GUI/MainForm.cs

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,53 @@ public MainForm() {
2121
internal static readonly string LatestReleaseTimestampCulture = "en-US";
2222

2323
private void ResolveCallstacks_Click(object sender, EventArgs e) {
24+
if (!ValidateInputs()) return;
25+
ProcessCallstacks();
26+
}
27+
28+
private void ResolveCallStackFromClipboardButton_Click(object sender, EventArgs e) {
29+
callStackInput.Clear();
30+
finalOutput.Clear();
31+
callStackInput.Text = Clipboard.GetText();
32+
if (!ValidateInputs()) return;
33+
ProcessCallstacks();
34+
}
35+
36+
private void ProcessCallstacks() {
37+
List<StackDetails> allStacks = null;
38+
using (BackgroundCTS = new CancellationTokenSource()) {
39+
var allStacksTask = this._resolver.GetListofCallStacksAsync(callStackInput.Text, FramesOnSingleLine.Checked, RelookupSource.Checked, BackgroundCTS);
40+
this.MonitorBackgroundTask(allStacksTask);
41+
allStacks = allStacksTask.Result;
42+
}
43+
if (allStacks.Any()) using (BackgroundCTS = new CancellationTokenSource()) {
44+
var resolverTask = this._resolver.ResolveCallstacksAsync(allStacks, pdbPaths.Text, pdbRecurse.Checked, string.IsNullOrEmpty(binaryPaths.Text) ? null : binaryPaths.Text.Split(';').ToList(),
45+
DLLrecurse.Checked, IncludeLineNumbers.Checked, RelookupSource.Checked,
46+
includeOffsets.Checked, showInlineFrames.Checked, cachePDB.Checked, outputFilePath.Text, BackgroundCTS);
47+
this.MonitorBackgroundTask(resolverTask);
48+
finalOutput.Text = resolverTask.Result;
49+
}
50+
51+
if (finalOutput.Text.Contains(StackResolver.WARNING_PREFIX)) {
52+
MessageBox.Show(this,
53+
"One or more potential issues exist in the output. This is sometimes due to mismatched symbols, so please double-check symbol paths and re-run if needed.",
54+
"Potential issues with the output", MessageBoxButtons.OK, MessageBoxIcon.Warning);
55+
}
56+
}
57+
58+
private bool ValidateInputs() {
2459
if (string.IsNullOrWhiteSpace(pdbPaths.Text)) {
2560
MessageBox.Show(this,
2661
"Please specify path(s) to PDB files!",
2762
"No symbol path(s) specified", MessageBoxButtons.OK, MessageBoxIcon.Error);
28-
return;
63+
return false;
2964
}
3065

3166
var res = this._resolver.ProcessBaseAddresses(this._baseAddressesString);
3267
if (!res) {
3368
MessageBox.Show(this, "Cannot interpret the module base address information. Make sure you just have the output of the following query (no column headers, no other columns) copied from SSMS using the Grid Results\r\n\r\nselect name, base_address from sys.dm_os_loaded_modules where name not like '%.rll'",
3469
"Unable to load base address information", MessageBoxButtons.OK, MessageBoxIcon.Error);
35-
return;
70+
return false;
3671
}
3772

3873
bool isSingleLineInput = this._resolver.IsInputSingleLine(callStackInput.Text, ConfigurationManager.AppSettings["PatternsToTreatAsMultiline"]);
@@ -80,28 +115,9 @@ private void ResolveCallstacks_Click(object sender, EventArgs e) {
80115
"It is recommended that you first do that. Do you want to exit (select Yes in that case) or continue at your own risk (select No in that case)?",
81116
"Input is large, risk of truncation or errors",
82117
MessageBoxButtons.YesNo)) {
83-
return;
84-
}
85-
86-
List<StackDetails> allStacks = null;
87-
using (BackgroundCTS = new CancellationTokenSource()) {
88-
var allStacksTask = this._resolver.GetListofCallStacksAsync(callStackInput.Text, FramesOnSingleLine.Checked, RelookupSource.Checked, BackgroundCTS);
89-
this.MonitorBackgroundTask(allStacksTask);
90-
allStacks = allStacksTask.Result;
91-
}
92-
if (allStacks.Any()) using (BackgroundCTS = new CancellationTokenSource()) {
93-
var resolverTask = this._resolver.ResolveCallstacksAsync(allStacks, pdbPaths.Text, pdbRecurse.Checked, string.IsNullOrEmpty(binaryPaths.Text) ? null : binaryPaths.Text.Split(';').ToList(),
94-
DLLrecurse.Checked, IncludeLineNumbers.Checked, RelookupSource.Checked,
95-
includeOffsets.Checked, showInlineFrames.Checked, cachePDB.Checked, outputFilePath.Text, BackgroundCTS);
96-
this.MonitorBackgroundTask(resolverTask);
97-
finalOutput.Text = resolverTask.Result;
98-
}
99-
100-
if (finalOutput.Text.Contains(StackResolver.WARNING_PREFIX)) {
101-
MessageBox.Show(this,
102-
"One or more potential issues exist in the output. This is sometimes due to mismatched symbols, so please double-check symbol paths and re-run if needed.",
103-
"Potential issues with the output", MessageBoxButtons.OK, MessageBoxIcon.Warning);
118+
return false;
104119
}
120+
return true;
105121
}
106122

107123
private void DisableCancelButton() {

0 commit comments

Comments
 (0)