MySQL  8.0.16
Source Code Documentation
dbug_analyze.cc File Reference
#include <m_string.h>
#include <my_thread.h>

Classes

struct  stack_t
 
struct  module_t
 
struct  bnode
 

Macros

#define PRO_FILE   "dbugmon.out" /* Default output file name */
 
#define STACKSIZ   100 /* Maximum function nesting */
 
#define MAXPROCS   10000 /* Maximum number of function calls */
 
#define EX_SOFTWARE   1
 
#define EX_DATAERR   1
 
#define EX_USAGE   1
 
#define EX_OSERR   1
 
#define EX_IOERR   1
 
#define EX_OK   0
 
#define __MERF_OO_   "%s: Malloc Failed in %s: %d\n"
 
#define MALLOC(Ptr, Num, Typ)
 
#define Malloc(Ptr, Num, Typ)
 
#define FILEOPEN(Fp, Fn, Mod)
 
#define Fileopen(Fp, Fn, Mod)
 
#define top()   &fn_stack[stacktop]
 
#define usage()   fprintf(DBUG_FILE, "Usage: %s [-v] [prof-file]\n", my_name)
 

Functions

void push (name_pos, time_entered) unsigned int name_pos
 
 DBUG_ENTER ("push")
 
 if (++stacktop > STACKSIZ)
 
 DBUG_PRINT ("push",("%d %ld", name_pos, time_entered))
 
unsigned int pop (name_pos, time_entered, child_time) unsigned int *name_pos
 
 DBUG_ENTER ("pop")
 
 if (stacktop< 1)
 
 DBUG_PRINT ("pop",("%d %lu %lu", *name_pos, *time_entered, *child_time))
 
 DBUG_RETURN (rtnval)
 
char * strsave (s) char *s
 
 DBUG_ENTER ("strsave")
 
 DBUG_PRINT ("strsave",("%s", s))
 
 if (!s||(len=strlen(s))==0)
 
 MALLOC (retval,++len, char)
 
 strcpy (retval, s)
 
 DBUG_RETURN (retval)
 
unsigned int add (m_name) char *m_name
 
 DBUG_ENTER ("add")
 
 if (n_items==0)
 
 while ((cmp=strcmp(m_name, modules[ind].name)))
 
 DBUG_RETURN (ind)
 
void process (inf) FILE *inf
 
 DBUG_ENTER ("process")
 
 while (fgets(buf, BUFSIZ, inf) !=NULL)
 
 while (pop(&oldpos, &oldtime, &oldchild))
 
void out_header (outf) FILE *outf
 
 if (verbose)
 
 fprintf (outf, " %%time sec #call ms/call %%calls weight stack name\)
 
void out_trailer (outf, sum_calls, sum_time) FILE *outf
 
void out_item (outf, m, called, timed) FILE *outf
 
 DBUG_ENTER ("out_item")
 
 if (tot_time > 0)
 
 if (tot_calls > 0)
 
 fprintf (outf, "%8.2f%8.3f%8u%8.3f%8.2f%8u%8lu %-s\, per_time, local_ftime, calls, ms_per_call, per_calls, import, stkuse, name)
 
void out_body (outf, root, s_calls, s_time) FILE *outf
 
 DBUG_ENTER ("out_body")
 
 DBUG_PRINT ("out_body",("%lu,%lu", *s_calls, *s_time))
 
 if (root==MAXPROCS)
 
void output (outf) FILE *outf
 
 DBUG_ENTER ("output")
 
 out_body (outf, 0, &sum_calls, &sum_time)
 
int main (int argc, char **argv)
 

Variables

static char * my_name
 
static int verbose
 
static struct stack_t fn_stack [STACKSIZ+1]
 
static unsigned int stacktop = 0
 
static unsigned long tot_time = 0
 
static unsigned long tot_calls = 0
 
static unsigned long highstack = 0
 
static unsigned long lowstack = (ulong)~0
 
unsigned long time_entered = temp->time
 
 t = &fn_stack[stacktop]
 
t pos = name_pos
 
t time = time_entered
 
t children = 0
 
 DBUG_VOID_RETURN
 
unsigned long * child_time = temp->children
 
unsigned int rtnval
 
 else
 
name_pos = temp->pos
 
static struct module_t modules [MAXPROCS]
 
static struct bnode s_table [MAXPROCS]
 
static unsigned int n_items = 0
 
unsigned int len
 
int cmp
 
char fn_name [64]
 
unsigned long fn_time
 
unsigned long fn_sbot
 
unsigned long fn_ssz
 
unsigned long lastuse
 
unsigned long local_time = m->m_time
 
unsigned int oldpos
 
unsigned long oldtime
 
unsigned long oldchild
 
unsigned long int sum_calls
 
unsigned long int sum_time = 0
 
struct module_tm
 
unsigned long int * called = calls
 
unsigned long int * timed = local_time
 
unsigned int calls = m->m_calls
 
unsigned long stkuse = m->m_stkuse
 
unsigned int import = (unsigned int)(per_time * per_calls)
 
double per_time = 0.0
 
double per_calls = 0.0
 
double ms_per_call = calls
 
double local_ftime = local_time
 
unsigned int root
 
unsigned long int * s_calls
 
unsigned long int * s_time
 
int optind
 
char * optarg
 

Macro Definition Documentation

◆ __MERF_OO_

#define __MERF_OO_   "%s: Malloc Failed in %s: %d\n"

◆ EX_DATAERR

#define EX_DATAERR   1

◆ EX_IOERR

#define EX_IOERR   1

◆ EX_OK

#define EX_OK   0

◆ EX_OSERR

#define EX_OSERR   1

◆ EX_SOFTWARE

#define EX_SOFTWARE   1

◆ EX_USAGE

#define EX_USAGE   1

◆ FILEOPEN

#define FILEOPEN (   Fp,
  Fn,
  Mod 
)
Value:
do /* File open with error exit */ \
if (!(Fp = fopen(Fn, Mod))) { \
fprintf(stderr, "%s: Couldn't open %s\n", my_name, Fn); \
exit(EX_IOERR); \
} \
while (0)
#define EX_IOERR
Definition: dbug_analyze.cc:73
static char * my_name
Definition: dbug_analyze.cc:55

◆ Fileopen

#define Fileopen (   Fp,
  Fn,
  Mod 
)
Value:
do /* Weaker version of above */ \
if (!(Fp = fopen(Fn, Mod))) \
fprintf(stderr, "%s: Couldn't open %s\n", my_name, Fn); \
while (0)
static char * my_name
Definition: dbug_analyze.cc:55

