gimelfarb / productionstacktrace Goto Github PK
View Code? Open in Web Editor NEWWithout deploying PDBs, generate a .NET exception stack trace that can be processed to retrieve source file and line number info
License: Other
Without deploying PDBs, generate a .NET exception stack trace that can be processed to retrieve source file and line number info
License: Other
The linenumber isn't inside the ExceptionReporting.GetExceptionReport(ex)).
Where do i find it?
Hello,
ExceptionReportInterpreter fails due to an error in s_regexStackTraceLine field.
// Regex for the stack frame line, it looks like this:
// <space> at AssemblyName!0x<hex method token>!Namespace.Class.Method(<arg types>) +0x<hex IL Offset>
// at MyAssembly!0x1234567!MyAssembly.Class1.A() +0xc
private static readonly Regex s_regexStackTraceLine =
new Regex(@"^\s*at\s+(?<Assembly>[^<>:\""/\\|?*\u0000-\u001f!]+)!0x(?<MDToken>[0-9a-f]+)!(?<Method>[^\(]+)\((?<Args>[^\)]*)\)\s+\+0x(?<ILOffset>[0-9a-f]+)", RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
but "at" word is wrong if the culture is not en-en because:
/// <summary>
/// Main reporting entry point.
/// </summary>
public static class ExceptionReporting
{
...
/// <summary>
/// Internal logic - adapted from Environment.GetStackTrace from .NET BCL.
/// </summary>
/// <param name="ex"></param>
/// <param name="ctx"></param>
/// <param name="builder"></param>
private static void GetStackTraceEx(Exception ex, ExceptionReportingContext ctx, ref StringBuilder builder)
{
var st = new StackTrace(ex);
var strAt = GetRuntimeResourceString("Word_At") ?? "at";
Best regards,
Filippo.
I've tried to use the Analyze.Library nuget package to extract line number infos from the exception report but couldn't - I get the instruction causing the exception but no line numbers.
Here's a sample of what I am doing - D:\symbols\ contains the latest symbols (which I copy-pasted from the debug/ folder)
catch (Exception ex)
{
var text = ExceptionReporting.GetExceptionReport(ex);
var writer = new StringWriter();
var pst = new ProductionStackTrace.Analyze.ExceptionReportInterpreter();
pst.SymbolPaths.Add("D:\\symbols");
pst.Translate(new StringReader(text), writer);
MessageBox.Show(writer.GetStringBuilder().ToString());
}
Here's the output:
System.NullReferenceException: Object reference not set to an instance of an object.
at animationTest.TestObj..ctor(String test)
And here's the exception report:
System.NullReferenceException: Object reference not set to an instance of an object.
at animationTest!0x06000009!animationTest.TestObj..ctor(String test) +0x9
==========
MODULE: animationTest => animationTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null; G:3b9e8688578a4f8e83f09c8f3f6a5d45; A:1
I'm most likely doing something stupid here :) but I've spent quite some time going through the examples and I really have no idea where to go next - sorry for disturbing you directly.
Hello,
running build.cmd deploy I get some errors.
I'm not able to create nuget packages because not all builds are completed before creating nuget packages.
I have attached my console output.
I'm using msbuild v.14.0. I suppose that something in the order of compilation was wrong.
Best regards,
Filippo.
Whilst testing the nuget package against symbols we had pushed via symstore
to a local drive we noticed that when we called Convert-ProductionStackTrace
on a trace for where there should be no symbols - it located a line for each offset - it seemed to be using the incorrect symbols (possibly latest?).
Reviewing the code we note that SymSetOptions was only being called with SYMOPT_DEBUG. We were thinking that SYMOPT_EXACT_SYMBOLS would also be useful to ensure that we don't get false positives.
What do you think?
Do you have (or intend) to strong name the assembly - it would really help its adoption as quite a few places have strong naming as a requirement?
Hi,
First of all I want to thank you for your great work on this project. I'm having some issues with the production not displaying the GUID and Age in the stacktrace.
When I deploy the application with debug configuration, everything is fine and I'm getting the GUID + age field. But when I deploy the application for release (obfuscated), I can't seem to get the fields into the stacktrace, it's displaying the MODULE: line but without the "G:{GUID} A:{AGE} fields.
What am I doing wrong here?
Thanks.
Hi! Thank you for sharing your code. But unfortunately it seems not to work here.
This is my Program.cs:
Program.cs.txt
And this is the project file
Tests.ProductionStackTrace.csproj.txt
I have successfully added the PDB to the symbol store and added it in VS:
But yet no luck:
What's the issue?
Thanks in advance!
I don't know how to use the third method About 【Use with a logging framework】 .Can you provide more detailed information?
I Want Use log4net and your Exception Frame,but I don't understhand how to use,can you provide a example or detailed information about it?
Any help will appreciate!
I am not able to convert a full log file. It converts only the first log in the file. The rest of the log information is not converted. What am I missing?
1.txt
Hello,
I'm using dbghelp.dll version 6.2.9200.16384. The function FindPdbFile returns null because DbgHelp.SymFindFileInPath fails.
I noticed that when info.PdbGuid is passed to FindPdbFile it changes value like in the second picture.
I don't know if this is an issue but I need more help to understand if SymFindFileInPath fails or if there are some errors in passed parameters.
Thank you for your help,
Filippo.
I had an instance where modulePtr was -1 when entering FromUnmanagedPtr(), which threw an exception.
I added the following code to ReadAssemblyDebugInfo()
PeHeaders^ peHdrs = PeHeaders::FromUnmanagedPtr(modulePtr);
if( !peHdrs )
return nullptr;
....
and the following to FromUnmanagedPtr
static PeHeaders^ FromUnmanagedPtr(IntPtr memoryPtr)
{
if( (int)memoryPtr == -1 )
{
return nullptr;
}
....
This resolved the issue.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.