Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: output native stack if HAVE_EXECINFO_H defined #196

Merged
merged 1 commit into from
Sep 30, 2022

Conversation

hyj1991
Copy link
Member

@hyj1991 hyj1991 commented Sep 29, 2022

背景

alpine 等环境下缺少 execinfo 库函数导致 --build-from-source 失败。

优化

本 PR 增加 HAVE_EXECINFO_H 宏:

#if defined(__linux__) && !defined(__GLIBC__) || defined(__UCLIBC__) || \
    defined(_AIX)
#define HAVE_EXECINFO_H 0
#else
#define HAVE_EXECINFO_H 1
#endif

且仅在 HAVE_EXECINFO_H 生效时诊断报告输出 Native stack,否则输出空:

#if HAVE_EXECINFO_H
#include <cxxabi.h>
#include <execinfo.h>
#endif

#if (HAVE_EXECINFO_H)
void PrintNativeStack(JSONWriter* writer) {
  // 此时获取 native stack 详细信息
}
#else
void PrintNativeStack(JSONWriter* writer) {
  writer->json_arraystart("nativeStacks");
  writer->json_arrayend();
}
#endif

验证

已在 alpine@3.16 上验证通过。

其它

Reference:

@codecov
Copy link

codecov bot commented Sep 29, 2022

Codecov Report

Merging #196 (dd1ff19) into master (5c594a0) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##            master      #196   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            9         9           
  Lines          296       296           
=========================================
  Hits           296       296           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@legendecas legendecas merged commit 1538d8c into X-Profiler:master Sep 30, 2022
@hyj1991 hyj1991 mentioned this pull request Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants