Author Topic: Need help setting up GBD embedded device cross-compiled  (Read 298 times)

JimmieC

  • Senior Community Member
  • Posts: 466
  • Hero Points: 16
Need help setting up GBD embedded device cross-compiled
« on: March 24, 2021, 04:33:29 pm »
SE Pro v25.0.1.0 64-bit running in Ubuntu 20.04.

I am new to Linux and GDB. However, with the help from a colleague, we got the GDB running on VSCode (as that is what he uses). I would like to get it working on SE.

I am debugging an embedded Linux device. Although I am debugging from Ubuntu, the embedded code is technically cross-compiled. It is compiled on Ubuntu but using an older compiler, gcc 4.4.4. Here is the GDB path:

"/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-gdb"

I looked up GDB in the SE Help->Index. However, it seems that I am too far down the Linux learning curve. I still could not figure out what to do.

I would appreciate some "newbie" help on this.  :)

JimmieC

  • Senior Community Member
  • Posts: 466
  • Hero Points: 16
Re: Need help setting up GBD embedded device cross-compiled
« Reply #1 on: March 24, 2021, 04:36:52 pm »
More details:
The way I use the GDB in VSCode is:

1) telnet to the embedded device and run ./gdbserver :51000 <program name>
2) VSCode launch the debugger

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3226
  • Hero Points: 459
Re: Need help setting up GBD embedded device cross-compiled
« Reply #2 on: March 29, 2021, 02:09:56 pm »
First step is to point SlickEdit at that GDB:

     Debug > Debugger Options... > Configurations

Then add the path to GDB to the list of configurations.

Now you can attach to the remote debugger.

     Debug > Attach Debugger > GDB > Attatch to Remote target

Give it the path to a copy of the program you are going to debug.
Otherwise, you won't have any debugging information.

     (x) Connect via socket, give the address of the remote machine you telnet into, and the port (51000)

Set the GDB configuration to use the GDB you just set up.

JimmieC

  • Senior Community Member
  • Posts: 466
  • Hero Points: 16
Re: Need help setting up GBD embedded device cross-compiled
« Reply #3 on: March 29, 2021, 07:03:15 pm »
Hi Dennis,

Thanks for the primer. Unfortunately, I failed at step 1. I got an error message:
-------------------------------------
"/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-gdb" does not appear to be a compatible version of GDB.

The required version is GDB 5.1 or greater.
The identified version was "".:  GDB has terminated prematurely
[/size]
--------------------------------------------
It looks like my debugger version is too old. Unforunately, the embedded world has products with long life cycles and updating to match new custom hardware is arduous. I can use SE for editing and keep VSCode for debugging. Darn it.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3226
  • Hero Points: 459
Re: Need help setting up GBD embedded device cross-compiled
« Reply #4 on: March 29, 2021, 08:37:33 pm »
What is the output of "/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-gdb" -version

Some builds of GDB do not properly identify the GDB version they are based on.  This is something that SlickEdit has checked, historically, because, back in the day, when we all rode horses to work, some versions of GDB did not support the machine interface command set.  If your GDB works with VSCode, it probably is new enough, because the folks who wrote VSCode have never had to deal with early versions of GDB.

Either way, that message is just a warning at this point, as you'll see, your GDB was still added to the list of configurations.

hs2

  • Senior Community Member
  • Posts: 2752
  • Hero Points: 291
Re: Need help setting up GBD embedded device cross-compiled
« Reply #5 on: March 29, 2021, 08:39:57 pm »
I think it’s possible to update the cross-gdb. Sure, the build toolchain can sometimes not updated for legacy products for various reasons. But gdb is not directly related to the build toolchain and is usually backwards compatible to legacy debug (dwarf) information.
I’d give it a try to grab a newer cross-gdb.

JimmieC

  • Senior Community Member
  • Posts: 466
  • Hero Points: 16
Re: Need help setting up GBD embedded device cross-compiled
« Reply #6 on: March 29, 2021, 10:46:18 pm »
>> when we all rode horses to work
Funny! :)    Before the industrial revolution but after dinasours and the wheel


I see your point that if it runs in VSC it can probably run in SE.

I ignored the warning about the GDB version as you suggested. I setup the File, Socket Addr & Port, & GDB Configuration. Also, I set the timeout to the max of 10 seconds.
I get the error:    "Error starting debugger:  GDB has terminated prematurely"

When I check the remote unit via telnet, it is still listening and waiting.

Just for grins, I tried to connect via Debug->Attach Debugger->Attach to Remote Process (LLDB). This brings up a debug session in SE. Also, in telnet, the remote device shows "Remote debugging from host 192.168.169.2". However, nothing in the SE debug session is working and it exits after 20 seconds or so.

I don't think that it is supposed to work with LLDB, but I tried it on a whim and thought it might offer a clue.

Lastly, I captured this from the DEBUG CONSOLE in VSCode:
GNU gdb (GDB) 7.1
Copyright (C) 2010 Free Software Foundation, Inc.

So, even though my compiler is 4.4.4, it seems the GDB is 7.1. New to Linux, so I don't know if 7.1 is the GDB executable running on Ubuntu, the GDB Server running on the embedded device, or both.

hs2:
Thanks for the suggestion. I will try that after giving up on the current GDB. Not there yet, but I can see it on the horizon.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3226
  • Hero Points: 459
Re: Need help setting up GBD embedded device cross-compiled
« Reply #7 on: March 29, 2021, 11:05:35 pm »
7.1 is new enough.  My next suspicion would be that GDB expects a certain LD_LIBRARY_PATH to be set up to find shared libraries.  What happens if you try to run that version of GDB from SlickEdit's Build window.  Pass along -version just to see if it will run and report back.

Also, if you happen to be running 32-bit SlickEdit and the GDB is 64-bit, that would be a problem too.


JimmieC

  • Senior Community Member
  • Posts: 466
  • Hero Points: 16
Re: Need help setting up GBD embedded device cross-compiled
« Reply #8 on: March 29, 2021, 11:46:49 pm »
64-bit Ubuntu 20.04, 64-bit SlickEdit

Here is the output from the Build window:

SE devVM@devVM Documents]$
[SE devVM@devVM Documents]$ cd ..
[SE devVM@devVM devVM]$ cd ..
[SE devVM@devVM home]$ cd ..
[SE devVM@devVM /]$ arm-fsl-linux-gnueabi-gdb -version
sh: 1: arm-fsl-linux-gnueabi-gdb: not found
[SE devVM@devVM /]$ cd opt
[SE devVM@devVM opt]$ cd freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0
[SE devVM@devVM gcc-4.4.4-glibc-2.11.1-multilib-1.0]$ cd arm-fsl-linux-gnueabi/bin
[SE devVM@devVM bin]$ arm-fsl-linux-gnueabi-gdb -version
sh: 1: arm-fsl-linux-gnueabi-gdb: not found
[SE devVM@devVM bin]$ ./arm-fsl-linux-gnueabi-gdb -version
arm-fsl-linux-gnueabi-gdb: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
Aborted (core dumped)
[SE devVM@devVM bin]$



JimmieC

  • Senior Community Member
  • Posts: 466
  • Hero Points: 16
Re: Need help setting up GBD embedded device cross-compiled
« Reply #9 on: March 30, 2021, 12:30:59 am »
I was looking around on the web about the error:
loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.

I found one suggestion to prepend the command with LC_ALL=C.
I tried it and got this from the SE Build window:

SE devVM@devVM bin]$ env LC_ALL=C; ./arm-fsl-linux-gnueabi-gdb -version
GJS_DEBUG_TOPICS=JS ERROR;JS LOG
USER=devVM
SSH_AGENT_PID=1740
XDG_SESSION_TYPE=x11
SHLVL=0
LD_LIBRARY_PATH=
HOME=/home/devVM
QT4_IM_MODULE=ibus
DESKTOP_SESSION=ubuntu
GIO_LAUNCHED_DESKTOP_FILE=/home/devVM/.local/share/applications/SlickEdit Pro-25.0.1.0.desktop
GTK_MODULES=gail:atk-bridge
GNOME_SHELL_SESSION_MODE=ubuntu
MANAGERPID=1526
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
GIO_LAUNCHED_DESKTOP_FILE_PID=85203
VSLICKINCLUDE=/home/devVM/slickedit-pro2020/macros
VSDIR=/home/devVM/slickedit-pro2020/bin/
IM_CONFIG_PHASE=1
LOGNAME=devVM
GTK_IM_MODULE=ibus
_=/usr/bin/dbus-update-activation-environment
JOURNAL_STREAM=8:38655
SLICKEDITCONFIG=/home/devVM/.slickedit/
XDG_SESSION_CLASS=user
USERNAME=devVM
SLKRUNS=1
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
WINDOWPATH=2
SLICKEDITCONFIGVERSION=/home/devVM/.slickedit/25.0.1/
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/devVM/slickedit-pro2020/bin/
SESSION_MANAGER=local/devVM:@/tmp/.ICE-unix/1839,unix/devVM:/tmp/.ICE-unix/1839
INVOCATION_ID=eaa1018ff7f64b9d947f6f9088283c48
XDG_RUNTIME_DIR=/run/user/1000
XDG_MENU_PREFIX=gnome-
DISPLAY=:0
LANG=en_US.UTF-8
XDG_CURRENT_DESKTOP=ubuntu:GNOME
VSLICKBITMAPS=/home/devVM/slickedit-pro2020/bitmaps:plugin://
XAUTHORITY=/run/user/1000/gdm/Xauthority
XDG_SESSION_DESKTOP=ubuntu
XMODIFIERS=@im=ibus
VSLICKBIN=/home/devVM/slickedit-pro2020/bin/
VSLICKUTF8=1
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
SHELL=/bin/bash
VSLICKMACROS=/home/devVM/slickedit-pro2020/macros:plugin://
QT_ACCESSIBILITY=1
GDMSESSION=ubuntu
VSLICKMISC=/home/devVM/slickedit-pro2020/
GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
GJS_DEBUG_OUTPUT=stderr
VSLICKPATH=/home/devVM/.slickedit/25.0.1/:/home/devVM/slickedit-pro2020/bin/:/home/devVM/slickedit-pro2020/:/home/devVM/slickedit-pro2020/macros
VSLICKUNICODECALLS=1
QT_IM_MODULE=ibus
PWD=/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
CLUTTER_IM_MODULE=ibus
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
VSLICKBIN1=/home/devVM/slickedit-pro2020/bin/
VSLICKBUILDALLOWUTF8=1
QT_PLUGIN_PATH=
VSROOT=/home/devVM/slickedit-pro2020/
LC_ALL=C
arm-fsl-linux-gnueabi-gdb: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
Aborted (core dumped)
[SE devVM@devVM bin]$

JimmieC

  • Senior Community Member
  • Posts: 466
  • Hero Points: 16
Re: Need help setting up GBD embedded device cross-compiled
« Reply #10 on: March 30, 2021, 08:00:28 pm »
Additional info:

I found that I can run GDB from the command line. I'm not very good at running it (following instructions from YT & Google forums).
I can list functions and set and hit breakpoints on the remote target.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3226
  • Hero Points: 459
Re: Need help setting up GBD embedded device cross-compiled
« Reply #11 on: March 30, 2021, 11:04:33 pm »
If you can run it from a shell outside the editor, then you just need to determine what is different in the environment there than from SlickEdit.  Run 'env' to see the environment from the shell and compare.
 LD_LIBRARY_PATH is a likely reason.

Also, how are you launching SlickEdit, from the desktop or using invoking 'vs' from the shell?  If you launch form the shell, you'll inherit the environment.

JimmieC

  • Senior Community Member
  • Posts: 466
  • Hero Points: 16
Re: Need help setting up GBD embedded device cross-compiled
« Reply #12 on: April 01, 2021, 04:00:18 pm »
>> Also, how are you launching SlickEdit
I was launching it via icon from the "Activities" search tool. Now, I am launching SE via terminal with ./vs.

The debugger is working when I launch from the terminal. So, you suspicions about the environment were correct. I don't really care about fixing the environment for launching from the icon. I will just use a terminal launch if I need to run GDB.

Thanks: finally debugging the cross-compiled, embedded, remote, target with SE.