Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only 1 line of callstack is shown in my derived class. #55

Open
shaovoon opened this issue Sep 27, 2022 · 0 comments
Open

Only 1 line of callstack is shown in my derived class. #55

shaovoon opened this issue Sep 27, 2022 · 0 comments

Comments

@shaovoon
Copy link

shaovoon commented Sep 27, 2022

Thank you for sharing your wonderful StackWalker library! I encountered an issue which I am not sure if it is a bug. Can you kindly take a look into it?

I downloaded the code from the master branch and used the latest VS2019 to build. When I derived my MyStackWalker class like shown in the README

class MyStackWalker : public StackWalker
{
public:
	MyStackWalker() : StackWalker() {}
protected:
	virtual void OnOutput(LPCSTR szText) override {
        printf("%s\n", szText);
        StackWalker::OnOutput(szText);
	}
};

And I called it this way.

int DummyFunc(int a, int b)
{
    MyStackWalker sw; 
    sw.ShowCallstack();
    return a + b;
}

Only 1 line of callstack is shown on my commandline console.

C:\Users\Shaovoon.Wong\source\repos\TestCallstack\StackWalker.cpp (1140): StackWalker::ShowCallstack

And the ShowCallstack() returns from the if condition at line 1342 of

https://github.com/JochenKalmbach/StackWalker/blob/master/Main/StackWalker/StackWalker.cpp#L1342

    if (s.AddrReturn.Offset == 0)
    {
      bLastEntryCalled = true;
      this->OnCallstackEntry(lastEntry, csEntry);
      SetLastError(ERROR_SUCCESS);
      break;
    }

But when I use the original StackWalker class like this,

int DummyFunc(int a, int b)
{
    StackWalker sw; 
    sw.ShowCallstack();
    return a + b;
}

I can see all the callstack in Sysinternal's DebugView.

C:\Users\Shaovoon.Wong\source\repos\TestCallstack\StackWalker.cpp (1140): StackWalker::ShowCallstack
C:\Users\Shaovoon.Wong\source\repos\TestCallstack\TestCallstack.cpp (22): DummyFunc
C:\Users\Shaovoon.Wong\source\repos\TestCallstack\TestCallstack.cpp (28): main
D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl (79): invoke_main
D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl (288): __scrt_common_main_seh
D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl (331): __scrt_common_main
D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp (17): mainCRTStartup

But I wish to write the callstack into my log and have my customer send it back to me. I have no access to customer machine and cannot possibly ask him/her to debug on my behalf.

Please kindly advise.

Thank you in advance.

Update: I cannot reproduce this problem on my home PC with VS2022.
Update again: It happens on my home PC with VS2022. Looks like it is an intermittent problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant