1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
/******************************************************************************
* TinTin++ *
* Copyright (C) 2004 (See CREDITS file) *
* *
* This program is protected under the GNU GPL (See COPYING) *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
*******************************************************************************/
/******************************************************************************
* (T)he K(I)cki(N) (T)ickin D(I)kumud Clie(N)t *
* *
* coded by Igor van den Hoven 2004 *
******************************************************************************/
#include "tintin.h"
#define MAX_STACK_SIZE 51
#define MAX_DEBUG_SIZE 400
char debug_stack[MAX_STACK_SIZE][MAX_DEBUG_SIZE];
short debug_index;
int push_call(char *f, ...)
{
va_list ap;
if (debug_index < MAX_STACK_SIZE)
{
va_start(ap, f);
vsnprintf(debug_stack[debug_index], MAX_DEBUG_SIZE - 1, f, ap);
va_end(ap);
}
if (++debug_index == 10000)
{
dump_stack();
return 1;
}
return 0;
}
void pop_call(void)
{
if (debug_index > 0)
{
debug_index--;
}
else
{
tintin_printf2(gtd->ses, "pop_call: index is zero.");
dump_full_stack();
}
}
void dump_stack(void)
{
unsigned char i;
for (i = 0 ; i < debug_index && i < MAX_STACK_SIZE ; i++)
{
printf("\033[1;32mDEBUG_STACK[\033[1;31m%03d\033[1;32m] = \033[1;31m%s\n", i, debug_stack[i]);
}
}
void dump_full_stack(void)
{
unsigned char i;
tintin_header(gtd->ses, " FULL DEBUG STACK ");
for (i = 0 ; i < MAX_STACK_SIZE ; i++)
{
if (*debug_stack[i])
{
tintin_printf2(gtd->ses, "\033[1;31mDEBUG_STACK[%03d] = %s", i, debug_stack[i]);
}
}
tintin_header(gtd->ses, "");
}
|