Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: C/C++ CI

on:
push:
branches: [ "master", "v2.14-maint" ]
branches: [ "master", "v2.14-maint", "python314" ]
pull_request:
branches: [ "master", "v2.14-maint" ]
branches: [ "master", "v2.14-maint", "python314" ]

jobs:
build-gcc:
Expand All @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v3
- name: configure
run: |
sudo apt install g++ liblzma-dev zlib1g-dev
sudo apt install g++ liblzma-dev zlib1g-dev python3-dbg
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=g++
- name: make
run: make VERBOSE=1
Expand All @@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v3
- name: configure
run: |
sudo apt install clang liblzma-dev zlib1g-dev
sudo apt install clang liblzma-dev zlib1g-dev python3-dbg
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
- name: make
run: make VERBOSE=1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ py311
compile_commands.json
arm
.claude
d
41 changes: 25 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
cmake_minimum_required(VERSION 3.10)
set(PSTACK_SOVERSION 2.17)
set(PSTACK_VERSION 2.17.7)
set(PSTACK_SOVERSION 2.18)
set(PSTACK_VERSION 2.18)
project(pstack LANGUAGES C CXX VERSION "${PSTACK_VERSION}" )
set(Python3_DEBUG_OUTPUT ON)

include (GNUInstallDirs)
enable_testing()

option(PYTHON3 "Compile with python 3 support" OFF)
option(PYTHON2 "Compile with python 2 support" ON)
option(PYTHON2 "Compile with python 2 support" OFF)
option(PYRDB "Compile with modern python 3 remote debugging" ON)
option(PTRACE_TESTS "Run extra tests that require unrestricted access to ptrace" OFF)

math(EXPR PLATFORM_BITS "${CMAKE_SIZEOF_VOID_P} * 8")
Expand All @@ -26,7 +28,7 @@ find_package(ZLIB REQUIRED)
if (PYTHON2)
find_package(Python2 COMPONENTS Development)
endif()
if (PYTHON3)
if (PYTHON3 OR PYRDB)
find_package(Python3 COMPONENTS Development)
endif()

Expand Down Expand Up @@ -67,17 +69,23 @@ if (Python3_Development_FOUND OR Python2_Development_FOUND)
set(pysrc python.cc)
endif()

if (PYRDB)
message(STATUS "will compile python remote debugging support")
add_definitions("-DWITH_PYRDB")
set(pysrc ${pysrc} pyrdb.cc)
endif()

if (PYTHON3 AND Python3_Development_FOUND)
set(pyinc "-I${Python3_INCLUDE_DIRS}")
message(STATUS "Python3_INCLUDE_DIRS are ${pyinc}")
add_definitions("-DWITH_PYTHON3")
set(pysrc ${pysrc} python3.cc pythonc.c)
set_source_files_properties(python3.cc PROPERTIES COMPILE_FLAGS ${pyinc})
set_source_files_properties(pythonc.c PROPERTIES COMPILE_FLAGS ${pyinc})
set_source_files_properties(canal.cc PROPERTIES COMPILE_FLAGS ${pyinc})
message(STATUS "Python3_INCLUDE_DIRS are ${pyinc}")
add_definitions("-DWITH_PYTHON3")
set(pyinc "-I${Python3_INCLUDE_DIRS}")
set(pysrc ${pysrc} pythonc.c python3.cc)
set_source_files_properties(python3.cc PROPERTIES COMPILE_FLAGS ${pyinc})
set_source_files_properties(pythonc.c PROPERTIES COMPILE_FLAGS ${pyinc})
set_source_files_properties(canal.cc PROPERTIES COMPILE_FLAGS ${pyinc})
endif()

if (Python2_Development_FOUND)
if (PYTHON2 AND Python2_Development_FOUND)
set(pysrc ${pysrc} python2.cc)
add_definitions("-DWITH_PYTHON2")
set_source_files_properties(python2.cc PROPERTIES COMPILE_FLAGS -I${Python2_INCLUDE_DIRS})
Expand Down Expand Up @@ -122,22 +130,21 @@ else()
endif()

add_executable(canal canal.cc)

add_executable(pstack-mkpyoff mkpyoff.cc)
add_executable(${PSTACK_BIN} pstack.cc)

target_link_libraries(procman dwelf dl)
target_link_libraries(procman_static dwelf_static dl)
target_link_libraries(${PSTACK_BIN} ${PSTACK_LINK_LIBS})
target_link_libraries(canal ${PSTACK_LINK_LIBS})
target_link_libraries(pstack-mkpyoff dwelf)
target_link_options(${PSTACK_BIN} PRIVATE -Wl,--export-dynamic)
target_link_options(canal PRIVATE -Wl,--export-dynamic)

set_target_properties(dwelf PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION "${PSTACK_SOVERSION}")
set_target_properties(procman PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION "${PSTACK_SOVERSION}")



if ((NOT (Python3_Development_FOUND)) AND PYTHON3)
if ((NOT (Python3_Development_FOUND)) AND (PYTHON3 OR PYRDB))
message(WARNING "no python3 support found")
endif()

Expand All @@ -155,8 +162,10 @@ target_link_libraries(stackusers ${PSTACK_LINK_LIBS})

install(TARGETS ${PSTACK_BIN} canal)
install(TARGETS hdmp)
install(TARGETS pstack-mkpyoff)
install(TARGETS dwelf procman dwelf_static procman_static hdbg)
install(FILES ${CMAKE_SOURCE_DIR}/pstack.1 DESTINATION share/man/man1 RENAME ${PSTACK_BIN}.1 )
install(DIRECTORY pyoff-data/ DESTINATION share/pstack)
install(DIRECTORY libpstack DESTINATION include)
install(CODE "execute_process (COMMAND setcap cap_sys_ptrace+ep ${DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/${PSTACK_BIN} RESULT_VARIABLE ret)
if (NOT ret EQUAL \"0\")
Expand Down
Loading
Loading