Why do I get "has arcs from exit block" messages when running gcov? - gcov

I am running gcov to measure coverage but I get "has arcs from exit block" message for each of the functions I use in the c code. Is there any problem with this message? Should I ignore them?

This can mean that your gcno file has been generated with newer/different version of gcc compiler. See if at the beginning you have also warning like 'version '404*', prefer '402*' If yes, solution below:
Check if g++ --version and gcov --version give you the same results. If not, update your tools like sudo apt-get install gcov, or specific version like `sudo apt-get install gcc-4.7.
If you have many versions of gcc installer you can switch between them using update-alternatives:
Query (what do you have) example: sudo update-alternatives --query gcc.
Add/make changes example: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 60

I got this issue recently, and wanted to add a piece of information in addition to #tutejszy 's answer
If you are cross-compiling your code (or using a toolchain that is not the default installed one), you will need to use this particular toolchain gcov.
And if you want to use lcov on just created gcov objects, you will need to specify the path of the toolchain gcov using option --gcov-tool <path to gcov> when running lcov

Related

Error: yq#3 has been disabled because it is not maintained upstream! How to install a disabled brew Formulae?

I'm trying to install yq#3 on my Mac running brew install yq#3 and I get the error:
Error: yq#3 has been disabled because it is not maintained upstream!
I see that it's there on their website at https://formulae.brew.sh/formula/yq#3#default but it doesn't seem to be supported anymore.
I still need to install it since our projects at work are using this specific version.
The only way that I'm thinking about is downloading the source code, building it myself, and adding it to the path but I'm thinking that there might be a simpler solution.
Any suggestion?
Thanks!
From yq github, you can install a binary by running:
wget https://github.com/mikefarah/yq/releases/download/3.4.1/yq_darwin_amd64 -O /usr/local/bin/yq &&\
chmod +x /usr/local/bin/yq
3.4.1 is the latest 3 version, darwin_amd64 is the Mac package (don't worry about having an Intel machine and installing the package that says AMD, the name comes from something about AMD invented the 64-bit instruction set).

How to use clang-format from macports?

I would like to use clang-format, but I can't find it in my system. I have llvm installed from macports. What is the way to install/enable it?
First install clang-3.9 with MacPorts with the command
sudo port install clang-3.9
Afterwards, you will find clang-format-mp-3.9 in /opt/local/bin which should already be in your PATH so you can just use it.
If you want to make clang and all other related tools point to the version you just installed, you can use the select mechanism of MacPorts.
You can see all available choices with port select --list for clang.
$ port select --list clang
Available versions for clang:
mp-clang-3.8
mp-clang-3.9
none (active)
With sudo port select --set clang <version> you choose one of them as the new default, which will create symlinks in /opt/local/bin without the version suffix.
$ sudo port select --set clang mp-clang-3.9
Selecting 'mp-clang-3.9' for 'clang' succeeded. 'mp-clang-3.9' is now active.
You can confirm this change by looking at the version of the tool:
$ clang-format --version
clang-format version 3.9.0 (tags/RELEASE_390/final)
If you later wish to remove these symlinks in order to avoid hiding tools installed by Xcode, just select the none version.
You need to install clang to get the clang tools (and llvm is a dependency of clang, so you are half way there). To get the latest stable version as of this post via macports use
sudo port install clang-3.9
Now for me clang-format is then installed in /opt/local/libexec/llmv-3.9/bin. In here you will find all the other clang tools too, such as clang-tidy.
For simplicity I made an alias in my bash profile, since I do not like the Apple's fmt command: alias fmt ='/opt/local/libexec/llmv-3.9/bin/clang-format'. Therefore fmt -i file.c now runs clang-format inplace (overwrites file) with the styles I picked in my .clang-format file.
As an added bonus this is an amazing tool to help test what all the clang-format options do: http://zed0.co.uk/clang-format-configurator/
The latest version of clang is 8.0:
$ sudo port install clang-8.0
$ clang
clang clang-check-mp-7.0 clang-format-mp-8.0 clang-offload-bundler-mp-7.0 clang-reorder-fields-mp-7.0
clang++ clang-check-mp-8.0 clang-func-mapping-mp-7.0 clang-offload-bundler-mp-8.0 clang-reorder-fields-mp-8.0
clang++-mp-7.0 clang-cl-mp-7.0 clang-import-test-mp-7.0 clang-query-mp-7.0 clang-tidy-mp-7.0
clang++-mp-8.0 clang-cl-mp-8.0 clang-import-test-mp-8.0 clang-query-mp-8.0 clang-tidy-mp-8.0
clang-apply-replacements-mp-7.0 clang-cpp-mp-7.0 clang-include-fixer-mp-7.0 clang-refactor-mp-7.0 clangd-mp-7.0
clang-apply-replacements-mp-8.0 clang-cpp-mp-8.0 clang-include-fixer-mp-8.0 clang-refactor-mp-8.0 clangd-mp-8.0
clang-change-namespace-mp-7.0 clang-extdef-mapping-mp-8.0 clang-mp-7.0 clang-rename-mp-7.0 clangd-xpc-test-client-mp-8.0
clang-change-namespace-mp-8.0 clang-format-mp-7.0 clang-mp-8.0 clang-rename-mp-8.0
So clang-format-mp-8.0 at /opt/local/bin/ is the one.

Clang Code Coverage Invalid Output

So I've checked out and built the clang trunk by following these instructions http://clang.llvm.org/get_started.html. I can build my binary with --coverage and run it to get the .gcno and .gcda files, but when I run lcov I get "GENINFO: ... reached unexpected end of file".
Now I'm stuck and came to SO to look for help :)
I'm working with Ubuntu 13.04 and writing c++11, just in case that makes a difference.
I had the same problem with clang with lcov on Ubuntu 13.04.
Here is the solution which worked for me on more than one Ubuntu setup.
You will find there are two versions of gcov on Ubuntu. gcov-4.6.4 & gcov-4.7.3. By default the gcov link is set to gcov-4.7.3. Change that to gcov-4.6.4
Furthermore, use lcov version 1.10 instead of what is available via apt-get install
This should generate the code coverage report.
EDIT: Mine was a upgrade from Ubuntu 12.04 to 13.04. Just in case you don't see two versions of gcov.
Just summarising the steps for the answer already shared by #Himanshu in case somebody's looking for the exact steps to go about it:
Install gcc 4.6
sudo apt-get-install -y gcc-4.6
I couldn’t find locv 1.10 version out of the box so I compiled it myself:
git clone https://github.com/linux-test-project/lcov.git
cd lcov
Switch to a new branch with the commit that published lcov 1.10 version as base
git checkout -b 1_10 b5c1bdd
Compile lcov
sudo make install
Confirm that lcov installed is 1.10
lcov --version
With all these things in place, use the command:
lcov --gcov-tool /usr/bin/gcov-4.6 --capture -d gcov_data/ -o gcov_data/coverage.info
This avoids tinkering with the link of the default gcov on the system.
Then generate the visual coverage file
genhtml -o gcov_data/html gcov_data/coverage.info
where gcov_data is the folder containing the gcno and gcda files.

Javac not installed with openjdk-6-jdk

I have been trying some different java compilers over the weekend and decided to stick with javac this morning. I then proceeded to clean up the mess that was caused by my testing and removed every last trace of java and did a fresh 'apt-get install openjdk-6-jdk' after autoremove and autoclean.
The following weirdness was then encountered:
tarskin#5-PARA-11-0120:~$ javac
The program 'javac' can be found in the following packages:
* openjdk-6-jdk
* ecj
* gcj-4.4-jdk
* gcj-4.6-jdk
* gcj-4.5-jdk
* openjdk-7-jdk
Try: sudo apt-get install <selected package>
I had allready installed openjdk but i tried it anyhow yielding:
tarskin#5-PARA-11-0120:~$ sudo apt-get install openjdk-6-jdk
[sudo] password for tarskin:
Reading package lists... Done
Building dependency tree
Reading state information... Done
openjdk-6-jdk is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
tarskin#5-PARA-11-0120:~$
I know i must be doing something stupid but I have no idea what, if anyone else could give a pointer in the right direction that would be very much appreciated...
Cheers
EDIT: Found some other weird aspects about the 'new' instance of my java distro, it doesn't seem to recognise for example 'Pattern' or 'Matcher' that should be coming from the regex import shrugs.
TL;DR: install java-1.6.0-openjdk-devel
I had a similar issue on Fedora, but used rpm -q -l to list the contents of the (pre-installed) java-1.6.0-openjdk package, and discovered that it doesn't include javac. It is in fact only a JRE, not a JDK, as implied by the installation instructions on http://openjdk.java.net/install/ . To get javac, I installed java-1.6.0-openjdk-devel . Not exactly what I expected, because the usual packaging conventions would indicate that is the package for doing openjdk development (i.e., working on the JVM), not for developing programs with it.
Basically, openjdk's package naming doesn't follow either standard Java conventions (would require calling it a JRE somewhere), or standard Linux packaging conventions (using -devel indicates it is used for developing the package w/o -devel itself).
As per http://openjdk.java.net/install/, to install the OpenJDK-6 JRE only:
$ sudo apt-get install openjdk-6-jre
To install the full JDK:
$ sudo apt-get install openjdk-6-jdk
Check /etc/alternatives and /usr/bin. One or both will contain links to old Java versions which you had installed. When those links are broken, you can get the error message above.
To update the links after installing a new version of Java, try update-alternatives
First to check if javac is installed try to look for that file:
1. locate javac
2. or find / -name javac
And also you can check at this website with instrucions on how to install java on Ubuntu (i suppose you are on ubuntu):
http://openjdk.java.net/install/
You can also check:
http://packages.ubuntu.com/hardy/i386/openjdk-6-jdk/filelist for the files installed by the pacakge, and you can notice that javac should be installed.
Maybe you also need to run:
Open the terminal and run this command to install OpenJDK 7.0 on Ubuntu Oneiric:
sudo update-alternatives --config java

Unable to find Lua headers with find_package in cmake

I'm trying to use CMake to build generate the make file for a project of mine that uses Lua. When I run make I get this error:
/path/to/my/project/luaudio/luaudio.c:1:17: fatal error: lua.h: No such file or directory
In the CMakeLists.txt file, I have the following lines, which I thought would do it, but apparently they're not enough:
find_package(Lua51 REQUIRED)
set(Luaudio_INCLUDE_DIRS ${Luaudio_SOURCE_DIR} ${Lua51_INCLUDE_DIRS} PARENT_SCOPE)
include_directories(${Luaudio_INCLUDE_DIRS})
Lua51_Include_Dirs appears to be empty (attempting to run it though the message command doesn't print anything) so I suspect that it just can't find it. Do I need to specify where to look for Lua? I was under the impression that the whole point of find_package was that it would look in a set a predefined places so that I don't need to specify where it is specifically.
(This is on an Ubuntu machine and I do have the Lua packages installed.)
install lua bin:
sudo apt-get install lua5.1
install lua lib:
sudo apt-get install lua5.1-dev
Exploring FindLua51.cmake from cmake 2.8 I found that it sets LUA_INCLUDE_DIR variable instead of Lua51_INCLUDE_DIRS. So cmake code should be
find_package(Lua51 REQUIRED)
set(Luaudio_INCLUDE_DIRS ${Luaudio_SOURCE_DIR} ${LUA_INCLUDE_DIR} PARENT_SCOPE)
include_directories(${Luaudio_INCLUDE_DIRS})
for Ubuntu 14.04
sudo apt install lua5.2;
sudo apt install liblua5.2-dev;

Resources