routine_tracer_ondemand.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef __ROUTINE_TRACER_ONDEMAND_H
  2. #define __ROUTINE_TRACER_ONDEMAND_H
  3. #include "routine_tracer.h"
  4. #include <unordered_map>
  5. class RoutineTracerOndemand
  6. {
  7. public:
  8. class RtnMaster : public RoutineTracer
  9. {
  10. public:
  11. RtnMaster();
  12. virtual ~RtnMaster() {}
  13. virtual RoutineTracerThread* getThreadHandler(Thread *thread) { return new RtnThread(this, thread); }
  14. virtual void addRoutine(IntPtr eip, const char *name, const char *imgname, IntPtr offset, int column, int line, const char *filename);
  15. virtual bool hasRoutine(IntPtr eip);
  16. RoutineTracer::Routine* getRoutine(IntPtr eip);
  17. private:
  18. static SInt64 signalHandler(UInt64, UInt64);
  19. Lock m_lock;
  20. std::unordered_map<IntPtr, RoutineTracer::Routine*> m_routines;
  21. };
  22. class RtnThread : public RoutineTracerThread
  23. {
  24. public:
  25. RtnThread(RtnMaster *master, Thread *thread) : RoutineTracerThread(thread), m_master(master) {}
  26. void printStack();
  27. private:
  28. RtnMaster *m_master;
  29. protected:
  30. virtual void functionEnter(IntPtr eip, IntPtr callEip) {}
  31. virtual void functionExit(IntPtr eip) {}
  32. virtual void functionChildEnter(IntPtr eip, IntPtr eip_child) {}
  33. virtual void functionChildExit(IntPtr eip, IntPtr eip_child) {}
  34. };
  35. };
  36. #endif // __ROUTINE_TRACER_ONDEMAND_H