1
/* Copyright (C) 2003 MySQL AB
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.
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.
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 */
16
#include <ndb_global.h>
17
#include <BaseString.hpp>
19
#include "DebuggerNames.hpp"
21
#include <BlockNumbers.h>
22
#include <GlobalSignalNumbers.h>
23
#include <signaldata/SignalDataPrint.hpp>
25
static const char * localSignalNames[MAX_GSN+1];
26
static SignalDataPrintFunction localPrintFunctions[MAX_GSN+1];
27
static const char * localBlockNames[NO_OF_BLOCKS];
31
initSignalNames(const char * dst[], const GsnName src[], unsigned short len){
33
for(i = 0; i<=MAX_GSN; i++)
36
for(i = 0; i<len; i++){
37
unsigned short gsn = src[i].gsn;
38
const char * name = src[i].name;
40
if(dst[gsn] != 0 && name != 0){
41
if(strcmp(dst[gsn], name) != 0){
43
"Multiple definition of signal name for gsn: %d (%s, %s)\n",
55
initSignalPrinters(SignalDataPrintFunction dst[],
56
const NameFunctionPair src[]){
58
for(i = 0; i<=MAX_GSN; i++)
62
for(i = 0; (gsn = src[i].gsn) > 0; i++){
63
SignalDataPrintFunction fun = src[i].function;
65
if(dst[gsn] != 0 && fun != 0){
68
"Multiple definition of signal print function for gsn: %d\n",
80
initBlockNames(const char * dst[],
81
const BlockName src[],
84
for(i = 0; i<NO_OF_BLOCKS; i++)
87
for(i = 0; i<len; i++){
88
const int index = src[i].number - MIN_BLOCK_NO;
89
if(index < 0 && index >= NO_OF_BLOCKS || dst[index] != 0){
91
"Invalid block name definition: %d %s\n",
92
src[i].number, src[i].name);
95
dst[index] = src[i].name;
101
* Run static initializer
104
xxx_DUMMY_SIGNAL_NAMES_xxx = initSignalNames(localSignalNames,
108
xxx_DUMMY_PRINT_FUNCTIONS_xxx = initSignalPrinters(localPrintFunctions,
109
SignalDataPrintFunctions);
112
xxx_DUMMY_BLOCK_NAMES_xxx = initBlockNames(localBlockNames,
117
getSignalName(unsigned short gsn, const char * defVal){
118
if(gsn > 0 && gsn <= MAX_GSN)
119
return (localSignalNames[gsn] ? localSignalNames[gsn] : defVal);
124
getGsn(const char * signalName){
129
getBlockName(unsigned short blockNo, const char * ret){
130
if(blockNo >= MIN_BLOCK_NO && blockNo <= MAX_BLOCK_NO)
131
return localBlockNames[blockNo-MIN_BLOCK_NO];
134
BaseString::snprintf(buf, sizeof(buf), "BLOCK#%d", (int)blockNo);
141
getBlockNo(const char * blockName){
142
for(int i = 0; i<NO_OF_BLOCKS; i++)
143
if(localBlockNames[i] != 0 && strcmp(localBlockNames[i], blockName) == 0)
144
return i + MIN_BLOCK_NO;
148
SignalDataPrintFunction
149
findPrintFunction(unsigned short gsn){
150
if(gsn > 0 && gsn <= MAX_GSN)
151
return localPrintFunctions[gsn];