Skip to content

Commit 78e99b4

Browse files
authored
Improve symbol re-lookup implementation (#107)
* Simplify symbol re-lookup implementation * Use the address offset and IDiaSession::findLinesByAddr to avoid an expensive loop through the entire symbol address range * Directly invoke ProcessFrameModuleOffset on effective RVA to avoid having to again parse the simulated frame, thereby gaining speed and streamlining code. * Fix some corner cases for single-line input detection * Add specific handling for single-line callstacks in relookup case * Consolidate `else` case processing * Restore method signature to avoid breaking change * Minor refactor * Add test for relookup of single-line stacks /w frame nums * Address CodeQL suggestion
1 parent b2549cd commit 78e99b4

4 files changed

Lines changed: 67 additions & 70 deletions

File tree

Engine/StackDetails.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ public class StackDetails {
88
private string _annotation, _callStack, _resolvedStack;
99
private readonly string _stackKey;
1010
private readonly bool _framesOnSingleLine;
11+
private readonly bool _relookupSource;
1112

12-
public StackDetails(string callStack, bool framesOnSingleLine, string annotation = null, string stackKey = null) {
13+
public StackDetails(string callStack, bool framesOnSingleLine, string annotation = null, string stackKey = null, bool relookupSource = false) {
1314
this._annotation = annotation;
1415
this._stackKey = stackKey;
1516
this._framesOnSingleLine = framesOnSingleLine;
17+
this._relookupSource = relookupSource;
1618
this._callStack = System.Net.WebUtility.HtmlDecode(framesOnSingleLine ? Regex.Replace(callStack, @"\s{2,}", " ") : callStack);
1719
_stackKey = stackKey;
1820
}
@@ -27,7 +29,8 @@ public string[] CallstackFrames {
2729
// sometimes we see call stacks which are arranged horizontally (this typically is seen when copy-pasting directly
2830
// from the SSMS XEvent window (copying the callstack field without opening it in its own viewer)
2931
// in that case, space is a valid delimiter, and we need to support that as an option
30-
var delims = this._framesOnSingleLine ? new char[3] { ' ', '\t', '\n' } : new char[1] { '\n' };
32+
var delims = this._framesOnSingleLine ? new char[] { '\t', '\n' } : new char[] { '\n' };
33+
if (!this._relookupSource && this._framesOnSingleLine) delims = delims.Append(' ').ToArray();
3134
return this._callStack.Replace("\r", string.Empty).Split(delims);
3235
}
3336
}

0 commit comments

Comments
 (0)