Bug 580414 - failed to handle debug sections for DWARF 5
Summary: failed to handle debug sections for DWARF 5
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Agent (show other bugs)
Version: unspecified   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-20 07:02 EDT by wenyan xin CLA
Modified: 2022-07-23 14:54 EDT (History)
1 user (show)

See Also:


Attachments
source code file (411 bytes, application/octet-stream)
2022-07-20 07:02 EDT, wenyan xin CLA
eugene: iplog-
Details
binary file compiled with llvm 14 with DWARF 5 (7.30 KB, application/octet-stream)
2022-07-20 07:03 EDT, wenyan xin CLA
eugene: iplog-
Details
used to reproduce on native ubuntu 22.04 with clang 14 (2.96 KB, application/x-gzip)
2022-07-22 01:46 EDT, wenyan xin CLA
eugene: iplog-
Details

Note You need to log in before you can comment on or make changes to this bug.
Description wenyan xin CLA 2022-07-20 07:02:49 EDT
Created attachment 288636 [details]
source code file

when try to load binary for debugging, the TCF reported: "Invalid FORM_STRX attribute, Error reading DWARF data".

It reported from dio_ReadFormStringIndex() function, agent/tcf/services/dwarfio.c file as folowing:

str_exception(ERR_INV_DWARF, "Invalid FORM_STRX attribute");





Attached sample source code and binary file (format = DWARF32, version = 0x0005) 
 compiled with llvm-14.0.5.1 from the source with DWARF 5.

compared with DWARF 4 that compiled with llvm 13, the following section are new:

.debug_line_str
.debug_addr
.debug_str_offsets


this test case works fine with GDB.
Comment 1 wenyan xin CLA 2022-07-20 07:03:38 EDT
Created attachment 288637 [details]
binary file compiled with llvm 14 with DWARF 5
Comment 2 Eugene Tarassov CLA 2022-07-20 13:38:14 EDT
I cannot reproduce.
TCF DWARF reader test shows no errors.

Running the file fails:
eugene@gate:~/projects/tcf/bugs/580414$ ./main.out
-bash: ./main.out: cannot execute binary file: Exec format error

Please, provide "steps to reproduce".
Comment 3 wenyan xin CLA 2022-07-20 19:34:35 EDT
The attached file is a kernel module for VxWorks.
It cannot run form shell. And this issue is also for all of arch (arm, ppc and x86 etc.).

I don't know how to reproduce this issue with Linux kernel module.
Can the TCF debug a kernel module on native Linux?
It seems it works fine for user application.

Could you just load the kernel module and try to start the "mytest" function with TCF? Since the TCF will report error before really executing it.
Comment 4 Eugene Tarassov CLA 2022-07-21 13:27:55 EDT
> Can the TCF debug a kernel module on native Linux?

No, not a kernel module. TCF can debug Linux application. If it is a problem with DWARF, then it should be reproducible by re-building the test as Linux application. If same code works as application, but does not work as kernel module, it is strong indication it is not a TCF problem.

> Could you just load the kernel module and try to start the "mytest"
> function with TCF?

No, I cannot. We don't have VxWorks around here in AMD.
Comment 5 wenyan xin CLA 2022-07-22 01:34:07 EDT
I can reproduce this issue on Ubuntu 22.04 LTS with Ubuntu clang version 14.0.0-1ubuntu1 and native eclipse with TCF (eclipse-cpp-2022-06-R-linux-gtk, and TCF).

I built the test case with the attached makfile and c source code sample.

When I debug with TCF, it can stop in _start function, then continue, the main function can not stop, and "Invalid FORM_STRX attribute" reported.

But if I built with -gdwarf-4, the main function will stop.



eclipse-cpp-2022-06-R-linux-gtk-x86_64.tar.gz and TCF.

pek-ide-u22: agent$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04 LTS
Release:        22.04
Codename:       jammy


pek-ide-u22: c$ clang --version
Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Comment 6 wenyan xin CLA 2022-07-22 01:46:57 EDT
Created attachment 288639 [details]
used to reproduce on native ubuntu 22.04 with clang 14
Comment 7 wenyan xin CLA 2022-07-22 03:57:29 EDT
In other words, the main can be stopped when built with DWRARF 4.

But the main can not stop with DWARF 5 and reported "Invalid FORM_STRX attribute" error.
Comment 8 Eugene Tarassov CLA 2022-07-23 14:53:57 EDT
Fixed.
Thanks!