◆ MALLOC

#define MALLOC (   Ptr,
  Num,
  Typ 
)
Value:
do /* Malloc w/error checking & exit */ \
if (!(Ptr = (Typ *)malloc((Num) * (sizeof(Typ))))) { \
fprintf(stderr, __MERF_OO_, my_name, __FILE__, __LINE__); \
exit(EX_OSERR); \
} \
while (0)
#define malloc(A)
Definition: fts0ast.h:41
#define EX_OSERR
Definition: dbug_analyze.cc:72
#define __MERF_OO_
Definition: dbug_analyze.cc:79
static char * my_name
Definition: dbug_analyze.cc:55

◆ Malloc

#define Malloc (   Ptr,
  Num,
  Typ 
)
Value:
do /* Weaker version of above */ \
if (!(Ptr = (Typ *)malloc((Num) * (sizeof(Typ))))) \
fprintf(stderr, __MERF_OO_, my_name, __FILE__, __LINE__); \
while (0)
#define malloc(A)
Definition: fts0ast.h:41
#define __MERF_OO_
Definition: dbug_analyze.cc:79
static char * my_name
Definition: dbug_analyze.cc:55

◆ MAXPROCS

#define MAXPROCS   10000 /* Maximum number of function calls */

◆ PRO_FILE

#define PRO_FILE   "dbugmon.out" /* Default output file name */

◆ STACKSIZ

#define STACKSIZ   100 /* Maximum function nesting */

◆ top

#define top ( )    &fn_stack[stacktop]

◆ usage

static void usage (   void)    fprintf(DBUG_FILE, "Usage: %s [-v] [prof-file]\n", my_name)

Function Documentation

◆ add()

unsigned int add ( m_name  )

◆ DBUG_ENTER() [1/8]

DBUG_ENTER ( "push"  )

◆ DBUG_ENTER() [2/8]

DBUG_ENTER ( "pop"  )

◆ DBUG_ENTER() [3/8]

DBUG_ENTER ( "strsave"  )

◆ DBUG_ENTER() [4/8]

DBUG_ENTER ( "add"  )

◆ DBUG_ENTER() [5/8]

DBUG_ENTER ( "process"  )

◆ DBUG_ENTER() [6/8]

DBUG_ENTER ( "out_item"  )

◆ DBUG_ENTER() [7/8]

DBUG_ENTER ( "out_body"  )

◆ DBUG_ENTER() [8/8]

DBUG_ENTER ( "output"  )

◆ DBUG_PRINT() [1/4]

