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

windows平台X86下无法打印出异常时的栈调用信息 #326

Open
bigbao9494 opened this issue May 16, 2023 · 2 comments
Open

windows平台X86下无法打印出异常时的栈调用信息 #326

bigbao9494 opened this issue May 16, 2023 · 2 comments

Comments

@bigbao9494
Copy link

windows平台X86下无法打印出异常时的栈调用信息(X64没有此问题),只打印了2行
F0516 17:24:33.963] Error: EXCEPTION_ACCESS_VIOLATION
778F75C4 (ntdll): (filename not available): RtlGetAppContainerNamedObjectPath

测试代码:
#include "co/log.h"
#include "co/cout.h"
#include "co/time.h"

DEF_bool(perf, false, "performance testing");
int nested_log() {
DLOG << ">>>> nested log..";
return 123;
}
void raise_error()
{
char* p = NULL;
p = 0x11;
}
int main(int argc, char
* argv) {
flag::parse(argc, argv);
FLG_cout = true;

if (FLG_perf) {
    // test performance by writting 100W logs
    co::print("print 100W logs, every log is about 50 bytes");

    co::Timer t;
    for (int k = 0; k < 1000000; k++) {
        LOG << "hello world " << 3;
    }
    int64 write_to_cache = t.us();

    log::exit();
    int64 write_to_file = t.us();

    co::print("All logs written to cache in ", write_to_cache, " us");
    co::print("All logs written to file in ", write_to_file, " us");

} else {
    // usage of other logs
    DLOG << "This is DLOG (debug).. " << 23;
    LOG  << "This is LOG  (info).. " << 23;
    WLOG << "This is WLOG (warning).. " << 23;
    ELOG << "This is ELOG (error).. " << 23;
    //FLOG << "This is FLOG (fatal).. " << 23;
    LOG << "hello " << nested_log() << "  " << nested_log();
    TLOG("co") << "hello co";
    TLOG("bob") << "hello bob";
}

raise_error();
return 0;

}

@idealvin
Copy link
Owner

编译时,需要添加调试信息,参考 test/stack.cc,

    if test[1] == "stack" then
        set_symbols("debug")    -- dbg symbols
        set_strip("none")
        set_optimize("none")
    end

@bigbao9494
Copy link
Author

bigbao9494 commented May 17, 2023

感谢回复
没太懂您的意思,我是用的cmake构建的,相同条件下为什么编译成X64可以打印出异常栈信息,而X86不行。
x86的构建需要单独添加编译条件 ?

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

2 participants