作者gwliao (gwliao)
看板NTUGIEE_EDA
标题Re: [转录][问题] 程式码一样 2台电脑跑出来不一样
时间Sun Feb 19 15:21:30 2006
※ 引述《yellowfishie (喵喵喵喵~~~)》之铭言:
: 找到了,是变数没有 initialize 初始值,
: 所以不同的机器会给不同的值,跑出来就不相同了 :)
可以对你比中指吗? #-_-
: 推 Donnie:加 -Wall 就找的到了 02/18 17:05
-Wall是compiling time很好用的参数 :)
不过也是因为只能在compileing time有用, 所以後人才发展Valgrind.
Valgrind是针对running time来找bug.
: 推 nextme:ㄟ..... 请问一下 -Wall是什麽呀? 02/18 17:29
是盖墙壁的意思, gcc会教你盖墙壁.
: 推 moonshade:warning all 02/18 22:43
: 推 yellowfishie:它是 class 里的变数,wall 不会警告 02/18 23:03
抓memory相关的问题, 推荐用Valgrind.
http://valgrind.org/
Valgrindk有这些功能:
Memcheck:
* Use of uninitialised memory
* Reading/writing memory after it has been free'd
* Reading/writing off the end of malloc'd blocks
* Reading/writing inappropriate areas on the stack
* Memory leaks -- where pointers to malloc'd blocks are lost forever
* Mismatched use of malloc/new/new [] vs free/delete/delete []
* Overlapping src and dst pointers in memcpy() and related functions
Addrcheck:
is a lightweight version of Memcheck.
programs run about twice as fast as they do on Memcheck,
and a lot less memory is used.
( 对, Memcheck很慢很慢.....zzzzZZZZZ )
Cachegrind:
is a cache profiler.
Helgrind:
finds data races in multithreaded programs.
後面两个应该很少有机会用到. 所以就不贴太多message了.
不过一开始的错误讯息会让你退却, 因为错误太多了...感觉自己的程式像未爆蛋一样.
( 我就是退却的人之一, 真的很多 Orz )
最後......Valgrind只支援Linux. Sun? 忘了它吧. XD
The Valgrind 3.0.X series supports the following platforms.
* x86/Linux: support is mature and almost complete.
* AMD64/Linux: support is new but fairly complete.
* PPC32/Linux: support is new, incomplete, but improving.
You must be running Linux kernel 2.4.X, 2.5.X or 2.6.X, and glibc 2.2.X,
2.3.X or 2.4.X. That covers the vast majority of installed systems at present.
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.230.125