<commit_before># **********************************************************
# Copyright (c) 2013-2014 Google, Inc.  All rights reserved.
# **********************************************************

# Dr. Memory: the memory debugger
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation;
# version 2.1 of the License, and no later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

cmake_minimum_required(VERSION 2.6)

find_package(DrMemoryFramework PATHS ${framework_dir})

##################################################
# drstracelib

set(srcs
    drstrace.c
    drstrace_named_consts.c)

if (WIN32)
  set(srcs ${srcs} ${PROJECT_SOURCE_DIR}/make/resources.rc)
  set(DEFINES_NO_D ${DEFINES_NO_D} RC_IS_DRSTRACE)
endif ()

# We set DR libc option on b/c this is needed to link with drsyms_static
# on VS2010. It has a downside of increase in pdb and dll size (xref DRi#714).
set(DynamoRIO_USE_LIBC ON)

add_library(drstracelib SHARED ${srcs})

# We share the framework version # for now
set_target_properties(drstracelib PROPERTIES VERSION ${DRMF_VERSION_MAJOR_MINOR})

if (WIN32)
  set_property(TARGET drstracelib PROPERTY COMPILE_DEFINITIONS
    "${DEFINES_NO_D};RC_IS_DRSTRACELIB")
else ()
  set_property(TARGET drstracelib PROPERTY COMPILE_DEFINITIONS ${DEFINES_NO_D})
endif ()

set_target_properties(drstracelib PROPERTIES
  RUNTIME_OUTPUT_DIRECTORY${location_suffix} "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")

# We rely on i#955's "rpath file" to locate the extension on Windows, for
# the build dir at least.
set(DynamoRIO_RPATH ON)
configure_DynamoRIO_client(drstracelib)

# We could link with the internal static lib but it's a good exercise
# to test the public version:
# While we seem to need the drmf_ prefix here for shared drsyscall, for static
# that doesn't work while this does -- go figure:
use_DynamoRIO_extension(drstracelib drsyscall_static)
use_DynamoRIO_extension(drstracelib drmgr_static)
use_DynamoRIO_extension(drstracelib drx_static)
# XXX: We could use a dynamic drsyms, although drmemory is using static.
# So we'd need special deployment here.
use_DynamoRIO_extension(drstracelib drsyms_static)
add_dependencies(drstracelib drsyscall)

install(TARGETS drstracelib
  RUNTIME DESTINATION "${INSTALL_LIB}" # dll
  LIBRARY DESTINATION "${INSTALL_LIB}" # .so
  PERMISSIONS ${owner_access} OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
  WORLD_READ WORLD_EXECUTE)

# XXX DRi#1078: we should add the relative dir .drpath support!
# For now we copy drsyscall.dll.  CMake won't let us install it as a
# target from this dir so we copy it as a file.
get_target_property(drsys_path drsyscall LOCATION${location_suffix})
install(FILES ${drsys_path} DESTINATION "${INSTALL_LIB}"
  PERMISSIONS ${owner_access} OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
  WORLD_READ WORLD_EXECUTE)

##################################################
# symbol_fetch to fetch symbols from MS Symbol Server

# We only need to fetch the Wintypes.pdb but the Wintypes.dll is only available
# on Windows 8 or later. So we make a special fake dll here and then change
# GUID & name to Wintypes.pdb in the debug section of the new dll. We use a special
# mksymguid.pl script to do that.
# Note: Fake dll name should be the same length as Wintypes.pdb to avoid PE debug
# section realignment.

if (WIN32)
  add_library(symfetch SHARED symfetch.c ${PROJECT_SOURCE_DIR}/make/resources.rc)
  get_target_property(symfetch_path symfetch LOCATION${location_suffix})

  # We manually set PDBALTPATH here b/c compiler sets absolute path
  # to pdb which we don't need here. We disable INCREMENTAL b/c we
  # don't want to produce additional files with dll. We statically
  # set image base to avoid bug on x64 environment when symbols
  # are fetched but couldn't be loaded by using SymLoadModuleExW.
  append_property_string(TARGET symfetch LINK_FLAGS
                         "/BASE:0x10000000 /INCREMENTAL:NO /PDBALTPATH:symfetch.pdb")

  set_property(TARGET symfetch PROPERTY COMPILE_DEFINITIONS
               "${DEFINES_NO_D};RC_IS_DRSTRACE_SYMFETCH_LIB")
  # locate perl
  if (PERL_PATH AND EXISTS "${PERL_PATH}/perl.exe")
    set(PERL_EXECUTABLE "${PERL_PATH}/perl.exe")
  else ()
    include(FindPerl)
    if (PERL_FOUND)
      get_filename_component(PERL_PATH "${PERL_EXECUTABLE}" PATH)
    endif (PERL_FOUND)
  endif ()
  add_custom_command(TARGET symfetch POST_BUILD COMMAND ${PERL_EXECUTABLE}
                     "${CMAKE_CURRENT_SOURCE_DIR}/mksymguid.pl"
                     "${symfetch_path}" VERBATIM)
endif (WIN32)

##################################################
# drstrace frontend

# We don't restore global flags (from each ${SAVE_${var}}) b/c cmake
# waits until the end of the file to take the global values into
# effect.  We don't seem to need them for the front-end though.

set(front_srcs drstrace_frontend.c)
if (WIN32)
  set(front_srcs ${front_srcs} ${PROJECT_SOURCE_DIR}/make/resources.rc)
endif ()
add_executable(drstrace ${front_srcs})<commit_msg>Added symfetch.dll into the final package<commit_after># **********************************************************
# Copyright (c) 2013-2014 Google, Inc.  All rights reserved.
# **********************************************************

# Dr. Memory: the memory debugger
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation;
# version 2.1 of the License, and no later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

