-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Description
Hello,
I'm an Android-Source-Code and ARM-GPU-DRIVER-Source-Code user.
When I try to use default compile tool-chain clang-18.0.1 (prebuilts/clang/host/linux-x86/clang-r522817/),
There is something wrong,
I can NOT use gdb to debug the clang-18.0.1 generated ELF file.
When I update from clang-18.0.1 to clang-19.0.1(prebuilts/clang/host/linux-x86/clang-r536225/bin/clang), the problem still exist.
I sincerely want yours can kindly help me about below Question_1 and Question_2.
===
1.Currently, the GPU-DRIVER-Source-Code can be compiled and used in the Android-Source-Code successfully, and It's output the malisc_host ELF file.
2.But when I try to use "gdb malisc_host" command to debug, It show below error message.
Android_15$ gdb ./malisc_host
BFD: malisc_host: unable to initialize decompress status for section .debug_loclists
malisc_host: not in executable format: file format not recognized
3.But the malisc_host can be debug by latest lldb-21.0.0 tool.
lldb ./malisc_host //OK it works
4.The the output binary file malisc_host can be debug by lldb, but can NOT be debug by gdb.
4.1. But the lldb is not a powerful tool, It can NOT stop on my added breakpoints.
4.2. So, I strongly want to use the gdb to debug the malisc_host ELF.
- And when I use the readelf command, it output below Warning message.
Warning message .debug_str unsupported compress type: 2
Android_15$ readelf -p .comment out/soong/.intermediates/product/malisc__host/linux_glibc_x86_64/unstripped/malisc_host
readelf: Warning: section '.debug_str' has unsupported compress type: 2
String dump of section '.comment':
[ 0] GCC: (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
[ 2a] GCC: (GNU) 4.8.3
[ 3c] Android (11967740, +pgo, +bolt, +lto, +mlgo, based on r522817) clang version 18.0.1 (https://android.googlesource.com/toolchain/llvm-project d8003a456d14a3deb8054cdaa529ffbf02d9b262)
[ f3] Linker: LLD 18.0.1
Above readelf command output the warning message:
5.1. I think in the clang generated ELF 's file header,
There must be something's version or format UN-Match with gdb's expectation.
that lead to gdb can not correctly recognize the malisc_host's format.
Questions_1
Q1.1 Does this message mean the malisc_host's file header have be corrupted by clang,
or clang give a different value to the malisc_host ELF's debug_section.
Q1.2 How can we fix this error? and make gdb can debug the clang‘s output ELF malisc_host?
Q1.3 Is this error that is an already known problem in clang-18.0.1/clang-19.0.1?
Below is my Machine info
1.The system's is Ubuntu 20.0.4
Android_15$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal
2.The clang/clang++ used to compile Android-Source-Code is 18.0.1.
Android_15$ ./prebuilts/clang/host/linux-x86/clang-r522817/bin/clang --version
Android (11967740, +pgo, +bolt, +lto, +mlgo, based on r522817) clang version 18.0.1
(https://android.googlesource.com/toolchain/llvm-project d8003a456d14a3deb8054cdaa529ffbf02d9b262)
Target: x86_64-unknown-linux-gnu
Thread model: posix
3.The gdb used to debug is 9.2:
Android_15$ gdb --version
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.2) 9.2
Copyright (C) 2020 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.
4.But when I use the default tool-chain clang-18.0.1(prebuilts/clang/host/linux-x86/clang-r522817/bin/clang++), compile a simple hello_world.cpp,
the output ELF a.out can be debug by gdb tool.
Android_15$ ./prebuilts/clang/host/linux-x86/clang-r522817/bin/clang++ hello_world.cpp -g
Android_15$ gdb -tui -args a.out //OK the gdb work correctly.
Below is my file
command's output for each ELF file.
- clang's info:
Android_15$ file ./prebuilts/clang/host/linux-x86/clang-r522817/bin/clang++
clang++:
ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
statically linked,
Go BuildID=CaRjX2xOY2sn3Eu50jD5/sx0sdGGnrBuwdu7dEfC8/RbpQ82--tce2MQnXDd-h/BpbhCXNCzLlerptoXX1D,
with debug_info,
not stripped
- malisc_host's info
Android_15$ file ./malisc_host
./malisc_host:
ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV),
dynamically linked,
interpreter /lib64/ld-linux-x86-64.so.2,
for GNU/Linux 2.6.24,
BuildID[xxHash]=300f2d32f4dbacdf,
with debug_info,
not stripped
- a.out's info:
Android_15$ file ./a.out
a.out info:
ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV),
dynamically linked,
interpreter /lib64/ld-linux-x86-64.so.2,
for GNU/Linux 3.2.0,
with debug_info,
not stripped
- gdb's info
Android_15$ file /usr/bin/gdb
/usr/bin/gdb:
ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux),
dynamically linked,
interpreter /lib64/ld-linux-x86-64.so.2,
BuildID[sha1]=f5f8723dbedf08022a36e8449e29e717e6547316,
for GNU/Linux 3.2.0,
stripped
- readelf ./malisc_host error message .debug_str unsupported compress type: 2
Android_15$ readelf -p .comment ./malisc_host
readelf: Warning: section '.debug_str' has unsupported compress type: 2
String dump of section '.comment':
[ 0] GCC: (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
[ 2a] GCC: (GNU) 4.8.3
[ 3c] Android (11967740, +pgo, +bolt, +lto, +mlgo, based on r522817) clang version 18.0.1 (https://android.googlesource.com/toolchain/llvm-project d8003a456d14a3deb8054cdaa529ffbf02d9b262)
[ f3] Linker: LLD 18.0.1
Questions_2
I see the version info between malisc_host and a.out is different.
./clang++ : no version info.
./malisc_host : for GNU/Linux 2.6.24,
./a.out : for GNU/Linux 3.2.0,
/usr/bin/gdb : for GNU/Linux 3.2.0,
Q2.1 Why did the malisc_host's have a different version info?
Q2.2 The malisc_host's version info generated base on what?
Q2.3 Did the "gdb malisc_host: BFD: can not recongize" error message,
caused by the gbd and malisc_host have different version info?
Q2.4 For make clang generate a malisc_host switch it's version from GNU/Linux 2.6.24 to GNU/Linux 3.2.0,
Can we specific a version info for malisc_host,
or we need replace some link-libarary for the malisc_host?