8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 22:03:03 +01:00

Added blr_src_info. Error call stack now contains not only

procedures\triggers names but line\column numbers also.
Thanks to Eugeney Putilin for idea
This commit is contained in:
hvlad 2006-07-04 14:44:43 +00:00
parent f8dbba47ac
commit fac53c8177
13 changed files with 79 additions and 6 deletions

View File

@ -2814,6 +2814,10 @@ void DSQL_pretty(const dsql_nod* node, int column)
verb = "lock_timeout"; // maybe show the timeout value?
break;
case nod_src_info:
verb = "source_info";
break;
default:
sprintf(s, "unknown type %d", node->nod_type);
verb = s;

View File

@ -1227,6 +1227,12 @@ void GEN_statement( dsql_req* request, dsql_nod* node)
}
return;
case nod_src_info:
stuff(request, blr_src_info);
stuff_word(request, node->nod_line);
stuff_word(request, node->nod_column);
return;
default:
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 901,
isc_arg_gds, isc_dsql_internal_err,

View File

@ -342,7 +342,8 @@ enum nod_t
nod_redef_trigger,
nod_tra_misc,
nod_lock_timeout,
nod_agg_list
nod_agg_list,
nod_src_info
};
typedef nod_t NOD_TYPE;

View File

@ -1587,10 +1587,27 @@ proc_statements : proc_block
{ $$ = make_node (nod_list, 2, $1, $2); }
;
proc_statement : simple_proc_statement ';'
| complex_proc_statement
proc_statement : stmt_start_line stmt_start_column simple_proc_statement ';'
{
dsql_nod* src_info = make_node (nod_src_info, 2, $1, $2);
$$ = make_node (nod_list, 2, src_info, $3);
}
| stmt_start_line stmt_start_column complex_proc_statement
{
dsql_nod* src_info = make_node (nod_src_info, 2, $1, $2);
$$ = make_node (nod_list, 2, src_info, $3);
}
;
stmt_start_line :
{ $$ = (dsql_nod*) (IPTR) lex.lines_bk; }
stmt_start_column :
{
const USHORT column = (lex.last_token_bk - lex.line_start_bk + 1);
$$ = (dsql_nod*) (IPTR) column;
}
simple_proc_statement : assignment
| insert
| update

View File

@ -1727,6 +1727,13 @@ dsql_nod* PASS1_statement(dsql_req* request, dsql_nod* input, bool proc_flag)
}
return input;
case nod_src_info:
{
input->nod_line = (USHORT) (IPTR) input->nod_arg[0];
input->nod_column = (USHORT) (IPTR) input->nod_arg[1];
return input;
}
default:
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 901,
isc_arg_gds, isc_dsql_command_err,

View File

@ -212,6 +212,7 @@ static const struct
{"lowcase", one},
{"strlen", strlength},
{"trim", trim},
{"src_info", src_info},
{0, 0}
};

View File

@ -333,4 +333,9 @@
#define blr_cursor_close (unsigned char)1
#define blr_cursor_fetch (unsigned char)2
/* FB 2.1 specific BLR */
/* Source code line and column numbers */
#define blr_src_info (unsigned char)184
#endif /* JRD_BLR_H */

View File

@ -896,6 +896,9 @@ void EXE_start(thread_db* tdbb, jrd_req* request, jrd_tra* transaction)
VIO_start_save_point(tdbb, transaction);
}
request->req_src_line = 0;
request->req_src_column = 0;
#ifdef WIN_NT
START_CHECK_FOR_EXCEPTIONS(NULL);
#endif
@ -1541,8 +1544,16 @@ static void stuff_stack_trace(const jrd_req* request)
isEmpty = false;
sTrace += name + "'";
}
else
else {
sTrace += "\n" + name + "'";
}
if (req->req_src_line)
{
Firebird::string src_info;
src_info.printf(" line: %u, col: %u", req->req_src_line, req->req_src_column);
sTrace += src_info;
}
}
}
@ -2432,6 +2443,15 @@ static jrd_nod* looper(thread_db* tdbb, jrd_req* request, jrd_nod* in_node)
node = node->nod_parent;
break;
case nod_src_info:
if (request->req_operation == jrd_req::req_evaluate) {
request->req_src_line = (USHORT) (IPTR) node->nod_arg[0];
request->req_src_column = (USHORT) (IPTR) node->nod_arg[1];
request->req_operation = jrd_req::req_return;
}
node = node->nod_parent;
break;
default:
BUGCHECK(168); /* msg 168 looper: action not yet implemented */
}
@ -3671,7 +3691,7 @@ static void validate(thread_db* tdbb, jrd_nod* list)
if (vector && id < vector->count() &&
(field = (*vector)[id]))
{
name = field->fld_name.c_str();
name = ERR_cstring(field->fld_name.c_str());
}
}

View File

@ -356,7 +356,8 @@ static const UCHAR
dcl_cursor[] = { op_word, op_line, op_verb, 0},
cursor_stmt[] = { op_cursor_stmt, 0 },
strlength[] = { op_byte, op_line, op_verb, 0},
trim[] = { op_byte, op_byte, op_line, op_verb, 0};
trim[] = { op_byte, op_byte, op_line, op_verb, 0},
src_info[] = { op_word, op_word, op_line, 0};
#include "../jrd/blp.h"

View File

@ -190,3 +190,5 @@ NODE(nod_asn_list, asn_list, "")
NODE(nod_equiv, equiv, " == ")
NODE(nod_strlen, strlen, "STRLEN")
NODE(nod_src_info, source_info, "")

View File

@ -2903,6 +2903,11 @@ static jrd_nod* parse(thread_db* tdbb, CompilerScratch* csb, USHORT expected,
break;
#endif
case blr_src_info:
node->nod_arg[0] = (jrd_nod*) (IPTR) BLR_WORD;
node->nod_arg[1] = (jrd_nod*) (IPTR) BLR_WORD;
break;
default:
syntax_error(csb, elements[expected]);
}

View File

@ -247,6 +247,9 @@ public:
Savepoint* req_proc_sav_point; /* procedure savepoint list */
Firebird::TimeStamp req_timestamp; /* Start time of request */
USHORT req_src_line;
USHORT req_src_column;
enum req_ta {
req_trigger_insert = 1,
req_trigger_update = 2,

View File

@ -213,6 +213,7 @@ static const VERB verbs[] =
PAIR(nod_lowcase, blr_lowcase, 1, 1, VALUE, VALUE),
PAIR(nod_strlen, blr_strlen, e_strlen_length, e_strlen_count, VALUE, VALUE),
PAIR(nod_trim, blr_trim, e_trim_length, e_trim_count, VALUE, VALUE),
PAIR(nod_src_info, blr_src_info, 2, 0, STATEMENT, STATEMENT),
{0, NULL, NULL, NULL, NULL, NULL, NULL}
};