Remote debugging problems - c++

I am trying to remote debug applications on a server in my local network.
Server:
$ uname -a
Linux broatyctl.localdomain 3.6.11.2-rt33.39.el6rt.x86_64 #1 SMP PREEMPT RT Thu Jul 4 06:46:48 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
$ gdbserver --version
GNU gdbserver (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1)
Copyright (C) 2010 Free Software Foundation, Inc.
gdbserver is free software, covered by the GNU General Public License.
This gdbserver was configured as "x86_64-redhat-linux-gnu"
Workstation:
$ uname -a
Linux workstation.localdomain 3.12.7-300.fc20.x86_64 #1 SMP Fri Jan 10 15:35:31 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$ gdb --version
GNU gdb (GDB) Fedora 7.6.50.20130731-16.fc20
I compiled a "Hello World" app on the workstation and it runs without errors on both workstation and server.
This works on both server and workstation
Shell 1:
$gdbserver localhost:2345 CrossTest
Shell 2:
$ gdb CrossTest
(gdb)target extended-remote localhost:2345
(gdb)run
This does not work
Server:
$ gdbserver workstation.ip.address:2345 CrossTest
Workstation:
$ gdb CrossTest
(gdb)target extended-remote server.ip.address:2345
(gdb)cont
GDB output
(gdb) cont
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x00007f2a3b247d50 in ?? ()
(gdb)
gdbserver tells me that there is an incomming connection, but it doesn't write my hello world message.
Any ideas?
P.S. I allready posted this question on linuxquestions.org a while ago. I don't think that was the right forum, so I am trying my luck here.

Compiling with -ggdb instead of -g AND using target remote instead of extended-remote did it.

Related

aarch64-linux-gnu-gcc: error: unrecognized command line option ‘-i’

I use this command->
aarch64-linux-gnu-gcc -i ok.c
to see the output of the prepossesses file
But it gives me error->
aarch64-linux-gnu-gcc: error: unrecognized command line option ‘-i’
I use both native and cross compiler(gcc and aarch64-linux-gnu) but both produces same result, the --help command show where there is no -i command at any compiler,
I find this command in "Advanced C and C++ Compiling - 2014 by Milan Stevanovic" book.
My os is Ubuntu - 20.04.2 LTS
Compiler version : gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 and
aarch64-linux-gnu-gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

lubuntu does not see executable file generated by ocamlopt on NixOS

i created executable "standalone" file in NixOS (x86_64) using "ocamlopt" native compiler with option -linkall. and the generated program is executed in NixOS. so far so good
after that i tried to execute this file under Lubuntu
lubuntu#lubuntu:~/Documents$ uname -a
Linux lubuntu 4.18.0-10-generic #11-Ubuntu SMP Thu Oct 11 15:13:55 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
but recieved:
lubuntu#lubuntu:~/Documents$ ./a.out
bash: ./a.out: No such file or directory
i am quite sure that architecture is suitable:
lubuntu#lubuntu:~/Documents$ objdump -h a.out
a.out: file format elf64-x86-64
what i did wrong? on NixOS, on OCaml, on Lubuntu?
Tnx in advance
UDP: my NixOS distro:
$> uname -a
Linux cat 4.19.36 #1-NixOS SMP Sat Apr 20 07:16:05 UTC 2019 x86_64 GNU/Linux
ocaml:
$> ocamlopt -v
The OCaml native-code compiler, version 4.06.1
UDP2:
$> readelf -a a.out | grep ld-
[Requesting program interpreter: /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/ld-linux-x86-64.so.2]
"No such file or directory" (ENOENT) when trying to execute a file that does exist usually means that its dynamic linker path (ELF interpreter) doesn't exist. It's exactly the same error for the same reason you'd get from executing a text file that started with #!/non-existant/path
Use strace ./a.out to see that the only system call is the execve which fails.
Most GNU/Linux distros use /lib64/ld-linux-x86-64.so.2. For example file /bin/ls on my Arch GNU/Linux desktop shows:
/bin/ls: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV),
dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2,
BuildID[sha1]=4fef2dc9762eb7d4593f402a65cc02bb3d4c48de, for GNU/Linux
3.2.0, stripped
Presumably NixOS, or at least ocamlopt on NixOS, uses a different path. Use file to check. (Or readelf -a to show the ELF program headers will also dump the interpreter path.)
ldd can also show the interpreter path, but IIRC fails if the path isn't valid.

Cross-compile for ARM: undefined reference to '__fdelt_chk#GLIBC_2.15'

