Skip to content

Commit

Permalink
Merge branch 'dyninst_arm64linux'
Browse files Browse the repository at this point in the history
Former-commit-id: d0b53d321f69b998e5df2d3ff0d69990744299f2
  • Loading branch information
uojalcaraz committed Oct 22, 2024
2 parents 0d58323 + 6f5f1f3 commit 7160a53
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 8 deletions.
4 changes: 3 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -10932,7 +10932,6 @@ if [ "x$download_dyninst" = xyes ] ; then
cd $prebfddir
fi #dyninst=download


######################################################################
# Check that the Sampling allocator code is supported by compiler
######################################################################
Expand Down Expand Up @@ -12510,6 +12509,9 @@ if [ $dyninst = yes ] ; then
if [ ! -f $dyninstdir/$PLATFORM/lib/libdynDwarf.so ] ; then
fixmakeargs="$fixmakeargs DYNINST14"
fi
if [ $machine = arm64_linux ]; then
fixmakeargs="$fixmakeargs DYN_ARMLINUX64"
fi
fi
Expand Down
2 changes: 2 additions & 0 deletions include/Makefile.skel
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ OPARI_O = TauKojakOpariDisable.o #ENDIF#
# DYNINST DEFAULT ARCH
#############################################
DYNINST_PLATFORM = $(PLATFORM)
#Dyninst 13 has issues with ARMLINUX64 when there are more than one function parameters, compile slightly modified tau_run.cpp and TauHooks.cpp
#DYN_ARMLINUX64#DYNINST_ARCH = -DDYNINSTARMLINUX64

############# OpenMP Fortran Option ########
TAU_OPENMP_OPTION =
Expand Down
2 changes: 1 addition & 1 deletion src/Profile/Makefile.skel
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ TauMapping.o : TauMapping.cpp $(HDRS)
$(CXX) $(CXXFLAGS) -c $(@:.o=.cpp)

TauHooks.o : TauHooks.cpp $(HDRS)
$(CXX) $(CXXFLAGS) -c $(@:.o=.cpp)
$(CXX) $(CXXFLAGS) $(DYNINST_ARCH) -c $(@:.o=.cpp)

TauJava.o : TauJava.cpp
$(CXX) $(CXXFLAGS) -c TauJava.cpp
Expand Down
13 changes: 13 additions & 0 deletions src/Profile/TauDisable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* invoke the corresponding C routines.
*****************************************************************************/
#include <stdio.h>
#include <string>
#include <string.h>

typedef unsigned int TauGroup_t;

Expand Down Expand Up @@ -728,6 +730,17 @@ void tau_trace_lib_exit(const char * func_name)
void trace_register_func(char *origname, int id) {
printf("TAU: trace_register_func : name = %s, id = %d\n", origname, id);
}
#ifdef DYNINSTARMLINUX64
void trace_register_func_dyn(char *id_origname) {
int id = std::stoi(strtok(id_origname, ","));
char *origname = strtok(NULL, ",");
printf("TAU: trace_register_func : name = %s, id = %d\n", origname, id);
}
#else
void trace_register_func_dyn(char *origname, int id) {
printf("TAU: trace_register_func : name = %s, id = %d\n", origname, id);
}
#endif

