Add component name in debugger positions.

[INTERPRETER]
* NEW: Add component name in debugger positions.

[GB.DEBUG]
* NEW: Add component name in debugger positions.
This commit is contained in:
Benoît Minisini 2022-07-22 20:31:51 +02:00
parent e3c26497f2
commit c78d7fb496
3 changed files with 44 additions and 35 deletions

View file

@ -74,7 +74,12 @@ const char *DEBUG_get_position(CLASS *cp, FUNCTION *fp, PCODE *pc)
{ {
#if DEBUG_MEMORY #if DEBUG_MEMORY
static char buffer[256]; static char buffer[256];
const int buffer_size = sizeof(buffer);
#else
char *buffer = COMMON_buffer;
const int buffer_size = COMMON_BUF_MAX;
#endif #endif
ushort line = 0; ushort line = 0;
if (!cp || !pc) if (!cp || !pc)
@ -83,21 +88,22 @@ const char *DEBUG_get_position(CLASS *cp, FUNCTION *fp, PCODE *pc)
if (fp != NULL && fp->debug) if (fp != NULL && fp->debug)
calc_line_from_position(cp, fp, pc, &line); calc_line_from_position(cp, fp, pc, &line);
#if DEBUG_MEMORY if (cp->component)
snprintf(buffer, sizeof(buffer), "%s.%s.%d", {
cp ? cp->name : "?", snprintf(buffer, buffer_size, "[%s].%s.%s.%d",
(fp && fp->debug) ? fp->debug->name : "?", cp->component->name, cp->name,
line); (fp && fp->debug) ? fp->debug->name : "?",
line);
}
else
{
snprintf(buffer, buffer_size, "%s.%s.%d",
cp->name,
(fp && fp->debug) ? fp->debug->name : "?",
line);
}
return buffer; return buffer;
#else
snprintf(COMMON_buffer, COMMON_BUF_MAX, "%.64s.%.64s.%d",
cp->name,
(fp && fp->debug) ? fp->debug->name : "?",
line);
return COMMON_buffer;
#endif
} }

View file

@ -648,12 +648,8 @@ void DEBUG_backtrace(FILE *out)
{ {
int i, n; int i, n;
STACK_CONTEXT *context; STACK_CONTEXT *context;
ushort line;
if (CP) fprintf(out, "%s", DEBUG_get_current_position());
fprintf(out, "%s", DEBUG_get_current_position());
else
fprintf(out, "?");
//for (i = 0; i < (STACK_frame_count - 1); i++) //for (i = 0; i < (STACK_frame_count - 1); i++)
n = 0; n = 0;
@ -663,7 +659,9 @@ void DEBUG_backtrace(FILE *out)
if (!context) if (!context)
break; break;
if (context->pc) n += fprintf(out, " %s", DEBUG_get_position(context->cp, context->fp, context->pc));
/*if (context->pc)
{ {
line = 0; line = 0;
if (DEBUG_calc_line_from_position(context->cp, context->fp, context->pc, &line)) if (DEBUG_calc_line_from_position(context->cp, context->fp, context->pc, &line))
@ -672,7 +670,7 @@ void DEBUG_backtrace(FILE *out)
n += fprintf(out, " %s.%s.%d", context->cp->name, context->fp->debug->name, line); n += fprintf(out, " %s.%s.%d", context->cp->name, context->fp->debug->name, line);
} }
else if (context->cp) else if (context->cp)
n += fprintf(out, " ?"); n += fprintf(out, " ?");*/
if (n >= (DEBUG_OUTPUT_MAX_SIZE / 2)) if (n >= (DEBUG_OUTPUT_MAX_SIZE / 2))
{ {
@ -1063,25 +1061,30 @@ void DEBUG_breakpoint(int id)
const char *DEBUG_get_position(CLASS *cp, FUNCTION *fp, PCODE *pc) const char *DEBUG_get_position(CLASS *cp, FUNCTION *fp, PCODE *pc)
{ {
if (pc) const char *comp_name;
const char *class_name;
const char *func_name;
ushort line = 0;
if (!cp)
return "?";
class_name = cp->name;
if (cp->component)
comp_name = cp->component->name;
else
comp_name = "$";
if (fp && fp->debug)
{ {
ushort line = 0; func_name = fp->debug->name;
if (pc)
if (fp != NULL && fp->debug)
DEBUG_calc_line_from_position(cp, fp, pc, &line); DEBUG_calc_line_from_position(cp, fp, pc, &line);
snprintf(DEBUG_buffer, sizeof(DEBUG_buffer), "%.64s.%.64s.%d",
cp ? cp->name : "?",
(fp && fp->debug) ? fp->debug->name : "?",
line);
} }
else else
{ func_name = "?";
snprintf(DEBUG_buffer, sizeof(DEBUG_buffer), "%.64s.%.64s",
cp ? cp->name : "?",
(fp && fp->debug) ? fp->debug->name : "?");
}
snprintf(DEBUG_buffer, sizeof(DEBUG_buffer), "[%s].%s.%s.%d", comp_name, class_name, func_name, line);
return DEBUG_buffer; return DEBUG_buffer;
} }

View file

@ -47,7 +47,7 @@ EXTERN char DEBUG_buffer[];
EXTERN char *DEBUG_fifo; EXTERN char *DEBUG_fifo;
#endif #endif
#define DEBUG_BUFFER_MAX 255 #define DEBUG_BUFFER_MAX 512
#define GB_DEBUG (*DEBUG_interface) #define GB_DEBUG (*DEBUG_interface)