2007-12-03 17:43:49 +01:00
|
|
|
project(pahole C)
|
2008-11-20 16:54:39 +01:00
|
|
|
cmake_minimum_required(VERSION 2.4.8)
|
2007-12-03 17:43:49 +01:00
|
|
|
|
|
|
|
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} )
|
2006-12-12 03:37:23 +01:00
|
|
|
|
2007-01-30 22:07:28 +01:00
|
|
|
# Try to parse this later, Helio just showed me a KDE4 example to support
|
|
|
|
# x86-64 builds.
|
|
|
|
# the following are directories where stuff will be installed to
|
|
|
|
set(__LIB "" CACHE STRING "Define suffix of directory name (32/64)" )
|
|
|
|
|
2007-02-25 20:43:59 +01:00
|
|
|
macro(_set_fancy _var _value _comment)
|
2007-01-30 22:07:28 +01:00
|
|
|
if (NOT DEFINED ${_var})
|
|
|
|
set(${_var} ${_value})
|
|
|
|
else (NOT DEFINED ${_var})
|
|
|
|
set(${_var} "${${_var}}" CACHE PATH "${_comment}")
|
|
|
|
endif (NOT DEFINED ${_var})
|
2007-02-25 20:43:59 +01:00
|
|
|
endmacro(_set_fancy)
|
2007-01-30 22:07:28 +01:00
|
|
|
|
2006-12-12 03:37:23 +01:00
|
|
|
# where to look first for cmake modules,
|
|
|
|
# before ${CMAKE_ROOT}/Modules/ is checked
|
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
|
|
|
|
|
2007-04-26 16:02:20 +02:00
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
|
|
set (CMAKE_BUILD_TYPE Debug CACHE STRING
|
|
|
|
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
|
|
|
|
FORCE)
|
|
|
|
endif (NOT CMAKE_BUILD_TYPE)
|
2006-12-23 16:16:30 +01:00
|
|
|
|
2009-02-13 13:57:23 +01:00
|
|
|
add_definitions(-D_GNU_SOURCE -DDWARVES_VERSION=\\"v1.7\\")
|
2006-12-12 03:37:23 +01:00
|
|
|
find_package(DWARF REQUIRED)
|
2008-03-04 19:37:02 +01:00
|
|
|
find_package(ZLIB REQUIRED)
|
2006-12-12 03:37:23 +01:00
|
|
|
|
2007-04-19 23:01:47 +02:00
|
|
|
_set_fancy(LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}${CMAKE_INSTALL_PREFIX}/${__LIB}" "libdir")
|
2007-01-30 22:07:28 +01:00
|
|
|
|
2009-04-19 18:48:51 +02:00
|
|
|
set(dwarves_LIB_SRCS dwarves.c dwarves_fprintf.c gobuffer strings
|
|
|
|
ctf_encoder.c ctf_loader.c libctf.c dwarf_loader.c
|
|
|
|
dutil.c elf_symtab.c)
|
2007-02-25 20:43:59 +01:00
|
|
|
add_library(dwarves SHARED ${dwarves_LIB_SRCS})
|
|
|
|
set_target_properties(dwarves PROPERTIES VERSION 1.0.0 SOVERSION 1)
|
2008-03-04 19:37:02 +01:00
|
|
|
target_link_libraries(dwarves ${DWARF_LIBRARIES} ${ZLIB_LIBRARIES})
|
2006-12-12 03:37:23 +01:00
|
|
|
|
2007-05-06 19:50:28 +02:00
|
|
|
set(dwarves_emit_LIB_SRCS dwarves_emit.c)
|
|
|
|
add_library(dwarves_emit SHARED ${dwarves_emit_LIB_SRCS})
|
|
|
|
set_target_properties(dwarves_emit PROPERTIES VERSION 1.0.0 SOVERSION 1)
|
|
|
|
target_link_libraries(dwarves_emit ${DWARF_LIBRARIES} dwarves)
|
|
|
|
|
2007-05-07 05:30:02 +02:00
|
|
|
set(dwarves_reorganize_LIB_SRCS dwarves_reorganize.c)
|
|
|
|
add_library(dwarves_reorganize SHARED ${dwarves_reorganize_LIB_SRCS})
|
|
|
|
set_target_properties(dwarves_reorganize PROPERTIES VERSION 1.0.0 SOVERSION 1)
|
|
|
|
target_link_libraries(dwarves_reorganize ${DWARF_LIBRARIES} dwarves)
|
|
|
|
|
2009-03-18 15:08:23 +01:00
|
|
|
set(codiff_SRCS codiff.c)
|
2007-02-25 20:43:59 +01:00
|
|
|
add_executable(codiff ${codiff_SRCS})
|
2007-03-28 15:18:57 +02:00
|
|
|
target_link_libraries(codiff dwarves)
|
2006-12-12 03:37:23 +01:00
|
|
|
|
2009-03-18 15:08:23 +01:00
|
|
|
set(ctracer_SRCS ctracer.c)
|
2007-02-25 20:43:59 +01:00
|
|
|
add_executable(ctracer ${ctracer_SRCS})
|
2007-05-07 05:30:02 +02:00
|
|
|
target_link_libraries(ctracer dwarves dwarves_emit dwarves_reorganize)
|
2006-12-20 15:16:16 +01:00
|
|
|
|
2007-02-25 20:43:59 +01:00
|
|
|
set(dtagnames_SRCS dtagnames.c)
|
|
|
|
add_executable(dtagnames ${dtagnames_SRCS})
|
2007-03-28 15:18:57 +02:00
|
|
|
target_link_libraries(dtagnames dwarves)
|
2006-12-28 17:03:42 +01:00
|
|
|
|
2007-02-25 20:43:59 +01:00
|
|
|
set(pahole_SRCS pahole.c)
|
|
|
|
add_executable(pahole ${pahole_SRCS})
|
2007-05-07 05:30:02 +02:00
|
|
|
target_link_libraries(pahole dwarves dwarves_reorganize)
|
2006-12-12 03:37:23 +01:00
|
|
|
|
2007-02-25 20:43:59 +01:00
|
|
|
set(pdwtags_SRCS pdwtags.c)
|
|
|
|
add_executable(pdwtags ${pdwtags_SRCS})
|
2007-03-28 15:18:57 +02:00
|
|
|
target_link_libraries(pdwtags dwarves)
|
2007-01-19 00:13:56 +01:00
|
|
|
|
2007-02-25 20:43:59 +01:00
|
|
|
set(pglobal_SRCS pglobal.c)
|
|
|
|
add_executable(pglobal ${pglobal_SRCS})
|
2007-03-28 15:18:57 +02:00
|
|
|
target_link_libraries(pglobal dwarves)
|
2007-02-02 14:56:53 +01:00
|
|
|
|
2007-02-25 20:43:59 +01:00
|
|
|
set(pfunct_SRCS pfunct.c )
|
|
|
|
add_executable(pfunct ${pfunct_SRCS})
|
pfunct: Implement --expand_types
So that one can get an skeleton from where a function can be
reimplemented, or a probe can be written to attach to a tracepoint.
Right now it will only expand the types for
struct/union/typedef/enumeration types, but it is a good start.
[acme@doppio pahole]$ pfunct --expand_types --function inet6_ioctl ipv6.ko > a.c
[acme@doppio pahole]$ echo "int main(void) { return 0; }" >> a.c
[acme@doppio pahole]$ gcc -Wall -g a.c -o a
[acme@doppio pahole]$ grep ^#include a.c
[acme@doppio pahole]$
No errors, no includes.
This is present in ctracer, where we don't want to _require_ any header
files, just the object file with the function we want to probe. From
there we get the function signature, and reconstruct the types needed to
access members of structs passed as parameters.
We still need to add padding to reconstruct __attribute__ alignment
effects.
Also, if we can detect what are the exact members accessed in the probe,
we can reconstruct just what is needed to access those members,
hopefully reducing the time needed for gcc to digest the resulting
source code. And also reducing the size of the output, which can
hopefully be interesting to help focus on what the probe is doing.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-09-30 22:30:42 +02:00
|
|
|
target_link_libraries(pfunct dwarves dwarves_emit)
|
2006-12-12 03:37:23 +01:00
|
|
|
|
2007-02-25 20:43:59 +01:00
|
|
|
set(prefcnt_SRCS prefcnt.c)
|
|
|
|
add_executable(prefcnt ${prefcnt_SRCS})
|
2007-03-28 15:18:57 +02:00
|
|
|
target_link_libraries(prefcnt dwarves)
|
2007-01-11 19:41:54 +01:00
|
|
|
|
2007-06-12 20:53:46 +02:00
|
|
|
set(syscse_SRCS syscse.c)
|
|
|
|
add_executable(syscse ${syscse_SRCS})
|
|
|
|
target_link_libraries(syscse dwarves)
|
|
|
|
|
2007-12-28 02:00:07 +01:00
|
|
|
install(TARGETS codiff ctracer dtagnames pahole pdwtags
|
2007-06-12 20:53:46 +02:00
|
|
|
pfunct pglobal prefcnt syscse RUNTIME DESTINATION
|
2007-04-19 23:01:47 +02:00
|
|
|
${CMAKE_INSTALL_PREFIX}/bin)
|
2007-02-25 20:43:59 +01:00
|
|
|
install(TARGETS dwarves LIBRARY DESTINATION ${LIB_INSTALL_DIR})
|
2007-05-07 05:30:02 +02:00
|
|
|
install(TARGETS dwarves dwarves_emit dwarves_reorganize LIBRARY DESTINATION ${LIB_INSTALL_DIR})
|
|
|
|
install(FILES dwarves.h dwarves_emit.h dwarves_reorganize.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
|
2009-02-11 15:19:46 +01:00
|
|
|
install(FILES man-pages/pahole.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1/)
|
2007-08-14 16:33:54 +02:00
|
|
|
install(PROGRAMS ostra/ostra-cg DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
2007-12-03 17:43:49 +01:00
|
|
|
install(FILES ostra/python/ostra.py DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dwarves/runtime/python)
|
2007-12-06 20:43:20 +01:00
|
|
|
install(FILES lib/Makefile lib/ctracer_relay.c lib/ctracer_relay.h lib/linux.blacklist.cu
|
2007-12-03 17:43:49 +01:00
|
|
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dwarves/runtime)
|