gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
profile.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005 The Regents of The University of Michigan
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * Authors: Nathan Binkert
29  */
30 
31 #ifndef __CPU_PROFILE_HH__
32 #define __CPU_PROFILE_HH__
33 
34 #include <map>
35 
36 #include "arch/stacktrace.hh"
37 #include "base/types.hh"
38 #include "config/the_isa.hh"
39 #include "cpu/static_inst.hh"
40 
41 class ThreadContext;
42 
44 {
45  private:
46  friend class FunctionProfile;
47 
48  typedef std::map<Addr, ProfileNode *> ChildList;
50 
51  public:
53 
54  public:
55  ProfileNode();
56 
57  void dump(const std::string &symbol, uint64_t id,
58  const SymbolTable *symtab, std::ostream &os) const;
59  void clear();
60 };
61 
62 class Callback;
64 {
65  private:
69  std::map<Addr, Counter> pc_count;
70  TheISA::StackTrace trace;
71 
72  public:
75 
78  void clear();
79  void dump(ThreadContext *tc, std::ostream &out) const;
80  void sample(ProfileNode *node, Addr pc);
81 };
82 
83 inline ProfileNode *
85 {
86  if (!trace.trace(tc, inst))
87  return NULL;
88  trace.dprintf();
89  return consume(trace.getstack());
90 }
91 
92 #endif // __CPU_PROFILE_HH__
Counter count
Definition: profile.hh:52
std::map< Addr, ProfileNode * > ChildList
Definition: profile.hh:48
void dump(ThreadContext *tc, std::ostream &out) const
Definition: profile.cc:124
Generic callback class.
Definition: callback.hh:41
FunctionProfile(const SymbolTable *symtab)
Definition: profile.cc:88
void sample(ProfileNode *node, Addr pc)
Definition: profile.cc:146
std::map< Addr, Counter > pc_count
Definition: profile.hh:69
ChildList children
Definition: profile.hh:49
const SymbolTable * symtab
Definition: profile.hh:67
void clear()
Definition: profile.cc:80
ProfileNode top
Definition: profile.hh:68
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Bitfield< 17 > os
Definition: misc.hh:804
ProfileNode()
Definition: profile.cc:45
TheISA::StackTrace trace
Definition: profile.hh:70
void clear()
Definition: profile.cc:117
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Callback * reset
Definition: profile.hh:66
int64_t Counter
Statistics counter type.
Definition: types.hh:58
Bitfield< 17, 16 > stack
Definition: misc.hh:588
IntReg pc
Definition: remote_gdb.hh:91
ProfileNode * consume(ThreadContext *tc, const StaticInstPtr &inst)
Definition: profile.hh:84
void dump(const std::string &symbol, uint64_t id, const SymbolTable *symtab, std::ostream &os) const
Definition: profile.cc:50

Generated on Fri Jun 9 2017 13:03:44 for gem5 by doxygen 1.8.6