bombela / backward-cpp

A beautiful stack trace pretty printer for C++
MIT License
3.68k stars 467 forks source link

Line number in source is off by 1 always #288

Open planetchili opened 1 year ago

planetchili commented 1 year ago

I find that when I look at the snippets, the line indicated is always the next line (skipping whitespace) after the one containing the call.

Stack trace (most recent call last):
#6    Object "", at 00007FFE109B7614, in BaseThreadInitThunk
#5 
   D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp(17): mainCRTStartup
#4 
   D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(331): __scrt_common_main
#3 
   D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(288): __scrt_common_main_seh
#2 
   D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(79): invoke_main
#1 
   C:\Users\Chili\Desktop\cpp\Chil\ConsoleSandbox\Main.cpp(33): main
         30:    chilog.warn(L"huh");
         31:    f();
         32: 
      >  33:    return 0;
         34: }
#0 
   C:\Users\Chili\Desktop\cpp\Chil\ConsoleSandbox\Main.cpp(19): f
         16: void f()
         17: {
         18:    chilog.error(L"oops!");
      >  19: }
         20: 
         21: int main()
         22: {

I see that this is not the case in the screenshots provided in the repo readme. Is there any way to get the resolver to indicate the correct line?

hofmannu commented 3 months ago

I have the same problem that for me on some machines for some reason the stack trace is off by one line. While this is not really an issue in most cases because it is clear where the exception actually comes from, this can be many misleading at times.