Build GDB for ESP32 and QEMU - gdb

I tried to build a gdb for esp32 that works with qemu, but after many attempt, I didn't manage. All my attempts leaded me to the following error message after connecting to the remote target: Remote 'g' packet reply is too long.
Right now I am using the prebuilt version from Ebiroll: https://github.com/Ebiroll/qemu_esp32/blob/master/bin/xtensa-esp32-elf-gdb
but I would like to use a newer gdb version than 7.10, did anyone had success with this?
Here is how I built gdb:
git clone --depth 1 --branch esp-2021r2-gdb https://github.com/espressif/binutils-gdb.git
cd binutils-gdb
mkdir -p build
cd build
../configure --without-guile --host=x86_64-pc-linux-gnu --target=xtensa-esp32-elf --disable-werror
make
make install
(note from this branch the patch to apply from the Zephyr project, as described here https://github.com/Ebiroll/qemu_esp32#qemu-esp32, seems to already be included)
I also tried by applying the following patch (no success):
curl -L https://raw.githubusercontent.com/Ebiroll/gdb/master/gdb/xtensa-config.c.qemu --output binutils-gdb/gdb/xtensa-config.c
or patching qemu to fix the value of num_regs (tried 104 and 172, also no success).

Espressif's qemu wiki mentions setting an environment variable to only list the core registers:
export QEMU_XTENSA_CORE_REGS_ONLY=1
This needs to be set in the environment from where qemu will be executed.
My recommendation is to use both qemu and gdb (from the Esp32 tool chain) as provided by Espressif. I have recently used this combination with success. The latest release uses gdb 9.2.

Related

Failure to "opam init", how to manually specify index.tar.gz?

I cannot opam init:
$ opam init --verbose
[NOTE] Will configure from built-in defaults.
Checking for available remotes: rsync and local, git, mercurial.
- you won't be able to use darcs repositories unless you install the darcs command on your system.
<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
[ERROR] Could not update repository "default": OpamDownload.Download_fail(_, "Curl failed: \"/usr/bin/curl --write-out %{http_code}\\\\n --retry 3 --retry-delay 2
--user-agent opam/2.0.7 -L -o /tmp/opam-1697-6d07ae/index.tar.gz.part https://opam.ocaml.org/index.tar.gz\" exited with code 28")
[ERROR] Initial download of repository failed
However, I've manually downloaded index.tar.gz. How to manually specify index.tar.gz to opam init?
System info:
$ uname -a
CYGWIN_NT-10.0-19043 xxx 3.4.5-1.x86_64 2023-01-19 19:09 UTC x86_64 Cygwin
P.S. I'm trying to build one project using OCaml, but it turned out that it is very tricky: either OCaml complains about compatibility (is not a compiled interface for this version of OCaml followed by It seems to be for an older version of OCaml; does it mean that OCaml is not backward compatible?), either opam init fails, either <whatever>.
Your error message indicates that you either have network problems or very poor connection. Also, you opam version is very old, so it might not handle bad networks very well, I would suggest your installing a newer version of opam (at least 2.1.x), or, if it is possible, switching to docker or a virtual machine.
Answering your original question: I don't think there is a way (at least officially supported to specify your own downloaded index). Also, if you have trouble with downloading the index it most likely means that you will have more trouble in the future with your network when opam will start downloading actual packages.

Having problems with gdb [duplicate]

How can I include/view the source code of malloc in gdb?
I want to do a step by step execution in gdb, and step into malloc.c source code when any of the malloc functions is called.
Currently what gdb says is:
malloc.c: No such file or directory.
This guy here faced the same problem, but they do not mention a solution, ie how to actually step into the source code of malloc.
I am on Ubuntu server 14.04, and I have already tried to install the following:
libc6-dbg, libc6-dev, and libc6-dbgsym.
I don't even know if one of these packages might help, but installing the libc-dbgsym gives me the following error:
dpkg: error processing archive /var/cache/apt/archives/libc6-dbgsym_2.19-0ubuntu6.6_amd64.ddeb (--unpack): trying to overwrite
'/usr/lib/debug/usr/lib/x86_64-linux-gnu/audit/sotruss-lib.so', which
is also in package libc6-dbg:amd64 2.19-0ubuntu6.6 dpkg-deb: error:
subprocess paste was killed by signal (Broken pipe)
The following worked for me. Not sure whether there is a better way.
Install libc6-dbg (which you have already done):
sudo apt-get install libc6-dbg
Install the eglibc-source package (ubuntu actually uses eglibc): sudo apt-get install eglibc-source.
Unpack the tar file that was installed in /usr/src/glibc: /usr/src/glibc $ sudo tar xvf eglibc-2.19.tar.xz
Crank up gdb and add in the path to the malloc source: (gdb) dir /usr/src/glibc/eglibc-2.19/malloc
(gdb) n
13 char *c = malloc(100);
(gdb) s
__GI___libc_malloc (bytes=100) at malloc.c:2876 2876
{
(gdb)
Gdb can only show the source codes because the debug-compiled binaries contain references between the binary code and the source files.
malloc() is in the C library. On normal systems, it is not compiled with debug metadata, and its sources are also not installed in the system.
But they are reachable, you only need to install the debug versions of these libraries. For example, on debian an apt-get install glibc-debug or similar will do it. On SuSE, a zipper in libc6-debug (afaik, maybe the exact package names could be a little bit differ).

OpenCV WebAssembly

I try to run this tutorial, http://videocortex.io/2017/opencv-web-app/, to build and try out OpenCV WebAssembly. But I can´t get over step "The Build System" I´ve build emscripten 1.38.21, installed Python 2.7.5.3_64bit and CMAKE 3.13.2 but get an error in the end:
Did I missed something?
When I run emcc -v I get some error´s also:
WARNING:root:LLVM version appears incorrect (seeing "6.0", expected
"3.7") ERROR:root:Emscripten, llvm and clang versions do not match,
this is dangerous (1.35.0, "1.38.21", "1.38.21") ERROR:root:Make sure
to use the same branch in each repo, and to be up-to-date on each. See
http://kripken.github.io/emscripten-site/docs/building_from_source/LLVM-Backend.html
INFO:root:(Emscripten: Running sanity checks) emcc (Emscripten
gcc/clang-like replacement + linker emulating GNU ld) 1.35.0 clang
version 6.0.1 (emscripten 1.38.21 : 1.38.21) Target:
x86_64-pc-windows-msvc Thread model: posix InstalledDir:
D:\Repositories\emsdk\clang\e1.38.21_64bit WARNING:root:LLVM version
appears incorrect (seeing "6.0", expected "3.7")
ERROR:root:Emscripten, llvm and clang versions do not match, this is
dangerous (1.35.0, "1.38.21", "1.38.21") ERROR:root:Make sure to use
the same branch in each repo, and to be up-to-date on each. See
http://kripken.github.io/emscripten-site/docs/building_from_source/LLVM-Backend.html
INFO:root:(Emscripten: Running sanity checks)
Someone has successfully compiled OpenCV to WebAssembly. You can visit the GitHub repository and follow the steps:
Get the source code:
git clone https://github.com/ucisysarch/opencvjs.git
cd opencvjs
git clone https://github.com/opencv/opencv
cd opencv
git checkout 3.1.0
Install Emscripten:
./emsdk update
./emsdk install sdk-incoming-64bit --shallow
./emsdk activate sdk-incoming-64bit
source ./emsdk_env.sh
Build OpenCV to WebAssembly.
python make.py --wasm

ERROR: Failed to build PhantomJS! Building Qt Base failed

I have Debian Linux(64-bit) in VirtualBox.
Ram: 8Gb (for Debian 4Gb)
CPU: i5-3470
If any other details are needed please tell me.
I have followed instructions written here, and here you can see the console log.
For some reason I am unable to to build phantomjs and I can't understand why its not working... Have searched a lot, but couldn't find any thread which would be about this error.
--- EDIT ---
When I executed this command:
./configure --with-openssl-includes=/usr/include/openssl-1.0/ --with-openssl-libraries=/usr/lib/openssl-1.0/
Output was this:
--with-openssl-includes=/usr/include/openssl-1.0/: invalid command-line switch
--with-openssl-libraries=/usr/lib/openssl-1.0/: invalid command-line switch
The output of the console has changed but I still get errors: https://pastebin.com/wbgi8syg
Looks like you are on stretch (or later) and that you are already aware of the libssl vs libssl1.0 case.
Therefore, if you don't have libssl-dev installed, this line will get you further:
python build.py --qt-config "-I /usr/include/openssl-1.0/ -L /usr/lib/openssl-1.0/"
If you already have it installed and my suggestion doesn't work, you can uninstall libssl-dev for the time to build phantomjs which will likely avoid having to play further with configuration related variables.

RabbitMQ C++ client for old Debian

I have an old Debian (Lenny), on which I develop an application that should connect to RabbitMQ.
I downloaded the official C++ client rabbitmq-c-0.8.0 from https://github.com/alanxz/rabbitmq-c/releases/tag/v0.8.0 , but unfortunately, I can't compile it on my old Debian:
wget https://github.com/alanxz/rabbitmq-c/archive/v0.8.0.tar.gz
tar zxvf v0.8.0.tar.gz
autoreconf -i
Result:
autoreconf -i
/usr/share/aclocal/libmcrypt.m4:17: warning: underquoted definition of AM_PATH_LIBMCRYPT
/usr/share/aclocal/libmcrypt.m4:17: run info '(automake)Extending aclocal'
/usr/share/aclocal/libmcrypt.m4:17: or see http://sources.redhat.com/automake/automake.html#Extending-aclocal
Makefile.am:6: Libtool library used but `LIBTOOL' is undefined
Makefile.am:6: The usual way to define `LIBTOOL' is to add `AC_PROG_LIBTOOL'
Makefile.am:6: to `configure.ac' and run `aclocal' and `autoconf' again.
Makefile.am:6: If `AC_PROG_LIBTOOL' is in `configure.ac', make sure
Makefile.am:6: its definition is in aclocal's search path.
autoreconf2.50: automake failed with exit status: 1
Version of automake I have (and I can't upgrade it): 1:1.10.1-3
Version of libtool I have (and I can't upgrade it as well): 1.5.26-4+lenny1
Does anyone know how to build the RabbitMQ client on the old OS I use?
Many thanks!!!
Eventually, the best solution was to move to ubuntu 14+