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

GetPC() always returns nullptr #953

Closed
cieplik opened this issue Oct 4, 2023 · 1 comment · Fixed by #954
Closed

GetPC() always returns nullptr #953

cieplik opened this issue Oct 4, 2023 · 1 comment · Fixed by #954
Labels
Milestone

Comments

@cieplik
Copy link

cieplik commented Oct 4, 2023

As PC_FROM_UCONTEXT is never defined, GetPC() always returns nullptr:

void* GetPC(void* ucontext_in_void) {
#if (defined(HAVE_UCONTEXT_H) || defined(HAVE_SYS_UCONTEXT_H)) && defined(PC_FROM_UCONTEXT)
if (ucontext_in_void != nullptr) {
ucontext_t *context = reinterpret_cast<ucontext_t *>(ucontext_in_void);
return (void*)context->PC_FROM_UCONTEXT;
}
#else
(void)ucontext_in_void;
#endif
return nullptr;
}

Possible fix:

  1. update

    glog/CMakeLists.txt

    Lines 215 to 233 in 6482757

    set (_PC_FIELDS
    "gregs[REG_PC]"
    "gregs[REG_EIP]"
    "gregs[REG_RIP]"
    "sc_ip"
    "uc_regs->gregs[PT_NIP]"
    "gregs[R15]"
    "arm_pc"
    "mc_eip"
    "mc_rip"
    "__gregs[REG_EIP]"
    "__gregs[REG_RIP]"
    "ss.eip"
    "__ss.__eip"
    "ss.rip"
    "__ss.__rip"
    "ss.srr0"
    "__ss.__srr0"
    )
    by prefixing each entry with uc_mcontext./uc_mcontext-> (https://github.com/couchbase/gperftools/blob/846b775dfadb77901202ae7ddbac30ad1de7df01/m4/pc_from_ucontext.m4#L23-L43 seems to provide an up-to-date list of fields)
  2. update try_compile () invocation.

    glog/CMakeLists.txt

    Lines 251 to 252 in 6482757

    try_compile (HAVE_PC_FROM_UCONTEXT ${CMAKE_CURRENT_BINARY_DIR} ${_TMP}
    COMPILE_DEFINITIONS _GNU_SOURCE=1)
    should say -D_GNU_SOURCE=1
  3. set cache variable correctly (set (PC_FROM_UCONTEXT ${_PC_FIELD} CACHE STRING ""))
  4. define the macro correctly (#cmakedefine PC_FROM_UCONTEXT ${PC_FROM_UCONTEXT})
@sergiud sergiud added the bug label Oct 4, 2023
@sergiud sergiud added this to the 0.7 milestone Oct 4, 2023
@sergiud
Copy link
Collaborator

sergiud commented Oct 4, 2023

Good catch, thanks! Could you please submit a PR with the corresponding changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants