~vadim-tk/percona-server/percona-galera-5.1.57-0.8.1

« back to all changes in this revision

Viewing changes to storage/ndb/include/debugger/SignalLoggerManager.hpp

  • Committer: root
  • Date: 2011-07-28 00:14:23 UTC
  • Revision ID: root@r815.office.percona.com-20110728001423-6pw0v4b7r0dkbsr4
Ported to Galera 0.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
//****************************************************************************
 
17
//
 
18
// .NAME
 
19
//      SignalLoggerManager - Handle signal loggers
 
20
//
 
21
//****************************************************************************
 
22
#ifndef SignalLoggerManager_H
 
23
#define SignalLoggerManager_H
 
24
 
 
25
 
 
26
#include <kernel_types.h>
 
27
#include <BlockNumbers.h>
 
28
#include <TransporterDefinitions.hpp>
 
29
 
 
30
class SignalLoggerManager
 
31
{
 
32
public:
 
33
  SignalLoggerManager();
 
34
  virtual ~SignalLoggerManager();
 
35
 
 
36
  /**
 
37
   * Sets output
 
38
   * @Returns old output stream
 
39
   */
 
40
  FILE * setOutputStream(FILE * output);
 
41
  
 
42
  /**
 
43
   * Gets current output
 
44
   */
 
45
  FILE * getOutputStream() const;
 
46
 
 
47
  void flushSignalLog();
 
48
  
 
49
  /**
 
50
   * For direct signals
 
51
   * @See also SimulatedBlock EXECUTE_DIRECT
 
52
   */   
 
53
  void executeDirect(const SignalHeader&, 
 
54
                     Uint8 prio, const Uint32 * theData, Uint32 node);
 
55
  
 
56
  /**
 
57
   * For input signals
 
58
   */
 
59
  void executeSignal(const SignalHeader&, Uint8 prio,
 
60
                     const Uint32 * theData, Uint32 node,
 
61
                     const SegmentedSectionPtr ptr[3], Uint32 secs);
 
62
 
 
63
  void executeSignal(const SignalHeader&, Uint8 prio,
 
64
                     const Uint32 * theData, Uint32 node,
 
65
                     const LinearSectionPtr ptr[3], Uint32 secs);
 
66
 
 
67
  /**
 
68
   * For output signals
 
69
   */
 
70
  void sendSignal(const SignalHeader&, Uint8 prio, 
 
71
                  const Uint32 * theData, Uint32 node,
 
72
                  const SegmentedSectionPtr ptr[3], Uint32 secs);
 
73
 
 
74
  void sendSignal(const SignalHeader&, Uint8 prio, 
 
75
                  const Uint32 * theData, Uint32 node,
 
76
                  const LinearSectionPtr ptr[3], Uint32 secs);
 
77
  
 
78
  /**
 
79
   * For output signals
 
80
   */
 
81
  void sendSignalWithDelay(Uint32 delayInMilliSeconds, 
 
82
                           const SignalHeader&, 
 
83
                           Uint8 prio, const Uint32 * data, Uint32 node,
 
84
                           const SegmentedSectionPtr ptr[3], Uint32 secs);
 
85
  
 
86
  /**
 
87
   * Generic messages in the signal log
 
88
   */
 
89
  void log(BlockNumber bno, const char * msg, ...);
 
90
  
 
91
  /**
 
92
   * LogModes
 
93
   */
 
94
  enum LogMode {
 
95
    LogOff   = 0,
 
96
    LogIn    = 1,
 
97
    LogOut   = 2,
 
98
    LogInOut = 3
 
99
  };
 
100
 
 
101
  /**
 
102
   * Returns no of loggers affected
 
103
   */
 
104
  int log(LogMode logMode, const char * params);
 
105
  int logOn(bool allBlocks, BlockNumber bno, LogMode logMode);
 
106
  int logOff(bool allBlocks, BlockNumber bno, LogMode logMode);
 
107
  int logToggle(bool allBlocks, BlockNumber bno, LogMode logMode);
 
108
  
 
109
  void setTrace(unsigned long trace);   
 
110
  unsigned long getTrace() const;
 
111
 
 
112
  void setOwnNodeId(int nodeId);
 
113
  void setLogDistributed(bool val);
 
114
 
 
115
  /**
 
116
   * Print header
 
117
   */
 
118
  static void printSignalHeader(FILE * output, 
 
119
                                const SignalHeader & sh,
 
120
                                Uint8 prio, 
 
121
                                Uint32 node,
 
122
                                bool printReceiversSignalId);
 
123
  
 
124
  /**
 
125
   * Function for printing the Signal Data
 
126
   */
 
127
  static void printSignalData(FILE * out, 
 
128
                              const SignalHeader & sh, const Uint32 *);
 
129
 
 
130
  /**
 
131
   * Print linear section.
 
132
   */
 
133
  static void printLinearSection(FILE * output,
 
134
                                 const SignalHeader & sh,
 
135
                                 const LinearSectionPtr ptr[3],
 
136
                                 unsigned i);
 
137
 
 
138
  /**
 
139
   * Print segmented section.
 
140
   */
 
141
  static void printSegmentedSection(FILE * output,
 
142
                                    const SignalHeader & sh,
 
143
                                    const SegmentedSectionPtr ptr[3],
 
144
                                    unsigned i);
 
145
 
 
146
  /**
 
147
   * Print data word in hex.  Adds line break before the word
 
148
   * when pos > 0 && pos % 7 == 0.  Increments pos.
 
149
   */
 
150
  static void printDataWord(FILE * output, Uint32 & pos, const Uint32 data);
 
151
 
 
152
private:
 
153
  bool m_logDistributed;
 
154
  Uint32 m_ownNodeId;
 
155
 
 
156
  FILE * outputStream;
 
157
  int log(int cmd, BlockNumber bno, LogMode logMode);
 
158
  
 
159
  Uint32        traceId;
 
160
  Uint8         logModes[NO_OF_BLOCKS];
 
161
  
 
162
  inline bool
 
163
  logMatch(BlockNumber bno, LogMode mask)
 
164
  {
 
165
    // avoid addressing outside logModes
 
166
    return
 
167
      bno < MIN_BLOCK_NO || bno > MAX_BLOCK_NO ||
 
168
      (logModes[bno-MIN_BLOCK_NO] & mask);
 
169
  }
 
170
};
 
171
 
 
172
#endif // SignalLoggerManager_H
 
173