DBUG_PRINT ( "push"  ,
("%d %ld", name_pos, time_entered  
)

◆ DBUG_PRINT() [2/4]

DBUG_PRINT ( "pop"  ,
("%d %lu %lu", *name_pos, *time_entered, *child_time  
)

◆ DBUG_PRINT() [3/4]

DBUG_PRINT ( "strsave"  ,
("%s", s)   
)

◆ DBUG_PRINT() [4/4]

DBUG_PRINT ( "out_body"  ,
("%lu,%lu", *s_calls, *s_time  
)

◆ DBUG_RETURN() [1/3]

DBUG_RETURN ( rtnval  )

◆ DBUG_RETURN() [2/3]

DBUG_RETURN ( retval  )

◆ DBUG_RETURN() [3/3]

DBUG_RETURN ( ind  )

◆ fprintf() [1/2]

fprintf ( outf  ,
" %%time sec #call ms/call %%calls weight stack name\   
)

◆ fprintf() [2/2]

fprintf ( outf  ,
"%8.2f%8.3f%8u%8.3f%8.2f%8u%8lu %-s\  ,
per_time  ,
local_ftime  ,
calls  ,
ms_per_call  ,
per_calls  ,
import  ,
stkuse  ,
name   
)

◆ if() [1/8]

if ( ++  stacktop,
STACKSIZ   
)

◆ if() [2/8]

if ( )

◆ if() [3/8]

if ( !s||  len=strlen(s) = = 0)

◆ if() [4/8]

if ( n_items  = = 0)

◆ if() [5/8]

if ( verbose  )
Initial value:
{
DBUG_ENTER("out_trailer")
DBUG_ENTER("push")

◆ if() [6/8]

if ( tot_time  ,
 
)

◆ if() [7/8]

if ( tot_calls  ,
 
)

◆ if() [8/8]

if ( root  = MAXPROCS)

◆ main()

int main ( int  argc,
char **  argv 
)

◆ MALLOC()

MALLOC ( retval  ,
++  len,
char   
)

◆ out_body() [1/2]

void out_body ( outf  ,
root  ,
s_calls  ,
s_time   
)

◆ out_body() [2/2]

out_body ( outf  ,
,
sum_calls,
sum_time 
)

◆ out_header()

out_header ( outf  )

◆ out_item()

void out_item ( outf  ,
m  ,
called  ,
timed   
)

◆ out_trailer()

out_trailer ( outf  ,
sum_calls  ,
sum_time   
)

◆ output()

void output ( outf  )

◆ pop()

unsigned int pop ( name_pos  ,
time_entered  ,
child_time   
)

◆ process()

void process ( inf  )

◆ push()

void push ( name_pos  ,
time_entered   
)

◆ strcpy()

strcpy ( retval  ,
 
)

◆ strsave()

char* strsave ( )

◆ while() [1/3]

while ( (cmp=strcmp(m_name, modules[ind].name))  )

◆ while() [2/3]

while ( fgets(buf, BUFSIZ, inf) !  = NULL)

◆ while() [3/3]

while ( pop &, &, &  oldchild)

Variable Documentation

◆ called

* called = calls

◆ calls

unsigned int calls = m->m_calls

◆ child_time

* child_time = temp->children

◆ children

t children = 0

◆ cmp

int cmp
Initial value:
{
unsigned int ind = 0

◆ DBUG_VOID_RETURN

DBUG_VOID_RETURN

◆ else

else
Initial value:
{
temp = &fn_stack[stacktop]
static struct stack_t fn_stack[STACKSIZ+1]
Definition: dbug_analyze.cc:115
static unsigned int stacktop
Definition: dbug_analyze.cc:117

◆ fn_name

char fn_name[64]
Initial value:
{
char buf[BUFSIZ]

◆ fn_sbot

unsigned long fn_sbot

◆ fn_ssz

unsigned long fn_ssz

◆ fn_stack

struct stack_t fn_stack[STACKSIZ+1]
static

◆ fn_time

unsigned long fn_time

◆ highstack

unsigned long highstack = 0
static

◆ import

import = (unsigned int)(per_time * per_calls)

◆ lastuse

unsigned long lastuse

◆ len

unsigned int len
Initial value:
{
char *retval

◆ local_ftime

local_ftime = local_time

◆ local_time

unsigned long local_time = m->m_time

◆ lowstack

unsigned long lowstack = (ulong)~0
static

◆ m

struct module_t* m

◆ modules

struct module_t modules[MAXPROCS]
static

◆ ms_per_call

ms_per_call = calls

◆ my_name

char* my_name
static

◆ n_items

unsigned int n_items = 0
static

◆ name_pos

* name_pos = temp->pos

◆ oldchild

unsigned long oldchild

◆ oldpos

unsigned int oldpos

◆ oldtime

unsigned long oldtime

◆ optarg

char* optarg

◆ optind

int optind

◆ per_calls

double per_calls = 0.0

◆ per_time

double per_time = 0.0

◆ pos

unsigned int pos = name_pos

◆ root

unsigned int root

◆ rtnval

rtnval
Initial value:
{
struct stack_t *temp
Definition: dbug_analyze.cc:109

◆ s_calls

unsigned long int* s_calls

◆ s_table

struct bnode s_table[MAXPROCS]
static

◆ s_time

unsigned long int * s_time

◆ stacktop

unsigned int stacktop = 0
static

◆ stkuse

unsigned long stkuse = m->m_stkuse

◆ sum_calls

unsigned long int sum_calls

◆ sum_time

unsigned long int sum_time = 0

◆ t

struct stack_t * t = &fn_stack[stacktop]

◆ time

t time = time_entered

◆ time_entered

* time_entered = temp->time

◆ timed

* timed = local_time

◆ tot_calls

unsigned long tot_calls = 0
static

◆ tot_time

unsigned long tot_time = 0
static

◆ verbose

int verbose
static