Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

GetPC() always returns nullptr #953

@cieplik

Description

@cieplik

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})

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions