VS2019 - Sudo Remote Debugging on Linux with Cmake project - c++

I have a cmake c++ Linux project that is using Remote Debugging from a windows computer. The program accesses the GPIO pins on Raspberry pi so it needs to run under sudo on the remote machine. Everything is building and working but it crashes on the first line that needs admin access. I have not been able to figure out how to launch the newly compiled application under sudo. I have tried different settings in the launch_schema.json but no luck so far.

I found this and it worked for me.
Unable to launch debugger (gdb) with root permissions.
Basically you decorate the existing gdb binary on the Pi with a bash script and then use the script.
The steps on the Pi are:
cd /usr/bin
sudo mv gdb gdborig
Now create a bash script named gdb with following content.
sudo nano gdb
Content of the bash is;
#!/bin/sh
sudo gdborig $#
Finally, make the script runnable with.
sudo chmod 0755 gdb
Thanks goes to Buğra Aydoğar

Related

gdbserver remote target: Target description specified unknown architecture "arm" Where is gdb binary for ARMv7?

I have a target machine, raspberry pi ARMv7, that I want to debug remotely from my windows machine.
I want to use gdb gdbserver with 'target remote' to debug the docker container remotely.
My executable is compiled c++ src code.
Dockerfile that I run on raspberry pi
FROM arm32v7/ubuntu:latest
# Install necessary packages and cross-compiling toolchain
RUN apt-get update && apt-get install -y gdb gdbserver g++ bash
RUN apt-get install -y crossbuild-essential-armhf gdb-multiarch
ENV CC=arm-linux-gnueabihf-gcc
ENV CXX=arm-linux-gnueabihf-g++
ENV AR=arm-linux-gnueabihf-ar
# Copy the source code
COPY . /app
# Set the working directory
WORKDIR /app
# Compile the source code
RUN ${CXX} -g -o testapp2 testapp2.cpp
# Run the executable
CMD ["./testapp2"]
I believe my windows machine needs a pre-built binary of gdb for the ARMv7 architecture.
I looked through linaro.org and developer.arm.com but I haven't been able to find a download for this.
Do I need to build it myself on my windows machine?
I was able to successfully target remote by using
gdb-multiarch -ex "target remote Enter-Ip-Address-Here:Enter-TCP-Port-Here" /path/to/executable/in/the/docker/container/here
in Windows Subsystem Linux

How to install the lustre client on Ubuntu nodes?

I am trying to install the lustre clients on Unbuntu 20.04 nodes I have in GCP. Im using linux kernel version 5.15.0-1021-gcp.
I'm trying to install the client with the following code:
cd /home/apps/
mkdir lustre
git clone git://git.whamcloud.com/fs/lustre-release.git
cd lustre-release
git checkout 2.15.0
sh autogen.sh
./configure --prefix=/home/apps/lustre --disable-server --enable-client ## doesnt run! Fails at ./configures with error message "error: Run make config in /lib/modules/5.15.0-1021-gcp/build"
make debs
The configure step fails with an error about running make config in /lib/modules/5.15.0-1021-gcp/build. I tried running make config in /lib/modules/5.15.0-1021-gcp/build but was asked to input some values that I was unsure of.
I also tried downloading the deb package of the client software at
https://downloads.whamcloud.com/public/lustre/lustre-2.15.0/ubuntu2004/client/lustre-client-modules-5.4.0-96-generic_2.15.0-1_amd64.deb. However this is for the wrong linux kernel and I'm not sure what env variables need to be set for this package.
Anyone know how to install the client modules for lustre on Ubuntu?
You need to have the kernel sources or kernel-devel package that exactly match the kernel that you are installing on. This should also include the .config file that describes all of the options used when building your kernel.
Alternately, you could try a pre-built package, but it isn't clear if this will install on your kernel or not.
https://build.whamcloud.com/job/lustre-b2_15/40/arch=x86_64,build_type=client,distro=ubuntu2204,ib_stack=inkernel/

Run Ganache GUI on ubuntu

I want to run ganache Gui app on ubuntu 22.04. After downloading AppImage I run it using command
ganache-2.5.4-linux-x86_64.AppImage --appimage-extract
It generates new folder and then I execute ./Ganache inside that folder.
I get this message
[50883:0717/002902.307174:FATAL:gpu_data_manager_impl_private.cc(1034)] The display compositor is frequently crashing. Goodbye.
Trace/breakpoint trap (core dumped)
How can I fix this ?
You should chmod +x ganache-2.5.4-linux-x86_64.AppImage and turn it into an executable. Then you can run it double clicking it.
You could also move it into the opt folder to be available to all users with the command sudo mv ganache-2.5.4-linux-x86_64.AppImag /opt/
And then, you could create a desktop link to be used in the menu, creating a file with the contents like this:
[Desktop Entry]
Name=Ganache
Exec=/opt/ganache-2.5.4-linux-x86_64.AppImage
comment=cloud
Type=Application
Terminal=false
Encoding=UTF-8
Categories=Utility;
Then, when you run it, you can pin it to your panel! :D
I found a solution for ubuntu 22.04 here: https://github.com/AppImage/AppImageKit/wiki/FUSE
just run these commands:
sudo add-apt-repository universe && sudo apt install libfuse2

How to debug a CMake target that needs root privileges with vscode

I am trying to debug a CMake target that needs root privileges on vscode, but when I replaced my gdb executable with a script to launch it using sudo, vscode won't start the debugger anymore.
This was my attempt to make gdb run with sudo:
echo '#!/bin/sh
sudo gdb-orig $#' >/usr/sbin/gdb
sudo chmod 0755 /usr/sbin/gdb
I don't get any error on vscode, it just won't start debugging my executable. Also, I can run the script without any problems from the terminal.
What am I missing? Is there any alternative to debug targets that need root privileges?

Vmware on Arch: Could not open /dev/vmmon: No such file or directory

I want to install VMware Workstation on Arch. I used the command yay -S vmware-workstation to install. After installation finished, I ran VMware, created an VM, started it, and got the error:
Could not open /dev/vmmon: No such file or directory.
Please make sure that the kernel module `vmmon' is loaded.
I tried to install linux-header but it still didn't work.
OS: Arch Linux, 5.10.56-1-lts.
Thanks for any help!
I ran into this problem too, and the solutions I found online ended up having their own problems that needed to be solve, which I'll document here.
To solve the error Could not open /dev/vmmon/: you need to run:
sudo vmware-mod-config --console --install-all
If this returns an error about Glib not having support, you need to clone https://github.com/mkubecek/vmware-host-modules.git and make it.
$ git clone https://github.com/mkubecek/vmware-host-modules.git
$ cd vmware-host-modules
$ git checkout -b 16.2.1 origin/workstation-16.2.1
$ sudo make
If this returns an error containing fatal error: generated/autoconf.h: No such file or directory, you need to install linux-headers and make sure it matches your linux kernel version. Probably also make sure your kernel is up to date, although I'm not sure if that's necessary.
$ sudo pacman -S linux
$ sudo reboot
$ sudo pacman -S linux-headers
Now you should be able to make install in that cloned repo, which should install the required modules for you to be able to run the vmware-mod-config --console --install-all command, which should solve the issue.
So working backwards, the steps are:
Update your linux kernel and install the right linux-headers for it.
Clone this git repo, cd into it, git checkout -b 16.2.1 origin/workstation-16.2.1, and run sudo make install
Run sudo vmware-mod-config --console --install-all
More about can be found at my post here: https://bbs.archlinux.org/viewtopic.php?pid=2020372#p2020372
I also encountered same problem. Most of the stackoverflow pages suggest to reinstall the vmware but its not a fair solution and even its not a solution. Its just like if you have pain in teeth remove that teeth.
Another thing is that some post and even vmware official posts said to disable secure boot.
But after trying both nothing changed so i goto to cd /dev and found that the file vmmmon exists.
And when i tries to load the file it loaded successfully.
So from here i concluded that to solve this issue do the following:
Either disable the secure boot or sign the vmmon.
CD to /dev/
Load vmmon using modprobe
and as always Happy coding....
The command: sudo vmware-modconfig --console --install-all works, but every time that I reboot the system the error come out again.
In my case, the cause of this problem was the vmmon didn't be load. So I just
sudo modprobe -v vmmon
and it work.