我在理解Valgrind输出时遇到了一些麻烦:
1> “自动生成的adb文件中出现了”无效的写入大小4“,
return (gnat_exit_status); -- this is line 314 of b~main.adb
并且gnat_exit_status的定义如下:
gnat_exit_status : Integer;
pragma Import (C, gnat_exit_status);
2 - ; “以信号11(SIGSEGV)的默认动作终止的过程”这是valgrind还是我的程序?我从valgrind得到139的返回值,但是当自己运行main时,我得到0,这是我所期待的!
memcheck的完整输出:
$ valgrind ./main
==2844== Memcheck, a memory error detector
==2844== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==2844== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==2844== Command: ./main
==2844==
==2844== Invalid write of size 4
==2844== at 0x804BA2F: main (b~main.adb:314)
==2844== Address 0xbee56294 is not stack'd, malloc'd or (recently) free'd
==2844==
==2844==
==2844== Process terminating with default action of signal 11 (SIGSEGV)
==2844== Access not within mapped region at address 0xBEE56294
==2844== at 0x804BA2F: main (b~main.adb:314)
==2844== If you believe this happened as a result of a stack
==2844== overflow in your program's main thread (unlikely but
==2844== possible), you can try to increase the size of the
==2844== main thread stack using the --main-stacksize= flag.
==2844== The main thread stack size used in this run was 8388608.
==2844==
==2844== HEAP SUMMARY:
==2844== in use at exit: 0 bytes in 0 blocks
==2844== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==2844==
==2844== All heap blocks were freed -- no leaks are possible
==2844==
==2844== For counts of detected and suppressed errors, rerun with: -v
==2844== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 19 from 8)
Segmentation fault
$
任何帮助感谢:)
NWS
答案 0 :(得分:2)
我从大学开始就没有使用Valgrind,但有一些事情可以让你以正确的方式指出你。
首先,我知道如何编译编程有所作为。您应该使用-g标志而不使用-O#(优化)。另外,我总是使用-v运行Valgrind,因此它输出最多信息(大量信息)。
查看此页面: http://www.redhat.com/magazine/015jan06/features/valgrind/
回合中途是标题为“在运行valgrind之前”和“如何阅读valgrind错误报告”的部分将帮助您。