Skip to content

Commit

Permalink
pt/addrtrace: Trace stack and vvar region
Browse files Browse the repository at this point in the history
  • Loading branch information
aewag committed Mar 3, 2023
1 parent 786340e commit 075f452
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions pintool/addrtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ memobj_t *heapcache;
typedef std::vector<memobj_t> HEAPVEC;
HEAPVEC heap;

/***********************************************************************/
/* Stack tracking*/
imgobj_t stack;

/***********************************************************************/
/* Multithreading */

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion pintool/makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 075f452

Please sign in to comment.