Can't analyse the output (the profile file) of gperftools profiler - c

I'm using gperftools for analysing my C code. An as a result I can't analyze the profile file using pprof application.
$ gcc -g prog.c -o prog -lprofiler
$ export CPUPROFILE=info.prof
$ ./prog
Inside main()
Inside func1
Inside new_func1()
Inside func2
PROFILE: interrupts/evictions/bytes = 1133/0/300
$ ls
info.prof prog prog.c
$ ls -lah info.prof
-rw-rw-r-- 1 mm mm 2.6K Jun 6 09:36 info.prof
$ pprof info.prof prog
Reading Profile files in profile.*
Error: Could not open profile.0.0.0: No such file or directory
profile.ftab: No such file or directory
$
What do I wrong? What's the profile.ftab file?

You're not using the correct 'pprof' tool. In particular, you're using http://www.cs.uoregon.edu/research/tau/docs/newguide/bk03ch01s08.html (which is totally unrelated), whereas you need the one here: https://code.google.com/p/gperftools/ I had the same issue and solved the problem by downloading the gperftools' source, building it, and using ./src/pprof

I just ran into this and I think it is worth mentioning how to deal with this in recent versions of Ubuntu (18.04 specifically).
When one tries to run the pprof command, the system suggests installing the tau package:
Command 'pprof' not found, but can be installed with:
sudo apt install tau
Do not install that package though, because it is entirely unrelated as David Carney pointed out in his answer. Install the google-perftools package instead, but be aware that the executable in it is called google-pprof instead of just pprof.

You installed the wrong pprof.
If you already have golang installed. You can install pprof using go.
Just do,
go get github.com/google/pprof
Also install graphviz if you want to generate PDFs using
sudo apt-get install graphviz

Related

Having trouble using the mingw32-make command to build json-c library

Here is the instructions: https://github.com/json-c/json-c/blob/master/README.md#build-instructions--
This is the first time I've ever built from source.
I'm on Windows 10 and I used CMake to build.
I did this and it all worked fine:
$ git clone https://github.com/json-c/json-c.git
$ mkdir json-c-build
$ cd json-c-build
$ cmake ../json-c
But I don't understand this part:
$ make
$ make test
$ make USE_VALGRIND=0 test # optionally skip using valgrind
$ make install
Can someone explain to me what these lines do?
I installed mingw32-make but when I run mingw32-make on its own like in the this tutorial it just says:
mingw32-make: *** No targets specified and no makefile found. Stop.
Do I need to create a Makefile? It doesn't say anywhere in the installation notes to do this but I cannot get past this step, what am I doing wrong?

How can I run GCC into WSL?

So, Windows System on Linux seems to be an inovative light-weight substitute for a virtual machine, especially when it comes to learning Linux. Nevertheless, for me WSL seems to have a little more complicated organization from a VM when it comes to file management. For example, in WSL the data are stored in
C:\Users\<username>\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\
as shown here.
Of course my first try to install GCC was to type in:
sudo apt install gcc
,but after typing
gcc --version
the output was :
Command 'gcc' not found, but can be installed with:
sudo apt install gcc
After that, I tried installing GCC using the following commands as shown here :
$ sudo apt-get update && sudo apt-get upgrade -y
$ sudo apt autoremove -y
$ sudo apt-get install gcc -y
but I end up getting the same output.
On the other hand, I already had installed TDM GCC on Windows and used sudo in VM to install it also there (successfully:).
Like a lot of people, I want to substitute the use of my virtual machine with WSL in order to be able to develop in C without overloading my RAM my questions are :
Can you count out for me how many times have I downloaded GCC files?
Why the folder that I was supposed to be downloading the gcc files in is shown to be empty?
Where are the downloaded files being stored?
How can get gcc fired up?
Is there any way to use the gcc I had on Windows to compile C using the WSL terminal?
I think these questions come from the fact that I cannot understand how WSL file system interacts with Windows. They are a bit more generic on purpose because I want you to have a lot of "answering" freedom.
Please help me out of this one! I don't want to be forced to use a virtual machine and run out of RAM almost every time!

Compiling through macOS Terminal, fatal error: stdio.h: No such file or directory

