valgrind

memory profiling for C program

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Need to do a memory profiling of my C application .. It should include footprint size and a RAM size ... for example if my application is like below .. #include <stdio.h> int global = 10; /* initialized global variable */ int test_code(void) { static int i = 100; /* Initialized static variable*/ return 0; } Output: [putta@linux]$ gcc memory-layout.c -c memory-layout [putta@linux]$ ls -ltrh memory-layout.o 760 Nov 9 18:26 memory-layout [putta@linux]$ size memory-layout.o text data bss dec hex filename 67 8 0 75 4b memory-layout.o So now which

Debugging a core produced by valgrind

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Valgrind produced a vgcore.NNNN file -- how do I debug the core using GDB? Do I need to use the original executable and supply the core, or is there some other way to do it? Using valgrind as the root executable doesn't seem to work, and using the executable that was being run under valgrind directly in GDB with the core seems to produce bad backtraces. 回答1: This works fine for me: gdb ./a.out vgcore.21650 and that's how you are supposed to use the vgcore. If your program corrupted stack before crashing, then obviously you wouldn't get good

Cross-compiling Valgrind for ARM

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to cross-compile VALGRIND to run on Freescale i.MX278 (ARM 9) running Linux. I have the tool chain provided by Freescale itself. I have already set the PATH variable to tool chain path. I'm using following command further: $ export CROSS_COMPILE=arm-fsl-linux-gnueabi- $ export CC=${CROSS_COMPILE}gcc $ export CPP=${CROSS_COMPILE}cpp $ export CXX=${CROSS_COMPILE}g++ $ export LD=${CROSS_COMPILE}ld $ export AR=${CROSS_COMPILE}ar $ ./configure --target=arm-fsl-linux-gnueabi \ --host=armv7-fsl-linux-gnueabi \ --prefix=/opt/valgrind \ CFLAGS

valgrind, profiling timer expired?

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I try to profile a simple c prog using valgrind: [zsun@nel6005001 ~]$ valgrind --tool=memcheck ./fl.out ==2238== Memcheck, a memory error detector ==2238== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al. ==2238== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info ==2238== Command: ./fl.out ==2238== ==2238== ==2238== HEAP SUMMARY: ==2238== in use at exit: 1,168 bytes in 1 blocks ==2238== total heap usage: 1 allocs, 0 frees, 1,168 bytes allocated ==2238== ==2238== LEAK SUMMARY: ==2238== definitely lost: 0 bytes

How do I use valgrind to find memory leaks?

匿名 (未验证) 提交于 2019-12-03 08:36:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How do I use valgrind to find the memory leaks in a program? Please someone help me and describe the steps to carryout the procedure? I am using Ubuntu 10.04 and I have a program a.c , please help me out. 回答1: Try this: valgrind --leak-check=full -v ./your_program As long as valgrind is installed it will go through your program and tell you what's wrong. It can give you pointers and approximate places where your leaks may be found. If you're segfault'ing, try running it through gdb . 回答2: How to Run Valgrind I would like to build on RageD's

Why electric fence/Valgrind is unable to catch this buffer-overflow issue?

雨燕双飞 提交于 2019-12-03 08:26:55
I have created a buggy program - buggy.c - this is a buffer-overflow scenario for buffer t. You can see that I am writing more than 5 indexes. It works fine. It never throws me an error. I was wondering, why is it like that? I tried even Valgrind, this also couldn't find this issue. Can you tell me please what is the issue here? void buffer_overflow(void) { int t[5]; int i = 0; for(i = 0; i<=7; i++) { t[i] = i; } /** this will cause buffer overflow **/ printf("Memory_overflow_completed\r\n"); } int main(int argc, char **argv) { buffer_overflow(); return 0; } $gcc -g buggy.c -o buggy.out

Terminate process running inside valgrind

ⅰ亾dé卋堺 提交于 2019-12-03 08:16:48
问题 Killing the valgrind process itself leaves no report on the inner process' execution. Is it possible to send a terminate signal to a process running inside valgrind? 回答1: There is no "inner process" as both valgrind itself and the client program it is running execute in a single process. Signals sent to that process will be delivered to the client program as normal. If the signal causes the process to terinate then valgrind's normal exit handlers will run and (for example) report any leaks.

Ubuntu System Monitor and valgrind to discover memory leaks in C++ applications

試著忘記壹切 提交于 2019-12-03 07:53:29
I'm writing an application in C++ which uses some external open source libraries. I tried to look at the Ubuntu System Monitor to have information about how my process uses resources, and I noticed that resident memory continues to increase to very large values (over 100MiB). This application should run in an embedded device, so I have to be careful. I started to think there should be a (some) memory leak(s), so I'm using valgrind. Unfortunately it seems valgrind is not reporting significant memory leaks, only some minor issues in the libraries I'm using, nothing more. So, do I have to

Memory leak C++

a 夏天 提交于 2019-12-03 06:28:44
问题 I just wrote a code in C++ which does some string manipulation, but when I ran valgrind over, it shows some possible memory leaks. Debugging the code to granular level I wrote a simple C++ program looking like: #include<iostream> #include<cstdlib> using namespace std; int main() { std::string myname("Is there any leaks"); exit(0); } and running valgrind over it I got: ==20943== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 26 from 1) ==20943== malloc/free: in use at exit: 360,645 bytes

Unable to build and install Valgrind on macOS High Sierra

折月煮酒 提交于 2019-12-03 06:06:45
I cannot install Valgrind on macOS High Sierra. It's not available through brew . I've tried with 3.10 . After make install , I get this message: configure: error: Valgrind works on Darwin 10.x, 11.x, 12.x, 13.x and 14.x (Mac OS X 10.6/7/8/9/10) Homebrew says: valgrind: This formula either does not compile or function as expected on macOS versions newer than Sierra due to an upstream incompatibility. Error: An unsatisfied requirement failed this build. Yuriy Lesyo I had the problem like this. So, I found the solving. You should install valgrind by this code brew install --HEAD valgrind I have