2016-03-04 100 views
0

AddressSanitizer默认将所有错误都引发到shell本身,因此我尝试使用以下命令运行我的ASAN build;如何将从Google AddressSanitizer抛出的错误记录到日志文件

>MCTester_ASAN>asan.log 

==15619==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61400000f9d0 at pc 0x46cff2 bp 0x7fffc062cb90 sp 0x7fffc062cb88 
    #0 0x46cff1 in heapOutOfBoundWrite() /home/MemTest/main.cpp:49 
    #1 0x46d68f in main /home/MemTest/main.cpp:116 
    #2 0x7fbd3365bc35 in __libc_start_main (/lib64/libc.so.6+0x1ec35) 
    #3 0x40a0f8 (/x01/exd10/bin/MCTester_ASAN+0x40a0f8) 

ASAN:SIGSEGV 
==15619==ERROR: AddressSanitizer: SEGV on unknown address 0x00000044ff97 (pc 0x00000046cff2 sp 0x7fffc062cba0 bp 0x7fffc062cbb0 T0) 
    #0 0x46cff1 in heapOutOfBoundWrite() /home/MemTest/main.cpp:49 
    #1 0x46d68f in main /home/MemTest/main.cpp:116 
    #2 0x7fbd3365bc35 in __libc_start_main (/lib64/libc.so.6+0x1ec35) 
    #3 0x40a0f8 (/x01/exd10/bin/MCTester_ASAN+0x40a0f8) 

AddressSanitizer can not provide additional info. 
Segmentation fault 

但我仍然得到输出到shell本身而不是日志文件。

如何将输出捕获到日志文件?

回答

2

但我仍然得到输出到shell本身而不是日志文件。

这是因为AddressSanitizerstderr中存在错误,但不在stdout中。 有很多answers为您的问题。

例如:

yourcommand &>filename 
相关问题