Posts Tagged ‘GCC Plugin Help’

This may help in some way the process of debugging and developing a GCC PLUGIN 

#Needed Information
PROJECT_NAME=Name
PROJECT_WSPACE=Work space Path
GCC_SRC_NAME=Plugin Src File Name

#Needed Paths
GCC_LIB_PATH=GCC HEADER PATH

GCC_PLUGIN_SO_PATH=$(PROJECT_WSPACE)/$(PROJECT_NAME)/x_plugin
GCC_TEST_RESULT_PATH=$(PROJECT_WSPACE)/$(PROJECT_NAME)/x_results
GCC_TEST_TREES_PATH=$(GCC_TEST_RESULT_PATH)/x_trees/

# Test Information
GCC_INJECT_PATH=$(PROJECT_WSPACE)/$(PROJECT_NAME)/x_inject
GCC_INJECT_CASE=Test Case File Name

compilingPlugin:
# Create the plugin #
gcc -I $(GCC_LIB_PATH) -shared -fPIC -O2 $(GCC_SRC_NAME).c -o $(GCC_PLUGIN_SO_PATH)/$(GCC_SRC_NAME).so
# Execute with input test
gcc -fdump-tree-all -fplugin=$(GCC_PLUGIN_SO_PATH)/$(GCC_SRC_NAME).so $(GCC_INJECT_PATH)/$(GCC_INJECT_CASE).c -o $(GCC_TEST_RESULT_PATH)/$(GCC_INJECT_CASE)
#
# Move tree information
#
mv case_* $(GCC_TEST_TREES_PATH)

clean:
# Clean all paths #

if test -d $(GCC_PLUGIN_SO_PATH) ; then rm -f -r $(GCC_PLUGIN_SO_PATH) ;fi
if test -d $(GCC_TEST_RESULT_PATH); then rm -f -r $(GCC_TEST_RESULT_PATH) ;fi

# Make paths #

if ! test -d $(GCC_PLUGIN_SO_PATH); then mkdir $(GCC_PLUGIN_SO_PATH) ;fi
if ! test -d $(GCC_TEST_RESULT_PATH); then mkdir $(GCC_TEST_RESULT_PATH) ;fi
if ! test -d $(GCC_TEST_TREES_PATH); then mkdir $(GCC_TEST_TREES_PATH) ;fi
if ! test -d $(GCC_INJECT_PATH); then mkdir $(GCC_INJECT_PATH) ;fi

An Example

#Needed Information
PROJECT_NAME=framework_poc
PROJECT_WSPACE=/str/uniRepo/thesisGCC/appGCC
GCC_SRC_NAME=plugin_poc

#Needed Paths
GCC_LIB_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.7/plugin/include/

GCC_PLUGIN_SO_PATH=$(PROJECT_WSPACE)/$(PROJECT_NAME)/x_plugin
GCC_TEST_RESULT_PATH=$(PROJECT_WSPACE)/$(PROJECT_NAME)/x_results
GCC_TEST_TREES_PATH=$(GCC_TEST_RESULT_PATH)/x_trees/

# Test Information
GCC_INJECT_PATH=$(PROJECT_WSPACE)/$(PROJECT_NAME)/x_inject
GCC_INJECT_CASE=case_1

 

compilingPlugin:
# Create the plugin #
gcc -I $(GCC_LIB_PATH) -shared -fPIC -O2 $(GCC_SRC_NAME).c -o $(GCC_PLUGIN_SO_PATH)/$(GCC_SRC_NAME).so
# Execute with input test
gcc -fdump-tree-all -fplugin=$(GCC_PLUGIN_SO_PATH)/$(GCC_SRC_NAME).so $(GCC_INJECT_PATH)/$(GCC_INJECT_CASE).c -o $(GCC_TEST_RESULT_PATH)/$(GCC_INJECT_CASE)
#
# Move tree information
#
mv case_* $(GCC_TEST_TREES_PATH)

clean:
# Clean all paths #

if test -d $(GCC_PLUGIN_SO_PATH) ; then rm -f -r $(GCC_PLUGIN_SO_PATH) ;fi
if test -d $(GCC_TEST_RESULT_PATH); then rm -f -r $(GCC_TEST_RESULT_PATH) ;fi

# Make paths #

if ! test -d $(GCC_PLUGIN_SO_PATH); then mkdir $(GCC_PLUGIN_SO_PATH) ;fi
if ! test -d $(GCC_TEST_RESULT_PATH); then mkdir $(GCC_TEST_RESULT_PATH) ;fi
if ! test -d $(GCC_TEST_TREES_PATH); then mkdir $(GCC_TEST_TREES_PATH) ;fi
if ! test -d $(GCC_INJECT_PATH); then mkdir $(GCC_INJECT_PATH) ;fi

 

Advertisements