1# Try setting up some bits for dtrace. 2# 3# By itself, dtrace can trace things like function entry/return points 4# just fine, and even pull numeric and string arguments. More involved 5# data structures, though, would either need manual definition in the D 6# scripts (which is practically impossible for anything sizable), manual 7# specification of offsets (even worse), or CTF info included in the 8# binary (hey, we can do that!). So, see if we can pull that stuff in... 9 10find_program(CTFCONVERT ctfconvert) 11find_program(CTFMERGE ctfmerge) 12 13if(CTFCONVERT AND CTFMERGE) 14 message(STATUS "Found ctfconvert/ctfmerge, setting up CTF info for dtrace.") 15 16 # ctfconvert/merge is about pulling over debug info, so make sure we 17 # enable that in the objects. 18 add_definitions("-g") 19 20 # ctfconvert/merge on BSD has a '-g' option, which we want to use 21 # (preserves the -g info in the final binary). Solarish apparently 22 # doesn't; maybe it always does it anyway? Regardless, figure out 23 # whether it takes that arg... 24 execute_process(COMMAND ${CTFCONVERT} -g -l0 /dev/null 25 OUTPUT_QUIET ERROR_VARIABLE _CTFCONVERT_G_OUT) 26 if(${_CTFCONVERT_G_OUT} MATCHES "^Usage:") 27 # No -g; leave vars alone 28 else() 29 # Add -g 30 set(CTFCONVERT "${CTFCONVERT} -g") 31 set(CTFMERGE "${CTFMERGE} -g") 32 endif() 33 34 # This is a horrific hack. cmake provides no way to actually find 35 # out the list of object files, or where they are, because that would 36 # be too easy. So we have to "know", and take our best shot. Sigh. 37 # Well, it's really only a dev tool anyway, so I guess some manual 38 # mess isn't the end of the world. We can't check the existence yet 39 # here, since it hasn't been created at this point in the process. 40 # So we just have to hope. mk_ctf_info.sh will warn us if things 41 # change... 42 set(CODIR ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/ctwmlib.dir) 43 44 add_custom_command(TARGET ctwm POST_BUILD 45 COMMAND ${CMAKE_COMMAND} -E env 46 CTFCONVERT=${CTFCONVERT} CTFMERGE=${CTFMERGE} 47 ${TOOLS}/mk_ctf_info.sh ${CODIR} 48 ${CMAKE_CURRENT_BINARY_DIR}/ctwm 49 COMMENT "Converting in CTF info for dtrace" 50 ) 51endif() 52