cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
rwk
Visitor
Visitor
1,101 Views
Registered: ‎06-18-2018

Issues with petalinux-utils --gdb

Hello.

I am going through the UG1144 PetaLinux Tools Reference Guide v2019.2 in order to learn to use the tools.

When working on chapter 9 Debugging I discovered that the petalinux-utils --gdb tool issued an error message, even when showing --help.

E.g.,

 

user@host:/opt/pkg/projects/test_petalinux$ petalinux-util --gdb --help
petalinux-util             (c) 2005-2019 Xilinx, Inc.

environment: line 292: get_subsystem: command not found
This is the GNU debugger.  Usage:

    gdb [options] [executable-file [core-file or process-id]]
    gdb [options] --args executable-file [inferior-arguments ...]

Selection of debuggee and its files:

  --args             Arguments after executable-file are passed to inferior
...

 

The error is :

 

environment: line 292: get_subsystem: command not found

 

This happens with all calls to petalinux-utils --gdb as can be seen below :

 

$ petalinux-util --gdb --foo
environment: line 292: get_subsystem: command not found
arm-none-eabi-gdb: unrecognized option '--foo'
Use `arm-none-eabi-gdb --help' for a complete list of options.

 

or

 

$ petalinux-util --gdb images/linux/vmlinux 
environment: line 292: get_subsystem: command not found
GNU gdb (Linaro GDB 2019.03) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from images/linux/vmlinux...done.

 

 

 

 

I don't know if this error is important or not but I can't debug neither the Kernel, neither an application as explained in Chapter 9 of UG1144.

 

Kernel debug example (pages 86-87 in UG1144) :

In one terminal I launch QEMU

 

$ petalinux-boot --qemu --kernel
INFO: sourcing build tools
INFO: The image provided is a zImage
INFO: Set QEMU tftp to /opt/pkg/projects/demesys_test_petalinux/images/linux 
INFO: TCP PORT is free 
INFO: Starting arm QEMU
INFO:  qemu-system-aarch64 -M arm-generic-fdt-7series -machine linux=on   -serial mon:stdio -serial /dev/null -display none -kernel /opt/pkg/projects/demesys_test_petalinux/build/qemu_image.elf -gdb tcp::9000 -dtb /opt/pkg/projects/demesys_test_petalinux/images/linux/system.dtb  -net nic,netdev=eth0 -netdev user,id=eth0,tftp=/opt/pkg/projects/demesys_test_petalinux/images/linux -net nic -device loader,addr=0xf8000008,data=0xDF0D,data-len=4 -device loader,addr=0xf8000140,data=0x00500801,data-len=4 -device loader,addr=0xf800012c,data=0x1ed044d,data-len=4 -device loader,addr=0xf8000108,data=0x0001e008,data-len=4 -device loader,addr=0xF8000910,data=0xF,data-len=0x4
...

 

From this I can see that GDB is running on port 9000 because of -gdb tcp::9000 

In the other terminal I start GDB

 

$ cd images/linux
$ petalinux-util --gdb vmlinux
environment: line 292: get_subsystem: command not found
GNU gdb (Linaro GDB 2019.03) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from images/linux/vmlinux...done.
(gdb) 

 

 From here I continue to connect to the target :

 

(gdb) target remote :9000
Remote debugging using :9000
warning: while parsing target description (at line 1): Could not load XML document "arm-sys.xml"
warning: Could not load XML target description; ignoring
Truncated register 18 in remote 'g' packet

 

This does interrupt the kernel running in QEMU (e.g., I cannot type in the shell in the embedded linux kernel), also I cannot continue in GDB

 

(gdb) continue
The program is not being run.

 

 

 

 

App debug example (pages 93-96 of UG1144) :

On the QEMU instance running the embedded linux kernel :

 

root@plnx:~# gdbserver host:1234 /usr/bin/mysapp 
Process /usr/bin/myapp created; pid = 1189
Listening on port 1234

 

On the host terminal :

 

user@host:...$ petalinux-util --gdb build/tmp/work/cortexa9t2hf-neon-xilinx-linux-gnueabi/myapp/1.0-r0/image/usr/bin/myapp 
environment: line 292: get_subsystem: command not found
GNU gdb (Linaro GDB 2019.03) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...

warning: A handler for the OS ABI "GNU/Linux" is not built into this configuration
of GDB.  Attempting to continue with the default armv7 settings.

Reading symbols from build/tmp/work/cortexa9t2hf-neon-xilinx-linux-gnueabi/myapp/1.0-r0/image/usr/bin/myapp...done.
(gdb) 

 

 

There are two things in the listing above that are strange :

1) This first thing that is strange is :

 

This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=arm-none-eabi".

 

I was not expecting arm-none-eabi as the target ABI, this may be wrong.

2) Then this warning message :

 

warning: A handler for the OS ABI "GNU/Linux" is not built into this configuration
of GDB.  Attempting to continue with the default armv7 settings.

 

 

I can however, still connect to the embedded system :

 

(gdb) target remote :1234
Remote debugging using :1234
warning: A handler for the OS ABI "GNU/Linux" is not built into this configuration
of GDB.  Attempting to continue with the default armv7 settings.

0xb6fd7a40 in ?? ()
(gdb) 

 

 

If I continue, the program executes on the target :

 

(gdb) continue 
Continuing.
[Inferior 1 (process 1189) exited normally]
(gdb) 

 

target :

 

root@plnx:~# gdbserver host:1234 /usr/bin/myapp 
Process /usr/bin/myapp created; pid = 1189
Listening on port 1234
random: crng init done
Remote debugging from host 10.0.2.2
Hello World! from application

Child exited with status 0

 

 

This means that at least the connection between GDB and the GDBserver is OK

But when I want to put a breakpoint, things seems strange (listing seems not ok. breakpoint seems not at correct place) :

 

(gdb) list
93	# ifdef __va_arg_pack
94	__fortify_function int
95	fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...)
96	{
97	  return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
98				__va_arg_pack ());
99	}
100	
101	__fortify_function int
102	printf (const char *__restrict __fmt, ...)
(gdb) b mysapp.c:main 
Breakpoint 1 at 0x478: file /usr/include/bits/stdio2.h, line 107.
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x478

Command aborted.
(gdb)

 

Then I cannot continue or do anything in GDB, so I kill the program being run and therefore the GDBserver on the target terminates and returns the to shell.

 

 

 

Any help would be appreciated.

I feel there is a problem with the ABI not being the correct one, I feel that --target=arm-none-eabi is incorrect and that therefore GDB does not interpret things correctly. This seems coherent with the warning message received in the app debug example.

For the kernel debug example it seems the configuration cannot be read.

Is it possible that those errors are linked to the fact that the petalinux-utils --gdb fails a step because of some bug, resulting in this error message ?

 

environment: line 292: get_subsystem: command not found

 

And this could this mean that petalinux-utils --gdb cannot get the correct environment (configuration)  because get_subsystem usually takes care of this ?

 

 

Thank you very much.

Regards,
Rick

5 Replies
tllilleh
Visitor
Visitor
766 Views
Registered: ‎07-16-2018

I am seeing this issue in Petalinux 2020.1.  Is there any resolution?

For what it is worth, I did not see this issue in Petalinux 2018.3 - I was able to use petalinux-util --gdb along with gdbserver to debug applications on hardware.

0 Kudos
ottob
Explorer
Explorer
440 Views
Registered: ‎05-26-2017

I'm seeing the same problem in 2020.2. ("Cannot Insert Breakpoint 1"). 

The whole reason I'm trying out GDB is that the system debugger is not stable (skipping breakpoints)

Seems to me like the Xilinx software guys were sleeping most of 2020 as this release is full of bugs 

 

 

0 Kudos
ottob
Explorer
Explorer
426 Views
Registered: ‎05-26-2017

Looks like the gdb generated in the sdk (bitbake meta-toolchain) works better. Also, if you want to run this from Eclipse "Remote C/C++ Debug" make sure you set the dropbear PACKAGECONFIG = ' '  in a bbappend file. Otherwise it wont allow the ciphers that Eclipse uses. Lastly you'll want to run this in .gdbinit to avoid stopping on a illegal instruction in libcrypto "handle SIGILL nostop"

0 Kudos
abouassi
Moderator
Moderator
310 Views
Registered: ‎03-25-2019

Hi @rwk,

Please check the answer in this thread.

Best regards,
Abdallah
-------------------------------------------------------------------------------
Please don't forget to reply, kudo and accept as a solution
0 Kudos
maruyama
Xilinx Employee
Xilinx Employee
206 Views
Registered: ‎02-09-2009

Hello,

I could solve similar issue by compiling application program with "-g -no-pie -fno-PIE" options.

These potions mean adding debug information and setting to non position independent executable.

I hope this helps,

Best regards