Valgrind on bash for Windows 10 [duplicate] - c++

When I installed WSL for my computer I was very excited to have a more natively supported Linux system rather than using VirtualBox. However I get this error when I try to run it. Is there a reason why?
I am happy to give more information as required.
--4364:0:aspacem -1: ANON 0038000000-00383d5fff 4022272 r-x-- SmFixed d=0x000 i=25365 o=0 (0) m=0 /usr/lib/valgrind/memcheck-amd64-linux
--4364:0:aspacem Valgrind: FATAL: aspacem assertion failed:
--4364:0:aspacem segment_is_sane
--4364:0:aspacem at m_aspacemgr/aspacemgr-linux.c:1502 (add_segment)
--4364:0:aspacem Exiting now.

It's definitely possible
I've encountered some problems installing it directly with apt, however it can be installed manually with some very simple steps:
Download the source file: wget http://valgrind.org/downloads/valgrind-3.12.0.tar.bz2 (by the time you read this there could be a newer version)
Extract the archive: tar -xvjf valgrind-3.12.0.tar.bz2
Configure the installation process: cd into the exctracted folder valgrind-3.12.0 and then launch ./configure
Make: simply launch make while in the valgrind-3.12.0 folder
Check the dependencies: launch make check to see whether all the dependencies necessary for the installation are satisfied (e.g: you'll have to install g++, just launch sudo apt install g++)
Install valgrind: type sudo make install to install it

I had the same problem, the solution was to install Windows 10 creators update (version 1703), and reinstall Bash/WSL. Valgrind now works fine :)

Related

How to Install ONOS using Bazel in Ubuntu 20.04?

