blob: a662056067311952e22ba99f05eaa1389732f234 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- FunctionProfiler.h --------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Created by Greg Clayton on 10/8/08.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef __FunctionProfiler_h__
15#define __FunctionProfiler_h__
16
17// C Includes
18
19// C++ Includes
20#include <map>
21#include <vector>
22#include <string>
23
24// Other libraries and framework includes
25
26// Project includes
27#include "DNBDefs.h"
28#include "DNBRuntimeAction.h"
29#include "PThreadMutex.h"
30
31class DNBBreakpoint;
32class MachProcess;
33
34class FunctionProfiler : public DNBRuntimeAction
35{
36public:
37 FunctionProfiler (nub_addr_t start_addr, nub_addr_t stop_addr);
38 virtual ~FunctionProfiler ();
39
40 //------------------------------------------------------------------
41 // DNBRuntimeAction required functions
42 //------------------------------------------------------------------
43 virtual void Initialize(nub_process_t pid);
44 virtual void ProcessStateChanged(nub_state_t state);
45 virtual void SharedLibraryStateChanged(DNBExecutableImageInfo *image_infos, nub_size_t num_image_infos) {}
46
47 nub_bool_t BreakpointHit(nub_process_t pid, nub_thread_t tid, nub_break_t breakID);
48 bool ShouldStepProcess() const
49 {
50 return m_func_entered_count > 0;
51 }
52protected:
53 static nub_bool_t BreakpointHitCallback (nub_process_t pid, nub_thread_t tid, nub_break_t breakID, void *baton);
54 void Clear();
55 void SetBreakpoints();
56
57 nub_process_t m_pid;
58 nub_addr_t m_start_addr;
59 nub_addr_t m_stop_addr;
60 nub_break_t m_start_break_id;
61 nub_break_t m_stop_break_id;
62 uint32_t m_func_entered_count;
63 nub_addr_t m_last_pc;
64 uint32_t m_last_flags;
65 uint32_t m_consecutive_opcode_count;
66 uint32_t m_total_opcode_count;
67};
68
69
70#endif // __FunctionProfiler_h__