can any one tell me how to find the source code line using byte offset (from stack trace) in wp7?
Asked
Active
Viewed 600 times
2
-
...and are you trying to do this on the phone, or analysing a crash dump? – Rowland Shaw May 11 '12 at 07:29
-
got stack trace from APP HUB which has byte offset. I am trying to find the line which caused the crash. XXX.fullprofile.FullProfile_Pivot.horoicon_clicked 224 here 224 is byteoffset but what i need is line number. I am trying to find this in phone – Lydia May 11 '12 at 08:51
-
Have you the PDBs for the exact version the crash dump is for? – Rowland Shaw May 11 '12 at 11:18
-
Same problem here; I do have the PDB. How do they help? – Seva Alekseyev Jun 21 '13 at 15:28
-
Related: http://stackoverflow.com/questions/4886191/find-a-byte-offset-in-a-net-assembly – Seva Alekseyev Jun 21 '13 at 15:48
-
Those offsets are not IL byte offsets (as displayed by ILDASM); seems like they're byte offsets in JIT-compiled native code. – Seva Alekseyev Jun 21 '13 at 15:51
1 Answers
0
This is something Ive used but its not win phone specific - but it might work for you with some tweeking:
private static string lineAndMethod() {
int stack_frame_depth = 5;
StackFrame sf = new StackFrame(stack_frame_depth, true);
while (sf.GetFileName() == null && stack_frame_depth > 0)
sf = new StackFrame(--stack_frame_depth, true);
if (sf.GetFileName() == null) // Failed.
return "";
MethodBase mb_caller = sf.GetMethod();
retrun string.Format("{0}, {1}: {2}]",
Path.GetFileName(sf.GetFileName()),
mb_caller.Name, sf.GetFileLineNumber());
}

Ricibob
- 7,505
- 5
- 46
- 65