I have been trying to install ONOS using Bazel's new version i.e., Bazel-5.1.1 in Ubuntu 20.04 LTS for mininet/containernet. I have been having issues regarding Bazel build onos command. I have searched for the installation process all over and tried as well many. But have similar issues. Is there any link or article where there is a clear step-by-step procedure to do so? I am having a task for the installation which I need to finish in a week. Any help would be appreciated. Thanks in Advance.
The error I get:
sendate#sendate04:~/onos$ bazel build onos
ERROR: The project you're trying to build requires Bazel 3.7.2 (specified in /home/sendate/onos/.bazelversion), but it wasn't found in /home/sendate/.bazel/bin.
Bazel binaries for all official releases can be downloaded from here:
https://github.com/bazelbuild/bazel/releases
You can download the required version directly using this command:
(cd "/home/sendate/.bazel/bin" && curl -fLO https://releases.bazel.build/3.7.2/release/bazel-3.7.2-linux-x86_64 && chmod +x bazel-3.7.2-linux-x86_64)
I tried doing the steps given like downloading the same version and also tried to change the version in the .bazelversion file. But nothing succeeded in Bazel build.
1.bazel —-version
If you didn’t download bazel version 3.7.x download it. If you download java version 11.You need create java default symbolic link. It will be /bar/lib/jam. . Test echo $PATH it will give ONON path. Then run sudo apt install —-reinstall build-essential. Build onos

Is there a way to install Valgrind on Catalina?

Is there a way to install Valgrind on Catalina and have it run properly? If so, I would very much appreciate a step-by-step process.
I tried installing Valgrind with https://github.com/sowson/valgrind
but when I tested out helloWorld.cpp on the terminal, the console returned errors I should not have gotten.
I'm not sure if I committed an error on my part in the installation process of this version of Valgrind or if Valgrind itself is simply incompatible with Catalina OS.
I have also tried installing Valgrind via Homebrew, but I've had issues with that as well (github.com/Homebrew/homebrew-core/issues/36683).
Currently, no. The repo you link has an issue raised about Catalina compatibility. As you also show, the brew package has its own problems as well. Official valgrind only supports 10.12.
You'll just have to wait, or containerize it. Although if you containerize valgrind, you would likely need a compatible build container as well.
Ok. I've found a way to use Valgrind on Catalina. Here's a link to my guide for how https://github.com/john-yohan-park/Valgrind_Catalina
Works amazingly!! see https://github.com/LouisBrunner/valgrind-macos/issues/5.
Not Homebrew, you need to compile it from source, but it's not so difficult.
1. git clone https://github.com/LouisBrunner/valgrind-macos.git
2. cd valgrind
3. sudo ./autogen.sh
4. sudo ./configure --prefix=/where/you/want/it/installed --enable-only64bit
5. copy the [contents][1] to ./coregrind/m_mach/mach_basics.c
6. sudo make
7. sudo make install
enjoy!
This is how I just did it on Catalina 10.15.5:
brew remove valgrind # remove previous attempts at installing it (if any)
brew tap LouisBrunner/valgrind
brew install --HEAD LouisBrunner/valgrind/valgrind
Source: https://github.com/LouisBrunner/valgrind-macos

Visual Studio 2017 Linux remote debugging (gdbserver)

After I installed gdbserver on my remote machine (Ubuntu 16.04.4 LTS), I tested the following c++ code by making a "cross-platform console application (linux)" project in Visual Studio 2017:
#include <cstdio>
int main()
{
printf("hello from testLinuxDebug!\n");
return 0;
}
I added the connection information (ip address, id, password) of my Ubuntu machine to connection manager and selected "gdbserver" for debugging mode.
Then I started debugging and got the following message:
Unable to start debugging. Unexpected GDB output from command
"-interpreter-exec console "target remote localhost63361"". Remote
connection closed.
Message after starting to debugging (Image captured from VS2017)
By the way, I got the following message from the Linux Console Window of debug menu of Visual Studio 2017:
Process /home/.../projects/testLinuxDebug/bin/x64/Debug/testLinuxDebug.out
created; pid = 29277 Listening on port 4444 Remote debugging from host
127.0.0.1 /build/gdb-9un5Xp/gdb-7.11.1/gdb/gdbserver/regcache.c:264: A problem > internal to GDBserver has been detected. Unknown register ymm0h requested
Message from Linux Console Window (Image captured from VS2017)
Could anybody help me with this problem?
I was having this exact same problem on my Ubuntu 16.04 machine.
I went through the source code on gdbserver, and it appears to be a problem with a processor register (ymm0h) which is only available to i386 processors.
The thing is, I don't know how to fix gdbserver to not use this register in particular, but you can solve the error by upgrading your gdb & gdbserver to version 8.3 on the Ubuntu machine. If my guess is correct, version 8.1 was the one that fixed this issue, but by default, Ubuntu 16.04 has version 7.11.1 for both gdb & gdbserver.
You can run these commands on the linux machine to do that:
wget "http://ftp.gnu.org/gnu/gdb/gdb-8.3.tar.gz"
tar xzf gdb-8.3.tar.gz
cd gdb-8.3
./configure --prefix=/usr --with-system-readline
make
sudo make install
You may need to install some extra packages in order to compile the gdb:
sudo apt-get install libreadline6-dev texinfo
If you still have problems trying to install gdb, try this example from Linux from Scratch.
Good luck!
I encountered the same problem as you, although for me the issue was on Microsoft's Visual Studio Online platform - I couldn't use pwntools' gdb.debug/gdb.attach functionality (that relies on gdbserver) due to this very same error in VSOnline's docker environment.
Leaving this answer here for people who might encounter the same issues that I have.
The issue and the steps are pretty similar to what Canella described - the root of the problem is indeed the old GDB version in the environment (7.12 at the time of writing).
I've compiled my GDB with python3 bindings, and you might want to do that too if you're planning to use GEF or similar GDB extensions.
Here's how to do that in your VSOnline environment's terminal:
# I needed to get rid of the apt-provided gdb for it to work properly
sudo apt remove gdb
# VSOnline has a weird way of handling python versions
# you're better off installing python3 from apt, if it's not installed yet
sudo apt update
sudo apt install libreadline6-dev texinfo python3 python3-dev
wget "http://ftp.gnu.org/gnu/gdb/gdb-8.3.tar.gz"
tar xzf gdb-8.3.tar.gz
cd gdb-8.3
mkdir build && cd build
../configure --prefix=/usr --with-system-readline --with-python=/usr/bin/python3
make
sudo make install

How to build and install Valgrind on Mac?

I am on Mac OS X using codeblocks 10.05
I downloaded Valgrind, and extracted a folder. I am completely lost from there, and have no idea how to build it.
I do not know ANY terminal/console commands and am generally new to programming, so I have no idea how to "build" or "compile" it. I just have a folder called Valgrind with a bunch of random files in it.
Could someone please tell me how to proceed? I already checked the website/documentation but it didn't really give me installation instructions, just usage instructions.
Thanks
PS: I know I already posted this question, but the previous question was shut down, for being too vague. I reposted this one with more info.
PSS: All that I am basically asking is what do I do to install Valgrind right after I download it from the website and extract the files?
Recommended:
Use brew: brew install valgrind
Manual Install:
Here's what worked on my Mac (10.6). Double-check you have the latest version, then change into the uncompressed directory
cd /users/(insert username here)/downloads/valgrind-3.17.0
I suggest you do as another posted and read the readme.
nano README
Commence the build; /usr/local is the place on the filesystem that the program will be installed to. There are many arguments like prefix that are available to customize the installation to your particular system if it doesn't work by default. Normally just using ./configure works perfectly well though.
./configure --prefix=/usr/local
make
sudo make install
Or you could probably get it from fink or macports or homebrew.
You can install it through brew for Mac:
brew install valgrind
You might have to manually link the entry to /usr/local/bin as brew refused to do it in my case:
$ ln /usr/local/Cellar/valgrind/3.8.1/bin/vgdb /usr/local/bin/vgdb
ln: /usr/local/bin/vgdb: Permission denied
$ sudo ln /usr/local/Cellar/valgrind/3.8.1/bin/vgdb /usr/local/bin/vgdb
On MacOS High Sierra
If you have the following error message:
brew install valgrind
valgrind: This formula either does not compile or function as expected on macOS
versions newer than Sierra due to an upstream incompatibility.
Fix
(1) To correctly install it, first, type the following command at the Terminal (which opens Valgrind’s formulae)
brew edit valgrind
And change the URL in head section
https://sourceware.org/git/valgrind.git
to
git://sourceware.org/git/valgrind.git
(2) Do an update for Homebrew:
brew update
(3) Finally, use the following command to install Valgrind from the HEAD:
brew install --HEAD valgrind
Sources
https://www.gungorbudak.com/blog/2018/04/28/how-to-install-valgrind-on-macos-high-sierra/
https://github.com/Homebrew/homebrew-core/issues/18998
For macOS Big Sur / Monterey:
brew tap LouisBrunner/valgrind
brew install --HEAD LouisBrunner/valgrind/valgrind
The core process is pretty simple:
Make sure you are in the correct directory.
First run:
./configure
when that is finished, run:
make
at this point you will need to su into root (this is relatively tricky to do, see the note at the end). As root, run:
make install
When this is finished you will have a working valgrind installation. Test it by running
valgrind ls -l
To su into root, you will need to have set up a root account. If you have not done this in the past, see the instructions from apple here.
To perform the actual su, you will first have to be running an account with administrator privileges. If you are not already doing so, you can switch users with the following:
su admin
where admin is the name of an user with administrator privileges (you will need to enter the password for this account). From there, you can then run su to go into root:
su
You will need to enter the root password that you set up earlier.
You may find it easier to use something like macports. How to install that is probably beyond the scope of this question, but they have a page dedicated to it on their site.
Once you have macports installed, you need to type:
sudo port install valgrind +universal
As you say you don't have any experience of command lines, let's just briefly go through the different parts of this command:
sudo means the rest of the command will run as root, and will ask for your password. This is needed for the installer to have the correct permissions
port is the command line tool for managing macports
install is a command for port. Try port help to see a list of commands.
valgrind tells macports what it should be installing
+universal is a variant. This tells macports to configure valgrind to support 32 bit and 64 bit support.

Not able to install GDB on Fedora

How to download and install GDB(GNU Debugger) on Fedora Linux Machine.. I have tried downloading from gnu website 7.1 package, but then it fails during
./configure and then make command...
Please share the source from where i can get information on the same.
Thanks..
I have found this tutorial which might be helpful to install gdb.
http://www.tutorialspoint.com/gnu_debugger/installing_gdb.htm
But for me the command:
yum install gdb
works.
You may need to install some development packages with header files needed to build gdb. The exact package list depends on error messages from ./configure and make. Here is installed package list on my system:
# rpm -qa "*devel"
kernel-devel-2.6.23.1-42.fc8
ncurses-devel-5.6-12.20070812.fc8
python-devel-2.5.1-15.fc8
expat-devel-2.0.1-2
libtirpc-devel-0.1.7-12.fc8
glibc-devel-2.7-2
libstdc++-devel-4.1.2-33
Try to install all of them with yum.