From 6f867e7633d20c0f585cfb2dc8734c4bb9ff4a0e Mon Sep 17 00:00:00 2001 From: Alexander Wagner Date: Fri, 3 Mar 2023 11:20:05 +0100 Subject: [PATCH] pt/addrtrace: Trace stack and vvar region --- pintool/addrtrace.cpp | 20 ++++++++++++++++++++ pintool/makefile.rules | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pintool/addrtrace.cpp b/pintool/addrtrace.cpp index 507983bd..284fe015 100644 --- a/pintool/addrtrace.cpp +++ b/pintool/addrtrace.cpp @@ -215,6 +215,10 @@ memobj_t *heapcache; typedef std::vector HEAPVEC; HEAPVEC heap; +/***********************************************************************/ +/* Stack tracking*/ +imgobj_t stack; + /***********************************************************************/ /* Multithreading */ @@ -2023,6 +2027,22 @@ int main(int argc, char *argv[]) { INS_AddInstrumentFunction(instrumentLeakingInstructions, 0); } + /* Getting the stack and vvar address range for this process */ + stack.baseaddr = getAddrFromProcMap("stack", 1); + stack.endaddr = getAddrFromProcMap("stack", 2); + PT_DEBUG(1, "stack.baseaddr is " << hex << stack.baseaddr); + PT_DEBUG(1, "stack.endaddr is " << hex << stack.endaddr); + + imgobj_t imgdata = { + .name = "vvar", + .baseaddr = getAddrFromProcMap("vvar", 1), + .endaddr = getAddrFromProcMap("vvar", 2), + .hash = "", + }; + imgvec.push_back(imgdata); + PT_DEBUG(1, "vvar.baseaddr is " << hex << imgdata.baseaddr); + PT_DEBUG(1, "vvar.endaddr is " << hex << imgdata.endaddr); + PIN_AddThreadStartFunction(ThreadStart, 0); PIN_AddThreadFiniFunction(ThreadFini, 0); PIN_AddFiniFunction(Fini, 0); diff --git a/pintool/makefile.rules b/pintool/makefile.rules index b01db1d7..44cb33b2 100644 --- a/pintool/makefile.rules +++ b/pintool/makefile.rules @@ -87,5 +87,5 @@ $(OBJDIR)proc-map$(OBJ_SUFFIX): proc-map.cpp proc-map.H $(CXX) $(TOOL_CXXFLAGS) $(COMP_OBJ)$@ $< # Build the tool as a dll (shared object). -$(OBJDIR)addrtrace$(PINTOOL_SUFFIX): $(OBJDIR)call-stack$(OBJ_SUFFIX) $(OBJDIR)sha1$(OBJ_SUFFIX) $(OBJDIR)addrtrace$(OBJ_SUFFIX) +$(OBJDIR)addrtrace$(PINTOOL_SUFFIX): $(OBJDIR)call-stack$(OBJ_SUFFIX) $(OBJDIR)sha1$(OBJ_SUFFIX) $(OBJDIR)proc-map$(OBJ_SUFFIX) $(OBJDIR)addrtrace$(OBJ_SUFFIX) $(LINKER) $(TOOL_LDFLAGS) $(LINK_EXE)$@ $(^:%.h=) $(TOOL_LPATHS) $(TOOL_LIBS)