Sign in
Sign up
Explore
Enterprise
Education
Search
Help
Terms of use
About Us
Explore
Enterprise
Education
Gitee Premium
Gitee AI
AI teammates
Sign in
Sign up
Fetch the repository succeeded.
description of repo status
Open Source
>
Other
>
Operation System
&&
Donate
Please sign in before you donate.
Cancel
Sign in
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
Watch
Unwatch
Watching
Releases Only
Ignoring
171
Star
431
Fork
1.6K
openEuler
/
community
Closed
Code
Issues
659
Pull Requests
15
Wiki
Insights
Pipelines
Service
Quality Analysis
Jenkins for Gitee
Tencent CloudBase
Tencent Cloud Serverless
悬镜安全
Aliyun SAE
Codeblitz
SBOM
DevLens
Don’t show this again
Update failed. Please try again later!
Remove this flag
Content Risk Flag
This task is identified by
as the content contains sensitive information such as code security bugs, privacy leaks, etc., so it is only accessible to contributors of this repository.
GDB无法调试__thread变量
Backlog
#I42988
Bug
pengjiong
Opened this issue
2021-07-24 17:20
<!-- #请根据issue的类型在标题右侧下拉框中选择对应的选项(需求、缺陷或CVE等)--> <!-- #请根据issue相关的版本在里程碑中选择对应的节点,若是与版本无关,请选择“不关联里程碑”--> 【标题描述】 使用GDB调试带有 __thread 变量的程序,在GDB中无法打印 __thread 变量,报错“Cannot find thread-local storage for process ” 【环境信息】 硬件信息: 华为TaiShan 2280 V2 * Kupeng 920 软件信息: 1) openEuler release 20.03 (LTS) 2) Linux version 4.19.90-2003.4.0.0036.oe1.aarch64 (abuild@obs-worker-003) (gcc version 7.3.0 (GCC)) #1 SMP Mon Mar 23 19:06:43 UTC 2020 3) GNU gdb (GDB) EulerOS 8.3.1-11.oe1 【问题复现步骤】 具体操作步骤 1. 准备测试代码如下: #include <pthread.h> #include <stdio.h> struct C { int x = 42; }; __thread C c; int main() { printf("%d\n", c.x); } 编译: gcc -g thread_test.cpp -pthread 2. 使用gdb调试编译输出的二进制 a.out. gdb a.out ``` (gdb) b main Breakpoint 1 at 0x4006cc: file thread_test.cpp, line 7. (gdb) r Starting program: a.out Missing separate debuginfos, use: dnf debuginfo-install glibc-2.28-36.oe1.aarch64 warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available. Breakpoint 1, main () at thread_test.cpp:7 7 printf("%d\n", c.x); (gdb) p c Cannot find thread-local storage for process 2760355, executable file a.out: Cannot find thread-local variables on this target ``` 出现概率(是否必现,概率性错误) 必现 【预期结果】 gdb p能够正常打印变量值 【实际结果】 gdb报错 【其他】 网上搜索到两个相关的问题,但是貌似没有解决。 https://github.com/kunpengcompute/Kunpeng/issues/17 https://gitee.com/src-openeuler/glibc/issues/I1HAME 另外,通过网上搜索得知,问题产生的原因可能是系统的 libpthread.so 被 strip 了: ``` # file /usr/lib64/libthread_db-1.0.so /usr/lib64/libthread_db-1.0.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), statically linked, BuildID[sha1]=xxx, for GNU/Linux 3.7.0, stripped # file /usr/lib64/libpthread-2.28.so /usr/lib64/libpthread-2.28.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=xxx, for GNU/Linux 3.7.0, stripped ```
<!-- #请根据issue的类型在标题右侧下拉框中选择对应的选项(需求、缺陷或CVE等)--> <!-- #请根据issue相关的版本在里程碑中选择对应的节点,若是与版本无关,请选择“不关联里程碑”--> 【标题描述】 使用GDB调试带有 __thread 变量的程序,在GDB中无法打印 __thread 变量,报错“Cannot find thread-local storage for process ” 【环境信息】 硬件信息: 华为TaiShan 2280 V2 * Kupeng 920 软件信息: 1) openEuler release 20.03 (LTS) 2) Linux version 4.19.90-2003.4.0.0036.oe1.aarch64 (abuild@obs-worker-003) (gcc version 7.3.0 (GCC)) #1 SMP Mon Mar 23 19:06:43 UTC 2020 3) GNU gdb (GDB) EulerOS 8.3.1-11.oe1 【问题复现步骤】 具体操作步骤 1. 准备测试代码如下: #include <pthread.h> #include <stdio.h> struct C { int x = 42; }; __thread C c; int main() { printf("%d\n", c.x); } 编译: gcc -g thread_test.cpp -pthread 2. 使用gdb调试编译输出的二进制 a.out. gdb a.out ``` (gdb) b main Breakpoint 1 at 0x4006cc: file thread_test.cpp, line 7. (gdb) r Starting program: a.out Missing separate debuginfos, use: dnf debuginfo-install glibc-2.28-36.oe1.aarch64 warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available. Breakpoint 1, main () at thread_test.cpp:7 7 printf("%d\n", c.x); (gdb) p c Cannot find thread-local storage for process 2760355, executable file a.out: Cannot find thread-local variables on this target ``` 出现概率(是否必现,概率性错误) 必现 【预期结果】 gdb p能够正常打印变量值 【实际结果】 gdb报错 【其他】 网上搜索到两个相关的问题,但是貌似没有解决。 https://github.com/kunpengcompute/Kunpeng/issues/17 https://gitee.com/src-openeuler/glibc/issues/I1HAME 另外,通过网上搜索得知,问题产生的原因可能是系统的 libpthread.so 被 strip 了: ``` # file /usr/lib64/libthread_db-1.0.so /usr/lib64/libthread_db-1.0.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), statically linked, BuildID[sha1]=xxx, for GNU/Linux 3.7.0, stripped # file /usr/lib64/libpthread-2.28.so /usr/lib64/libpthread-2.28.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=xxx, for GNU/Linux 3.7.0, stripped ```
Comments (
4
)
Sign in
to comment
Status
Backlog
Backlog
已挂起
Fixing
Confirmed
Done
Accepted
Canceled
Assignees
Not set
Labels
sig/sig-Community
Not set
Projects
Unprojected
Unprojected
Milestones
No related milestones
No related milestones
Pull Requests
None yet
None yet
Successfully merging a pull request will close this issue.
Branches
No related branch
Branches (
-
)
Tags (
-
)
Planed to start   -   Planed to end
-
Top level
Not Top
Top Level: High
Top Level: Medium
Top Level: Low
Priority
Not specified
Serious
Main
Secondary
Unimportant
Duration
(hours)
参与者(4)
Go
1
https://gitee.com/openeuler/community.git
git@gitee.com:openeuler/community.git
openeuler
community
community
Going to Help Center
Search
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register