diff --git a/src/dsql/BlrDebugWriter.cpp b/src/dsql/BlrDebugWriter.cpp index f20040fb92..fdb810c440 100644 --- a/src/dsql/BlrDebugWriter.cpp +++ b/src/dsql/BlrDebugWriter.cpp @@ -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); diff --git a/src/dsql/BlrDebugWriter.h b/src/dsql/BlrDebugWriter.h index 41980861ba..ec81544e50 100644 --- a/src/dsql/BlrDebugWriter.h +++ b/src/dsql/BlrDebugWriter.h @@ -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; } diff --git a/src/dsql/DsqlCompilerScratch.cpp b/src/dsql/DsqlCompilerScratch.cpp index aa5bd71736..a84970b0b8 100644 --- a/src/dsql/DsqlCompilerScratch.cpp +++ b/src/dsql/DsqlCompilerScratch.cpp @@ -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) diff --git a/src/dsql/DsqlCompilerScratch.h b/src/dsql/DsqlCompilerScratch.h index e54cea0ff1..21b93d731a 100644 --- a/src/dsql/DsqlCompilerScratch.h +++ b/src/dsql/DsqlCompilerScratch.h @@ -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); diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index 61de239c7c..5a60da1189 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -2274,7 +2274,6 @@ static RegisterNode 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 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 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); } diff --git a/src/include/firebird/impl/blr.h b/src/include/firebird/impl/blr.h index 70a41ac159..b75354c8c6 100644 --- a/src/include/firebird/impl/blr.h +++ b/src/include/firebird/impl/blr.h @@ -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 diff --git a/src/include/firebird/impl/consts_pub.h b/src/include/firebird/impl/consts_pub.h index 74be2b75bb..9ba14d70f9 100644 --- a/src/include/firebird/impl/consts_pub.h +++ b/src/include/firebird/impl/consts_pub.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 diff --git a/src/jrd/DebugInterface.cpp b/src/jrd/DebugInterface.cpp index d0e528e8b1..79de9e8147 100644 --- a/src/jrd/DebugInterface.cpp +++ b/src/jrd/DebugInterface.cpp @@ -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; diff --git a/src/jrd/DebugInterface.h b/src/jrd/DebugInterface.h index b7f3836e5c..f7cd7253f9 100644 --- a/src/jrd/DebugInterface.h +++ b/src/jrd/DebugInterface.h @@ -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 > > MapVarIndexToName; -typedef GenericMap > > 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 > > subFuncs; // sub functions GenericMap > > subProcs; // sub procedures - MapBlrToMarks blrToMarks; // blr offsets of marked verbs }; } // namespace Firebird diff --git a/src/jrd/blp.h b/src/jrd/blp.h index da41ec60aa..a6e41a55b0 100644 --- a/src/jrd/blp.h +++ b/src/jrd/blp.h @@ -247,5 +247,6 @@ static const struct {"local_timestamp", byte_line}, {"local_time", byte_line}, {"at", verb_byte_verb}, + {"marks", byte_literal}, {0, 0} }; diff --git a/src/jrd/par.cpp b/src/jrd/par.cpp index 951cdeec40..99b1027ae6 100644 --- a/src/jrd/par.cpp +++ b/src/jrd/par.cpp @@ -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())); diff --git a/src/jrd/par_proto.h b/src/jrd/par_proto.h index 487f8dfe8b..13a5c8594c 100644 --- a/src/jrd/par_proto.h +++ b/src/jrd/par_proto.h @@ -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);