libcsdbg  1.28
C++ exception (and generic) stack trace debug library
thread.hpp
Go to the documentation of this file.
1 #ifndef _CSDBG_THREAD
2 #define _CSDBG_THREAD 1
3 
10 #include "./stack.hpp"
11 #include "./call.hpp"
12 
13 namespace csdbg {
14 
27 class thread: virtual public object
28 {
29 protected:
30 
31  /* Protected variables */
32 
35  pthread_t m_handle;
44 public:
45 
46  /* Constructors, copy constructors and destructor */
47 
48  explicit thread(const i8* = NULL);
49 
50  thread(const thread&);
51 
52  virtual ~thread();
53 
54  virtual thread* clone() const;
55 
56 
57  /* Accessor methods */
58 
59  virtual const i8* name() const;
60 
61  virtual pthread_t handle() const;
62 
63  virtual i32 lag() const;
64 
65  virtual thread& set_name(const i8*);
66 
67 
68  /* Operator overloading methods */
69 
70  virtual thread& operator=(const thread&);
71 
72 
73  /* Generic methods */
74 
75  virtual bool is_current() const;
76 
77  virtual u32 call_depth() const;
78 
79  virtual const call* backtrace(u32) const;
80 
81  virtual thread& called(mem_addr_t, mem_addr_t, const i8*);
82 
83  virtual thread& returned();
84 
85  virtual thread& unwind();
86 
87  virtual thread& foreach(void (*)(u32, call*)) const;
88 };
89 
90 }
91 
92 #endif
93 
This abstract class serves as the root of the class hierarchy tree.
Definition: object.hpp:17
i8 * m_name
Thread name.
Definition: thread.hpp:33
virtual thread & called(mem_addr_t, mem_addr_t, const i8 *)
Simulate a function call.
Definition: thread.cpp:230
virtual pthread_t handle() const
Get the thread handle.
Definition: thread.cpp:109
char i8
8-bit signed integer
Definition: config.hpp:72
stack< call > * m_stack
Simulated call stack.
Definition: thread.hpp:37
Class csdbg::stack definition and method implementation.
Lightweight, templated, singly-linked LIFO queue (stack)
Definition: stack.hpp:28
virtual bool is_current() const
Check if this is the currently executing thread.
Definition: thread.cpp:185
This class represents a program/library runtime function call.
Definition: call.hpp:17
virtual thread & returned()
Simulate a function return.
Definition: thread.cpp:262
This class represents a thread of execution in the instrumented process.
Definition: thread.hpp:27
virtual ~thread()
Object destructor.
Definition: thread.cpp:71
virtual thread & operator=(const thread &)
Assignment operator.
Definition: thread.cpp:167
virtual thread & unwind()
Unwind the simulated call stack to meet the real call stack.
Definition: thread.cpp:283
virtual u32 call_depth() const
Get the size (call depth) of the simulated call stack.
Definition: thread.cpp:196
virtual i32 lag() const
Get the size (call depth) of the simulated call stack with respect to the real call stack...
Definition: thread.cpp:123
thread(const i8 *=NULL)
Object constructor.
Definition: thread.cpp:18
virtual thread * clone() const
Object virtual copy constructor.
Definition: thread.cpp:87
unsigned int u32
32-bit unsigned integer
Definition: config.hpp:102
int i32
32-bit signed integer
Definition: config.hpp:82
virtual const call * backtrace(u32) const
Peek at the simulated call stack.
Definition: thread.cpp:211
virtual const i8 * name() const
Get the thread name.
Definition: thread.cpp:98
unsigned long long mem_addr_t
64-bit memory address
Definition: config.hpp:120
i32 m_lag
The number of calls that must be popped off the simulated stack for it to match the real one...
Definition: thread.hpp:39
Class csdbg::call definition.
pthread_t m_handle
Thread handle.
Definition: thread.hpp:35
virtual thread & set_name(const i8 *)
Set the thread name.
Definition: thread.cpp:138