void tau_dyninst_cleanup() {
printf("TAU: Inside tau_dyninst_cleanup\n");
Expand Down
19 changes: 18 additions & 1 deletion src/Profile/TauHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ static inline int getTauDyninstEnabled(int tid){

void trace_register_func(char *origname, int id)
{

static int invocations = 0;
int i;
int tid = RtsLayer::myThread();
Expand Down Expand Up @@ -410,6 +411,21 @@ void trace_register_func(char *origname, int id)
TAU_VERBOSE("Exiting trace_register_func\n");
}

#ifdef DYNINSTARMLINUX64
void trace_register_func_dyn(char *id_origname)
{

int id = std::stoi(strtok(id_origname, ","));
char *origname = strtok(NULL, ",");
#else
void trace_register_func_dyn(char *origname, int id)
{
#endif
trace_register_func(origname, id);
}



void traceEntry(int id)
{
TAU_VERBOSE("Inside traceEntry: id = %d\n", id);
Expand Down Expand Up @@ -552,11 +568,13 @@ void tau_dyninst_cleanup()
TAU_VERBOSE("Inside tau_dyninst_cleanup\n");
}


void tau_register_func(char **func, char** file, int* lineno,
int id) {
char * tmpstr = Tau_demangle_name(*func);
if (*file == NULL){
TAU_VERBOSE("TAU: tau_register_func: name = %s, id = %d\n", *func, id);

trace_register_func(tmpstr, id);
} else {
char funcname[2048];
Expand Down Expand Up @@ -633,7 +651,6 @@ void tau_trace_register_loop(int id, char *loopname) {

void tau_register_loop(char **func, char** file, int* lineno,
int id) {

char lname[2048];
char *loopname;
if (((*file) != (char *)NULL) && (*lineno != 0)) {
Expand Down
4 changes: 4 additions & 0 deletions utils/FixMakefile
Original file line number Diff line number Diff line change
Expand Up @@ -1947,6 +1947,10 @@ case $1 in
echo "NOTE: Using newer version DYNINST 5.2 "
echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
;;
DYN_ARMLINUX64)
echo "NOTE: Using modified version for ARMLINUX64 Dyninst"
echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
;;
JAVA)
echo "NOTE: Using Java Virtual Machine Instrumentation ***"
echo "s/#$1#\(.*\)/$bs\1#$1#/g" >> $sedout
Expand Down
2 changes: 1 addition & 1 deletion utils/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ tau_run: tau_run.o tau_selective_dyn.o tau_instrument.dyn.o
$(CXX) $(CFLAGS) tau_run.o tau_selective_dyn.o tau_instrument.dyn.o -o $@ $(DYNLIBS) $(LEXTRAUTIL) $(TAU_BOOSTLIB) $(BFDLINK)

tau_run.o: tau_run.cpp
$(CXX) $(CFLAGS) $(DYNINC) -DTAU_DYNINST -DTAU_DYNINST41PLUS $(DYN_PKG_OPT) -c tau_run.cpp $(TAU_BOOSTINC)
$(CXX) $(CFLAGS) $(DYNINC) $(DYNINST_ARCH) -DTAU_DYNINST -DTAU_DYNINST41PLUS $(DYN_PKG_OPT) -c tau_run.cpp $(TAU_BOOSTINC)

tau_trace2json: tau_trace2json.o
$(CXX) $(CFLAGS) tau_trace2json.o -o $@ -lm $(TAU_TRACE_INPUT_LIB)
Expand Down
3 changes: 2 additions & 1 deletion utils/include/Makefile.skel
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ PDT_CFLAGS = $(PDTCFLAGS) $(PDT_COMPILE_FLAGS)
#DYNINST8#DYN_PKG_OPT = -DTAU_DYNINSTAPI_8_PLUS #ENDIF#
#DYNINST12#DYN_PKG_OPT = -DTAU_DYNINSTAPI_12_PLUS #ENDIF#
#DYNINST8#DYNINST_PLATFORM= #ENDIF#

#Dyninst 13 has issues with ARMLINUX64 when there are more than one function parameters, compile slightly modified tau_run.cpp and TauHooks.cpp
#DYN_ARMLINUX64#DYNINST_ARCH = -DDYNINSTARMLINUX64
#DEBUGPROF#DEBUGOPT = -DDEBUG #ENDIF#

#GNU#GNUOPT = -DTAU_GNU -DTAU_DOT_H_LESS_HEADERS -fPIC #ENDIF#
Expand Down
12 changes: 9 additions & 3 deletions utils/tau_run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,18 @@ BPatch_Vector<BPatch_snippet *> funcNames;
int addName(char *name)
{
static int funcID = 0;
#ifdef DYNINSTARMLINUX64
string id_name = std::to_string(funcID)+","+name;
BPatch_constExpr *id_name_param = new BPatch_constExpr(id_name.c_str());
BPatch_Vector<BPatch_snippet *> params;
params.push_back(id_name_param);
#else
BPatch_constExpr *name_param = new BPatch_constExpr(name);
BPatch_constExpr *id_param = new BPatch_constExpr(funcID);
BPatch_Vector<BPatch_snippet *> params;
params.push_back(name_param);
params.push_back(id_param);

#endif
BPatch_funcCallExpr *call = new BPatch_funcCallExpr(*name_reg, params);
funcNames.push_back(call);
return funcID++;
Expand Down Expand Up @@ -857,7 +863,7 @@ int tauRewriteLibrary(BPatch *bpatch, const char *mutateeName, char *outfile, ch
dprintf("Searching for TAU functions\n");
BPatch_function* entryLibTrace = tauFindFunction(mutateeImage, "tau_trace_lib_entry");
BPatch_function* exitLibTrace = tauFindFunction(mutateeImage, "tau_trace_lib_exit");
name_reg = tauFindFunction(mutateeImage, "trace_register_func");
name_reg = tauFindFunction(mutateeImage, "trace_register_func_dyn");


if(!entryLibTrace || !exitLibTrace )
Expand Down Expand Up @@ -1004,7 +1010,7 @@ int tauRewriteBinary(BPatch *bpatch, const char *mutateeName, char *outfile, cha
BPatch_function* setupFunc = tauFindFunction(mutateeImage, "tau_dyninst_init");
BPatch_function* cleanupFunc = tauFindFunction(mutateeImage, "tau_dyninst_cleanup");
BPatch_function* mainFunc = tauFindFunction(mutateeImage, "main");
name_reg = tauFindFunction(mutateeImage, "trace_register_func");
name_reg = tauFindFunction(mutateeImage, "trace_register_func_dyn");

// This heuristic guesses that debugging info. is available if main
// is not defined in the DEFAULT_MODULE
Expand Down

0 comments on commit 7160a53

Please sign in to comment.