输出如下:
niklas@emerald:~/Arbeitsfläche/spyr/bin/DeBUG$valgrind --tool=memcheck --leak-check=full --show-reachable=yes ./spyr[...]==4404== InvalID write of size 4==4404== at 0x8048849: sp_ParticleBuffer_init (in /home/niklas/Arbeitsfläche/spyr/bin/DeBUG/spyr)==4404== by 0x8048BFC: sp_ParticleSystem_createParticle (in /home/niklas/Arbeitsfläche/spyr/bin/DeBUG/spyr)==4404== by 0x8048691: main (in /home/niklas/Arbeitsfläche/spyr/bin/DeBUG/spyr)==4404== Address 0x422a0a0 is 4 bytes after a block of size 4 alloc'd==4404== at 0x402BE68: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)==4404== by 0x8048BC1: sp_ParticleSystem_createParticle (in /home/niklas/Arbeitsfläche/spyr/bin/DeBUG/spyr)==4404== by 0x8048691: main (in /home/niklas/Arbeitsfläche/spyr/bin/DeBUG/spyr)==4404== ==4404== InvalID write of size 4==4404== at 0x8048865: sp_ParticleBuffer_init (in /home/niklas/Arbeitsfläche/spyr/bin/DeBUG/spyr)==4404== by 0x8048BFC: sp_ParticleSystem_createParticle (in /home/niklas/Arbeitsfläche/spyr/bin/DeBUG/spyr)==4404== by 0x8048691: main (in /home/niklas/Arbeitsfläche/spyr/bin/DeBUG/spyr)==4404== Address 0x422a09c is 0 bytes after a block of size 4 alloc'd==4404== at 0x402BE68: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)==4404== by 0x8048BC1: sp_ParticleSystem_createParticle (in /home/niklas/Arbeitsfläche/spyr/bin/DeBUG/spyr)==4404== by 0x8048691: main (in /home/niklas/Arbeitsfläche/spyr/bin/DeBUG/spyr)[...]
我看到了输出,其中行号在文件名后面的双冒号后显示.即/ home / niklas /Arbeitsfläche/ spyr / bin / DeBUG / spyr:23或类似.
我怎样才能启用它?
仅供参考,这是sp_ParticleBuffer_init函数.
int sp_ParticleBuffer_init(sp_ParticleBuffer* buffer,sp_Uint32 buffer_size,int init_zero) { size_t size = sizeof(sp_Particle) * buffer_size; buffer->next = null; buffer->array = (sp_Particle*) malloc(size); buffer->alive_count = 0; if (!buffer->array) return SPYR_ALLOCFailed; if (init_zero) memset((voID*) buffer->array,size); return SPYR_NOERR;}解决方法 您需要在二进制文件中包含调试信息.如果您正在使用gcc,请传递-g标志. 总结
以上是内存溢出为你收集整理的c – Valgrind不显示行号全部内容,希望文章能够帮你解决c – Valgrind不显示行号所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)