Following this howto I'm cross-compiling a bluetooth application for Raspberry Pi (ARM). When I try to link with libbluetooth I get the error below. Even the simplest helloworld application (without bluetooth code) won't link.
arm-linux-gnueabihf-g++ -c hello.cpp -o hello.o
arm-linux-gnueabihf-g++ hello.o -o hello -lbluetooth -L/home/sbf/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf
/home/sbf/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libbluetooth.so: undefined reference to `__fdelt_chk#GLIBC_2.15'
sbf#sbf-VirtualBox ~/raspberrypi/projects/test $ ls -al /home/sbf/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libbluetooth*
-rw-r--r-- 1 sbf sbf 132886 May 27 2016 /home/sbf/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libbluetooth.a
lrwxrwxrwx 1 sbf sbf 23 Nov 24 21:20 /home/sbf/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libbluetooth.so -> libbluetooth.so.3.17.11
lrwxrwxrwx 1 sbf sbf 23 Nov 24 21:20 /home/sbf/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libbluetooth.so.3 -> libbluetooth.so.3.17.11
-rw-r--r-- 1 sbf sbf 103376 May 27 2016 /home/sbf/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libbluetooth.so.3.17.11
Edit (added):
GLIBC Version 2.19
pi#raspberrypi:~ $ ldd --version
ldd (Debian GLIBC 2.19-18+deb8u6) 2.19
What's going wrong?
I was experiencing the same issue yesterday trying to link libbluetooth using raspberry pi tools.
To solve this I downloaded a newer version of Linaro dev tools (6.1.1) than what is supplied by the raspberry pi tools repository.
Here is the link to the latest linaro toolchain release
Download "gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabihf.tar.xz" and put that folder in your raspberrypi/tools/arm-bcm2708/ directory along with the other toolchains.
Then set compiler/linker paths to point to the new directory.
(I am using cmake)
SET(CMAKE_C_COMPILER $ENV{HOME}/raspberrypi/tools/arm-bcm2708/gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER $ENV{HOME}/raspberrypi/tools/arm-bcm2708/gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++)
(edit) I had trouble running my executable with this version of the toolchain compiled since jessie doesn't support gcc versions 5 or 6. Instead try using this release https://releases.linaro.org/components/toolchain/binaries/4.9-2016.02/arm-linux-gnueabihf/

installing gcc version 4.8.2 in redhat have an error

First run ./configure it worked,
then make -j4, it will report
options.c:11145: error: narrowing conversion of '-0x00000000000000001' from 'int' to 'short unsigned int' inside { }
GMP、MPFR、MPC install successed
cat /proc/version
Linux version 2.6.32-504.23.4.el6.x86_64 (mockbuild#x86-029.build.eng.bos.redhat.com) (gcc version 4.4.7 20120313 (Red Hat 4.4-9) (GCC) ) #1 SMP Fri May 29 10:16:43 EDT 2015
file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 6.6 (Santiago)
Release: 6.6
Codename: Santiago

GCC 4.9.2 cross-compiler build for ARM

I am trying to build a cross-compiler for ARM. When I add c++ to my "enable-languages" list in the configure (see) below, the gmake errors out with:
checking for exception model to use...
configure: error: unable to detect exception model
gmake[1]: *** [configure-target-libstdc++-v3]
but when I take c++ out of the "enable-languages", as in my configure script below, the GCC cross-compiler builds just fine.
../gcc-4.9.2/configure --prefix=/home/me/ANDROID21 --target=arm-linux-androideabi
--with-gmp=/home/me/ANDROID21 --with-mpfr=/home/me/ANDROID21
--with-mpc=/home/me/ANDROID21
--with-gnu-as--with-gnu-ld --enable-languages=c,fortran --disable-nls
--disable-tls
--disable-bootstrap --disable-libgomp --disable-shared --disable-libssp
-disable-libquadmath --enable-threads --enable-target-optspace --disable-libatomic
--with-sysroot=/home/me/android-ndk-r10c/platforms/android-21/arch-arm
For reference, here is my machine info:
$ uname -a
Linux (system name) 2.6.32-504.el6.x86_64 #1 SMP Tue Sep 16 01:56:35 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
And the GCC I'm building off of:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/me/GCC4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/me/gcc-4.9.2/configure --prefix=/home/me/GCC4.9.2 --disable-multilib
--enable-libgomp --enable-languages=c,c++,objc,obj-c++,java,fortran
Thread model: posix
gcc version 4.9.2 (GCC)
Any ideas on possible causes?
Haven't found anything definitive in the archives yet. Would really like to get the c++ portion to cross-compile too.
TIA,
Steve