cmake_minimum_required(VERSION 2.6)

find_package(DrMemoryFramework PATHS ${framework_dir})

##################################################
# drstracelib

set(srcs
    drstrace.c
    drstrace_named_consts.c)

if (WIN32)
  set(srcs ${srcs} ${PROJECT_SOURCE_DIR}/make/resources.rc)
  set(DEFINES_NO_D ${DEFINES_NO_D} RC_IS_DRSTRACE)
endif ()

# We set DR libc option on b/c this is needed to link with drsyms_static
# on VS2010. It has a downside of increase in pdb and dll size (xref DRi#714).
set(DynamoRIO_USE_LIBC ON)

add_library(drstracelib SHARED ${srcs})

# We share the framework version # for now
set_target_properties(drstracelib PROPERTIES VERSION ${DRMF_VERSION_MAJOR_MINOR})

if (WIN32)
  set_property(TARGET drstracelib PROPERTY COMPILE_DEFINITIONS
    "${DEFINES_NO_D};RC_IS_DRSTRACELIB")
else ()
  set_property(TARGET drstracelib PROPERTY COMPILE_DEFINITIONS ${DEFINES_NO_D})
endif ()

set_target_properties(drstracelib PROPERTIES
  RUNTIME_OUTPUT_DIRECTORY${location_suffix} "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")

# We rely on i#955's "rpath file" to locate the extension on Windows, for
# the build dir at least.
set(DynamoRIO_RPATH ON)
configure_DynamoRIO_client(drstracelib)

# We could link with the internal static lib but it's a good exercise
# to test the public version:
# While we seem to need the drmf_ prefix here for shared drsyscall, for static
# that doesn't work while this does -- go figure:
use_DynamoRIO_extension(drstracelib drsyscall_static)
use_DynamoRIO_extension(drstracelib drmgr_static)
use_DynamoRIO_extension(drstracelib drx_static)
# XXX: We could use a dynamic drsyms, although drmemory is using static.
# So we'd need special deployment here.
use_DynamoRIO_extension(drstracelib drsyms_static)
add_dependencies(drstracelib drsyscall)

install(TARGETS drstracelib
  RUNTIME DESTINATION "${INSTALL_LIB}" # dll
  LIBRARY DESTINATION "${INSTALL_LIB}" # .so
  PERMISSIONS ${owner_access} OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
  WORLD_READ WORLD_EXECUTE)

# XXX DRi#1078: we should add the relative dir .drpath support!
# For now we copy drsyscall.dll.  CMake won't let us install it as a
# target from this dir so we copy it as a file.
get_target_property(drsys_path drsyscall LOCATION${location_suffix})
install(FILES ${drsys_path} DESTINATION "${INSTALL_LIB}"
  PERMISSIONS ${owner_access} OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
  WORLD_READ WORLD_EXECUTE)

##################################################
# symbol_fetch to fetch symbols from MS Symbol Server

# We only need to fetch the Wintypes.pdb but the Wintypes.dll is only available
# on Windows 8 or later. So we make a special fake dll here and then change
# GUID & name to Wintypes.pdb in the debug section of the new dll. We use a special
# mksymguid.pl script to do that.
# Note: Fake dll name should be the same length as Wintypes.pdb to avoid PE debug
# section realignment.

if (WIN32)
  add_library(symfetch SHARED symfetch.c ${PROJECT_SOURCE_DIR}/make/resources.rc)
  get_target_property(symfetch_path symfetch LOCATION${location_suffix})

  # We manually set PDBALTPATH here b/c compiler sets absolute path
  # to pdb which we don't need here. We disable INCREMENTAL b/c we
  # don't want to produce additional files with dll. We statically
  # set image base to avoid bug on x64 environment when symbols
  # are fetched but couldn't be loaded by using SymLoadModuleExW.
  append_property_string(TARGET symfetch LINK_FLAGS
                         "/BASE:0x10000000 /INCREMENTAL:NO /PDBALTPATH:symfetch.pdb")

  set_property(TARGET symfetch PROPERTY COMPILE_DEFINITIONS
               "${DEFINES_NO_D};RC_IS_DRSTRACE_SYMFETCH_LIB")
  # locate perl
  if (PERL_PATH AND EXISTS "${PERL_PATH}/perl.exe")
    set(PERL_EXECUTABLE "${PERL_PATH}/perl.exe")
  else ()
    include(FindPerl)
    if (PERL_FOUND)
      get_filename_component(PERL_PATH "${PERL_EXECUTABLE}" PATH)
    endif (PERL_FOUND)
  endif ()
  add_custom_command(TARGET symfetch POST_BUILD COMMAND ${PERL_EXECUTABLE}
                     "${CMAKE_CURRENT_SOURCE_DIR}/mksymguid.pl"
                     "${symfetch_path}" VERBATIM)
  install(TARGETS symfetch DESTINATION "${INSTALL_BIN}"
    PERMISSIONS ${owner_access} OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
    WORLD_READ WORLD_EXECUTE)
endif (WIN32)

##################################################
# drstrace frontend

# We don't restore global flags (from each ${SAVE_${var}}) b/c cmake
# waits until the end of the file to take the global values into
# effect.  We don't seem to need them for the front-end though.

set(front_srcs drstrace_frontend.c)
if (WIN32)
  set(front_srcs ${front_srcs} ${PROJECT_SOURCE_DIR}/make/resources.rc)
endif ()
add_executable(drstrace ${front_srcs})
{'fraction_non_alphanumeric': 0.11660272994914801, 'fraction_numerical': 0.010527254884467839, 'mean_word_length': 5.079175704989154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '81577', 'n_tokens_mistral': 3762, 'n_tokens_neox': 3505, 'n_words': 1181}