Show The Command Line of Valgrind Used in Eclipse CDT - profile

I'm using valgrind for profiling/memchecking my application in Eclipse CDT (Indigo).
After profiling it with memcheck in Eclipse, I found two "possibly lost"s (both from libraries that are out of my control). So I want to add them to my suppressions list.
I then ran the same binary using valgrind in command line:
valgrind --leak-check=full --gen-suppressions=all myapp --arg1 --arg2
To my supprise, the two "possibly losts"s are not showing up. (if they show up, I could just add them to my suppressions list in Eclipse)
I'm wondering what options are passed to valgrind in Eclipse profiling. But I don't know how to show the command line of valgrind when profiling in Eclipse.
Please help me out. Thanks.
Peter

I figured it out myself. Actually, it's very simple, and I don't know why I could not think of this before:
On the command line:
plee#pleeUbuntu:~$ ps -ef | grep valgrind
plee 24548 17479 91 12:43 ? 00:00:14 /usr/bin/valgrind.bin --tool=memcheck -q --log-file=/home/plee/EclipseCDT-IndigoWorkspace/.metadata/.plugins/org.eclipse.linuxtools.valgrind.launch/valgrind_%p.txt --trace-children=no --child-silent-after-fork=yes --run-libc-freeres=yes --demangle=yes --num-callers=20 --error-limit=yes --show-below-main=no --max-stackframe=2000000 --dsymutil=yes --suppressions=/home/plee/valgrind_suppressions.supp --leak-check=yes --show-reachable=no --leak-resolution=low --freelist-vol=10000000 --workaround-gcc296-bugs=no --partial-loads-ok=no --undef-value-errors=yes --track-origins=no MyProgramBinary --arg1 --arg2

Related

How to use tar + pbzip2 with Jenkins

I've been trying to find ways to cut my Jenkins build time as much as possible, and thanks to this helpful SO post, I found pbzip2: Utilizing multi core for tar+gzip/bzip compression/decompression
Works great! A 6 min compression time was brought down to 2 mins on my machine with the following:
tar -v -c --use-compress-program=pbzip2 -f parallel.tar.bzip2 myapplication.app
But Jenkins just barfs with a Execute Shell task where I put in the above command:
+ tar -v -c --use-compress-program=pbzip2 -f parallel.tar.bz2 myapplication.app
a myapplication.appBuild step 'Execute shell' marked build as failure
The fact that the "Build step" line is getting mashed together with the output from the tar tells me it might be a background process issue that tar/pbzip2 is introducing.
I've tried introducing a #!/bin/bash -xe and get the same results. I've tried wrapping the tar command in an if statement. I've also tried putting tar in a background thread itself with & and waiting for it. Same result.
Is there any techniques I could implement to help the Jenkins process out?
Found out that even though I can run this command as the jenkins user through command line, pbzip2 wasn't defined in the PATH for the Jenkins job. Pretty misleading since there wasn't useful output.

bash script -> ps read nothing of a command launch within the script

I'd like to understand why when I execute the following command in my terminal it works, but when I run through a script it doesn't
the command when I run it in my terminal
./tparente & ps --no-headers -C tparente -o rss,vsz >> "mem_results"
The mem_result file has the rss and vsz written in it.
The command when I run it through my terminal is slightly modified, it is written like this:
sh ~/Documents/tparente & ps --no-headers -C tparente -o rss,vsz >> "mem_results"
There's an echo command that write some text in mem_results before the aforementioned command, those works.
And if I remove the no header flag, it writes the header in the file but not the result.
I know the script is run, because it produce a file at the end.
This has been bugging me for a couple hours now.
Thank you
Alex.
I think I may have found the answer.
After trying a couple of configuration of the command line: this one works:
./tparente & ps --no-headers -C tparente -o rss,vsz >> "mem_results"
The difference is subtle (there's no "sh")
This line is from the script; what I noticed is when I tried to run the script on it's and run a ps command in another terminal, the tparente process was is there. I don't know why, but my instinct told me to remove the sh and I did and it works.
If anyone has a proper explanation go ahead :)

bash --debugger does not work on with bash 4.3 on a script with no arguments after installing bashdb

I installed bashdb on fedora 21 which uses bash 4.3 . I need to run using --debugger because I want $0 to be set correctly to the name of the script rather than bashdb.
bash --debugger my.bash
But the script is just executed, there is no debug session. On the other hand running:
bash --debugger my.bash ""
works fine.
What am I doing wrong?
This is a bug that I think was introduced in bash 4.3: Wed Feb 26 09:36:43 2014 -0500 Bash-4.3 distribution sources and documentation
The code added that causes this is:
if (debugging_mode && locally_skip_execution == 0 && running_setuid == 0 && dollar_vars[1])
start_debugger ();
I have posted a bug report on this. See http://lists.gnu.org/archive/html/bug-bash/2015-04/msg00183.html
The short story in the above thread is that although bash versions 4.3 up to 4.3.33 have this bug, in the next release after 4.3.33 (sometime after April 2015), this bug will be fixed.
When you use bash --debugger, the debugger has to be installed in the location that bash expects. Although the configure script tries to figure this out, many times it gets this wrong. To see where bash thinks the debugger should be installed, run:
strings /bin/bash | grep bashdb
On Ubuntu, the answer I got was: /usr/share/bashdb/bashdb-main.inc. So bashdb is expected to be installed in /usr/share/bashdb. Using this, then run configure like this:
/bin/bash ./configure -with-bashdb-main.inc=/usr/share/bashdb/bashdb-main.inc

Simple bash problem related to executing command after previous has stopped (I am not programmer)

#!/bin/sh
xmodmap -e "keycode 49 = equal plus"
cd /media/5F53-7973/BGTrilogy/
wine ./bgmain.exe
xmodmap -e "keycode 49 = dead_caron dead_tilde dead_caron dead_tilde notsign notsign"
Basically what I want from it is that the last entry would only run after I quit wine ./bgmain.exe.
What's the most foolproof way to do it?
Try adding wait on a line after the wine command.

How to Profile a C-Program in a Loop of Shell Script, Using Shark on Mac?

I have a question about Shark-profiling on mac.
Say if I have a C-program, compiled with:
gcc -o mycprog mycprog.c -g -pg
and also I have a shell script something like:
for file in ($SomeDirectory)
do
mycprog $file
done
I need to profile the average performance for all files in $SomeDirectory.
Where should I put the shark -i command? Thanks.
This is not a great approach, for various reasons - ideally you should modify your program's outer loop so that it can process all the files on the command line, then you can just do everything in one run:
$ shark -i
$ mycprog $SomeDirectory/*
If you can't do that then you will need to set your Shark configuration for system-wide profiling and start profiling before your bash loop and stop profiling afterwards. When you subsequently view the profile in Shark you'll be able to filter out the processes that you're not interested in.
Firstly open Shark (the GUI app), set up your configuration and enable remote control (Sampling => Programmatic). Make sure you have Time Profile and Everything selected.
Then from the command line:
$ chudRemoteCtrl -s "mycprog"
$ sleep 1
$ for f in $SomeDirectory/*
$ do
$ mycprog $SomeDirectory/$f
$ done
$ chudRemoteCtrl -e

Resources