So was trying to compile a c file (via a makefile) and got the "fatal error: stdio.h: No such file or directory" . This compiles on just fine via cygwin and a remote linux box just not my mac (so the files are okay).
I have installed the mac command line tools as mentioned in this question. When I do gcc --version I am getting 5.3 but if i do brew info gcc i get 8.2. When I do a find through terminal I can the file, so not sure what is up.
If you run:
which gcc
you will get /usr/bin/gcc which is the compiler supplied by Apple as part of macOS.
Presumably, since you mention homebrew, you mean to use the compiler installed by homebrew. So, you need to look in /usr/local/bin and see what homebrew has installed:
ls -l /usr/local/bin/gcc*
lrwxr-xr-x 1 mark admin 29 17 Sep 10:53 /usr/local/bin/gcc-8 -> ../Cellar/gcc/8.2.0/bin/gcc-8
So, the answer to your question is:
firstly, you need to have /usr/local/bin at the start of your PATH, and
secondly, you need to use the following command to compile:
gcc-8 main.c -o main
try running following:
xcode-select --install
See:
GCC fatal error: stdio.h: No such file or directory
for details.
With Mojave and XCODE 10, the problem is that the "include" folder is no longer automatically included when you install the command line tools. Instead, you need to do an "open" on /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
That solved the identical problem for me, anyway.
I ran into this issue and this is how I resolved it.
softwareupdate --all --install --force
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
Basically developer framework is likely to be broken. But simply running xcode-select --install may not work because it will say the xcode developer tools are already installed (despite its broken status). So I had to completely wipe out any existing installation and install the developer framework again.
FYI if everything is installed correctly, the header files should be found at:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include

error when compiling testfiles from installed c-algorithms library

I'm trying to install and test c library c-algorithms from Github.
https://github.com/fragglet/c-algorithms/blob/master/test/test-queue.c
When I try to test the installation from the generated test folder with:
gcc -o test-arraylist `pkg-config --cflags --libs libcalg-1.0` test-arraylist.c
I get the following error massage:
test-arraylist.c:30:23: fatal error: arraylist.h: No such file or directory
compilation terminated.
I use a Vagrant box: ubuntu/xenial32 with Ubuntu 14.04.5 LTS
Prior to installation of c-algorithms:
sudo apt-get install autoconf
sudo apt-get install libtool
sudo apt-get install pkg-config
To install the library I have done following:
sudo ./autogen.sh
sudo ./configure
sudo make
sudo make install
Any help would be highly apriciated
The test-arraylist.c has line #include "arraylist.h" but it is under the libcalg subdirectory not directly in the include path.
libcalg subdir should be added to the include path or you have to modify the include like #include "libcalg/arraylist.h"
If you want only run the tests, then run the
sudo make check from the build root (in your case it is the source root)
This is probably going to be stomped on by process-fetishizers.
But.
When you build in a Unix/Linux operating system (and derivatives like RTEMS), you are building off other people's libraries - so you need those libraries and their header files ( just like c-alg... ) installed in locations that your compiler can find.
To find a file that is associated with a package, use dpkg as explained here:
https://askubuntu.com/questions/481/how-do-i-find-the-package-that-provides-a-file
But you have another problem you might not be aware of. You are trying to compile a test program using a gcc command when the software uses GNU autoconf automake and probably libtool to function PROPERLY.
Perhaps you don't understand you need to make sure autoconf, automake, and then libtool find the right configuration from one directory system to another. Fedora puts files in differing spots from Ubuntu distros.
Instead run:
autoreconf -fvi
first in the top level directory and see if this finds your header file.
THEN you run
./configure
and then
make test/check
(whichever it uses, some use recipe "all-tests", etc.)
make all
This would make all if your system is ready to handle them.

c - can't compile with <sys/times.h> ubuntu

I have 64bit ubuntu installed, and I am trying to compile a code with times.h however I keep getting sys/times.h No such file or directory
What I have tried so far
1. installing libc6-dev-i386, g++-multili, and libc6 and libc6-dev (Even though it is already installed)
2. I swapped <sys/times.h> to </usr/include/sys/times.h> and now I am getting features.h No such file or directory error
Question:
It is weird how it accepts </usr/include/sys/times.h> instead of <sys/times.h>, and help?
EDIT: I can access times.h, if it matters
I would recommend running:
$ locate /sys/time.h | grep include
Using the output you can determine what to do next:
If there is a file named /usr/include/<x86_64 or i386>-linux-gnu/sys/time.h, then simply run: $ sudo ln -s /usr/include/<x86_64 or i386>-linux-gnu/sys /usr/include/sys. This will direct the compiler to the right file if it checks . This seems to be what you are doing manually.
If there is no relevant output, then try downloading build-essential. It may be that something else is missing. $ sudo apt-get update; sudo apt-get install build-essential
Let me know if this helps!

Resources