-->

What do the “+n” values mean at the end of a metho

2020-01-25 09:11发布

问题:

When reading a stack trace like:

[FormatException: Input string was not in a correct format.]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2755599
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +112
   System.Convert.ToInt32(String value) +68

What do the +68, +112, etc. numbers mean. I'm guessing that they're offsets to something. If so, what?

回答1:

It means:

it’s an offset into the native instructions for the method.

Read this for more details.



回答2:

I believe they're offsets into the code of the method - whether IL or JIT-compiled-assembly bytes, I'm not sure...

(Basically they're taking the place of line numbers, which of course aren't available without the pdbs.)



回答3:

it is the byte offset into native code.

With ILDASM you know why.



回答4:

Simply said, a Stack Trace is a reverse chronological listing of functions/methods in a flow, till current code. That is, up until a breakpoint is hit or an exception occurs.

On top of the stack trace listing, is the current method and its details like the Class, Assembly, filename, etc.

Following lines, list the method from where the previous method (one in the above line) was called. Going down the list, this continues to show the call stack, all the way back to the start of the program.

All these details from Stack Trace is beneficial, as it lists the origin of a method call and the intermediate methods/functions till it reached the current line of code. This is very much helpful because, if there are multiple ways to access the current method, Stack Track lists the exact flow followed.



标签: c# .net