mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 21:23:04 +01:00
Introduced generic way to add some specific markers for primary BLR verbs using new blr_marks code.
Debug info markers is replaced by blr_marks. Debug info format and version is changed back.
This commit is contained in:
parent
16b39a8a96
commit
7a97a8b050
@ -141,13 +141,6 @@ void BlrDebugWriter::putDebugSubProcedure(DeclareSubProcNode* subProcNode)
|
||||
debugData.add(subDebugData.begin(), count);
|
||||
}
|
||||
|
||||
void BlrDebugWriter::putDebugMarkers(ULONG marks)
|
||||
{
|
||||
debugData.add(fb_dbg_map_markers);
|
||||
putValue(marks);
|
||||
putBlrOffset();
|
||||
}
|
||||
|
||||
void BlrDebugWriter::putValue(ULONG val)
|
||||
{
|
||||
debugData.add(val);
|
||||
|
@ -50,7 +50,6 @@ public:
|
||||
void putDebugCursor(USHORT, const Firebird::MetaName&);
|
||||
void putDebugSubFunction(DeclareSubFuncNode* subFuncNode);
|
||||
void putDebugSubProcedure(DeclareSubProcNode* subProcNode);
|
||||
void putDebugMarkers(ULONG marks);
|
||||
|
||||
DebugData& getDebugData() { return debugData; }
|
||||
|
||||
|
@ -59,6 +59,27 @@ void DsqlCompilerScratch::dumpContextStack(const DsqlContextStack* stack)
|
||||
#endif
|
||||
|
||||
|
||||
void DsqlCompilerScratch::putBlrMarkers(ULONG marks)
|
||||
{
|
||||
appendUChar(blr_marks);
|
||||
if (marks <= MAX_UCHAR)
|
||||
{
|
||||
appendUChar(1);
|
||||
appendUChar(marks);
|
||||
}
|
||||
else if (marks <= MAX_USHORT)
|
||||
{
|
||||
appendUChar(2);
|
||||
appendUShort(marks);
|
||||
}
|
||||
else
|
||||
{
|
||||
appendUChar(4);
|
||||
appendULong(marks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write out field data type.
|
||||
// Taking special care to declare international text.
|
||||
void DsqlCompilerScratch::putDtype(const TypeClause* field, bool useSubType)
|
||||
|
@ -169,6 +169,7 @@ public:
|
||||
return statement;
|
||||
}
|
||||
|
||||
void putBlrMarkers(ULONG marks);
|
||||
void putDtype(const TypeClause* field, bool useSubType);
|
||||
void putType(const TypeClause* type, bool useSubType);
|
||||
void putLocalVariables(CompoundStmtNode* parameters, USHORT locals);
|
||||
|
@ -2274,7 +2274,6 @@ static RegisterNode<EraseNode> regEraseNode(blr_erase);
|
||||
|
||||
DmlNode* EraseNode::parse(thread_db* /*tdbb*/, MemoryPool& pool, CompilerScratch* csb, const UCHAR /*blrOp*/)
|
||||
{
|
||||
const ULONG blrOffset = csb->csb_blr_reader.getOffset();
|
||||
const USHORT n = csb->csb_blr_reader.getByte();
|
||||
|
||||
if (n >= csb->csb_rpt.getCount() || !(csb->csb_rpt[n].csb_flags & csb_used))
|
||||
@ -2283,9 +2282,8 @@ DmlNode* EraseNode::parse(thread_db* /*tdbb*/, MemoryPool& pool, CompilerScratch
|
||||
EraseNode* node = FB_NEW_POOL(pool) EraseNode(pool);
|
||||
node->stream = csb->csb_rpt[n].csb_stream;
|
||||
|
||||
ULONG marks;
|
||||
if (csb->csb_dbg_info && csb->csb_dbg_info->blrToMarks.get(blrOffset, marks))
|
||||
node->marks |= marks;
|
||||
if (csb->csb_blr_reader.peekByte() == blr_marks)
|
||||
node->marks |= PAR_marks(csb);
|
||||
|
||||
return node;
|
||||
}
|
||||
@ -2404,10 +2402,11 @@ void EraseNode::genBlr(DsqlCompilerScratch* dsqlScratch)
|
||||
}
|
||||
|
||||
dsqlScratch->appendUChar(blr_erase);
|
||||
if (marks)
|
||||
dsqlScratch->putDebugMarkers(marks);
|
||||
GEN_stuff_context(dsqlScratch, context);
|
||||
|
||||
if (marks)
|
||||
dsqlScratch->putBlrMarkers(marks);
|
||||
|
||||
if (statement)
|
||||
dsqlScratch->appendUChar(blr_end);
|
||||
|
||||
@ -4812,10 +4811,8 @@ DmlNode* ForNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb,
|
||||
{
|
||||
ForNode* node = FB_NEW_POOL(pool) ForNode(pool);
|
||||
|
||||
const ULONG blrOffset = csb->csb_blr_reader.getOffset();
|
||||
ULONG marks;
|
||||
if (csb->csb_dbg_info && csb->csb_dbg_info->blrToMarks.get(blrOffset, marks))
|
||||
node->forUpdate = (marks & StmtNode::MARK_FOR_UPDATE) != 0;
|
||||
if (csb->csb_blr_reader.peekByte() == blr_marks)
|
||||
node->forUpdate = (PAR_marks(csb) & StmtNode::MARK_FOR_UPDATE) != 0;
|
||||
|
||||
if (csb->csb_blr_reader.peekByte() == (UCHAR) blr_stall)
|
||||
node->stall = PAR_parse_stmt(tdbb, csb);
|
||||
@ -4932,7 +4929,7 @@ void ForNode::genBlr(DsqlCompilerScratch* dsqlScratch)
|
||||
dsqlScratch->appendUChar(blr_for);
|
||||
|
||||
if (forUpdate)
|
||||
dsqlScratch->putDebugMarkers(StmtNode::MARK_FOR_UPDATE);
|
||||
dsqlScratch->putBlrMarkers(StmtNode::MARK_FOR_UPDATE);
|
||||
|
||||
if (!statement || dsqlForceSingular)
|
||||
dsqlScratch->appendUChar(blr_singular);
|
||||
@ -5970,8 +5967,6 @@ static RegisterNode<ModifyNode> regModifyNode2(blr_modify2);
|
||||
DmlNode* ModifyNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp)
|
||||
{
|
||||
// Parse the original and new contexts.
|
||||
const ULONG blrOffset = csb->csb_blr_reader.getOffset();
|
||||
|
||||
USHORT context = (unsigned int) csb->csb_blr_reader.getByte();
|
||||
|
||||
if (context >= csb->csb_rpt.getCount() || !(csb->csb_rpt[context].csb_flags & csb_used))
|
||||
@ -6000,6 +5995,9 @@ DmlNode* ModifyNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* c
|
||||
node->orgStream = orgStream;
|
||||
node->newStream = newStream;
|
||||
|
||||
if (csb->csb_blr_reader.peekByte() == blr_marks)
|
||||
node->marks |= PAR_marks(csb);
|
||||
|
||||
AutoSetRestore<StmtNode*> autoCurrentDMLNode(&csb->csb_currentDMLNode, node);
|
||||
|
||||
node->statement = PAR_parse_stmt(tdbb, csb);
|
||||
@ -6007,10 +6005,6 @@ DmlNode* ModifyNode::parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* c
|
||||
if (blrOp == blr_modify2)
|
||||
node->statement2 = PAR_parse_stmt(tdbb, csb);
|
||||
|
||||
ULONG marks;
|
||||
if (csb->csb_dbg_info && csb->csb_dbg_info->blrToMarks.get(blrOffset, marks))
|
||||
node->marks |= marks;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -6239,8 +6233,6 @@ void ModifyNode::genBlr(DsqlCompilerScratch* dsqlScratch)
|
||||
const dsql_msg* message = dsqlGenDmlHeader(dsqlScratch, rse);
|
||||
|
||||
dsqlScratch->appendUChar(statement2 ? blr_modify2 : blr_modify);
|
||||
if (marks)
|
||||
dsqlScratch->putDebugMarkers(marks);
|
||||
|
||||
const dsql_ctx* context;
|
||||
|
||||
@ -6255,6 +6247,10 @@ void ModifyNode::genBlr(DsqlCompilerScratch* dsqlScratch)
|
||||
GEN_stuff_context(dsqlScratch, context);
|
||||
context = dsqlRelation->dsqlContext;
|
||||
GEN_stuff_context(dsqlScratch, context);
|
||||
|
||||
if (marks)
|
||||
dsqlScratch->putBlrMarkers(marks);
|
||||
|
||||
statement->genBlr(dsqlScratch);
|
||||
|
||||
if (statement2)
|
||||
@ -8913,7 +8909,7 @@ static const dsql_msg* dsqlGenDmlHeader(DsqlCompilerScratch* dsqlScratch, RseNod
|
||||
if (dsqlRse)
|
||||
{
|
||||
dsqlScratch->appendUChar(blr_for);
|
||||
dsqlScratch->putDebugMarkers(StmtNode::MARK_FOR_UPDATE);
|
||||
dsqlScratch->putBlrMarkers(StmtNode::MARK_FOR_UPDATE);
|
||||
GEN_expr(dsqlScratch, dsqlRse);
|
||||
}
|
||||
|
||||
|
@ -441,4 +441,6 @@
|
||||
#define blr_at_local (unsigned char) 0
|
||||
#define blr_at_zone (unsigned char) 1
|
||||
|
||||
#define blr_marks (unsigned char) 217 // mark some blr code with specific flags
|
||||
|
||||
#endif // FIREBIRD_IMPL_BLR_H
|
||||
|
@ -740,7 +740,6 @@
|
||||
#define fb_dbg_subproc 5
|
||||
#define fb_dbg_subfunc 6
|
||||
#define fb_dbg_map_curname 7
|
||||
#define fb_dbg_map_markers 8
|
||||
|
||||
// sub code for fb_dbg_map_argument
|
||||
#define fb_dbg_arg_input 0
|
||||
|
@ -225,28 +225,6 @@ void DBG_parse_debug_info(ULONG length, const UCHAR* data, DbgInfo& dbgInfo)
|
||||
break;
|
||||
}
|
||||
|
||||
case fb_dbg_map_markers:
|
||||
{
|
||||
if (data + 8 >= end)
|
||||
{
|
||||
bad_format = true;
|
||||
break;
|
||||
}
|
||||
|
||||
ULONG marks = *data++;
|
||||
marks |= *data++ << 8;
|
||||
marks |= *data++ << 16;
|
||||
marks |= *data++ << 24;
|
||||
|
||||
ULONG offset = *data++;
|
||||
offset |= *data++ << 8;
|
||||
offset |= *data++ << 16;
|
||||
offset |= *data++ << 24;
|
||||
|
||||
dbgInfo.blrToMarks.put(offset, marks);
|
||||
}
|
||||
break;
|
||||
|
||||
case fb_dbg_end:
|
||||
if (data != end)
|
||||
bad_format = true;
|
||||
|
@ -33,8 +33,7 @@
|
||||
// Also, it introduces some new tags.
|
||||
const UCHAR DBG_INFO_VERSION_1 = UCHAR(1);
|
||||
const UCHAR DBG_INFO_VERSION_2 = UCHAR(2);
|
||||
const UCHAR DBG_INFO_VERSION_3 = UCHAR(3); // blr offsets of "update" cursors and driven sub-statements
|
||||
const UCHAR CURRENT_DBG_INFO_VERSION = DBG_INFO_VERSION_3;
|
||||
const UCHAR CURRENT_DBG_INFO_VERSION = DBG_INFO_VERSION_2;
|
||||
|
||||
namespace Firebird {
|
||||
|
||||
@ -56,7 +55,6 @@ typedef Firebird::SortedArray<
|
||||
MapBlrToSrcItem> MapBlrToSrc;
|
||||
|
||||
typedef GenericMap<Pair<Right<USHORT, MetaName> > > MapVarIndexToName;
|
||||
typedef GenericMap<Pair<NonPooled<ULONG, ULONG> > > MapBlrToMarks;
|
||||
|
||||
struct ArgumentInfo
|
||||
{
|
||||
@ -95,8 +93,7 @@ struct DbgInfo : public PermanentStorage
|
||||
argInfoToName(p),
|
||||
curIndexToName(p),
|
||||
subFuncs(p),
|
||||
subProcs(p),
|
||||
blrToMarks(p)
|
||||
subProcs(p)
|
||||
{
|
||||
}
|
||||
|
||||
@ -129,8 +126,6 @@ struct DbgInfo : public PermanentStorage
|
||||
|
||||
subProcs.clear();
|
||||
}
|
||||
|
||||
blrToMarks.clear();
|
||||
}
|
||||
|
||||
MapBlrToSrc blrToSrc; // mapping between blr offsets and source text position
|
||||
@ -139,7 +134,6 @@ struct DbgInfo : public PermanentStorage
|
||||
MapVarIndexToName curIndexToName; // mapping between cursor index and name
|
||||
GenericMap<Pair<Left<MetaName, DbgInfo*> > > subFuncs; // sub functions
|
||||
GenericMap<Pair<Left<MetaName, DbgInfo*> > > subProcs; // sub procedures
|
||||
MapBlrToMarks blrToMarks; // blr offsets of marked verbs
|
||||
};
|
||||
|
||||
} // namespace Firebird
|
||||
|
@ -247,5 +247,6 @@ static const struct
|
||||
{"local_timestamp", byte_line},
|
||||
{"local_time", byte_line},
|
||||
{"at", verb_byte_verb},
|
||||
{"marks", byte_literal},
|
||||
{0, 0}
|
||||
};
|
||||
|
@ -683,6 +683,26 @@ CompoundStmtNode* PAR_make_list(thread_db* tdbb, StmtNodeStack& stack)
|
||||
}
|
||||
|
||||
|
||||
ULONG PAR_marks(Jrd::CompilerScratch* csb)
|
||||
{
|
||||
if (csb->csb_blr_reader.getByte() != blr_marks)
|
||||
PAR_syntax_error(csb, "blr_marks");
|
||||
|
||||
switch (csb->csb_blr_reader.getByte())
|
||||
{
|
||||
case 1:
|
||||
return csb->csb_blr_reader.getByte();
|
||||
|
||||
case 2:
|
||||
return csb->csb_blr_reader.getWord();
|
||||
|
||||
case 4:
|
||||
return csb->csb_blr_reader.getLong();
|
||||
}
|
||||
PAR_syntax_error(csb, "valid length for blr_marks value (1, 2, or 4)");
|
||||
return 0;
|
||||
}
|
||||
|
||||
CompilerScratch* PAR_parse(thread_db* tdbb, const UCHAR* blr, ULONG blr_length,
|
||||
bool internal_flag, ULONG dbginfo_length, const UCHAR* dbginfo)
|
||||
{
|
||||
@ -1627,6 +1647,7 @@ void PAR_syntax_error(CompilerScratch* csb, const TEXT* string)
|
||||
|
||||
csb->csb_blr_reader.seekBackward(1);
|
||||
|
||||
// BLR syntax error: expected @1 at offset @2, encountered @3
|
||||
PAR_error(csb, Arg::Gds(isc_syntaxerr) << Arg::Str(string) <<
|
||||
Arg::Num(csb->csb_blr_reader.getOffset()) <<
|
||||
Arg::Num(csb->csb_blr_reader.peekByte()));
|
||||
|
@ -61,6 +61,7 @@ SSHORT PAR_find_proc_field(const Jrd::jrd_prc*, const Firebird::MetaName&);
|
||||
Jrd::ValueExprNode* PAR_gen_field(Jrd::thread_db* tdbb, StreamType stream, USHORT id, bool byId = false);
|
||||
Jrd::ValueExprNode* PAR_make_field(Jrd::thread_db*, Jrd::CompilerScratch*, USHORT, const Firebird::MetaName&);
|
||||
Jrd::CompoundStmtNode* PAR_make_list(Jrd::thread_db*, Jrd::StmtNodeStack&);
|
||||
ULONG PAR_marks(Jrd::CompilerScratch*);
|
||||
Jrd::CompilerScratch* PAR_parse(Jrd::thread_db*, const UCHAR* blr, ULONG blr_length,
|
||||
bool internal_flag, ULONG = 0, const UCHAR* = NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user