Merge remote-tracking branch 'origin/topic/vern/macro-descriptions'

* origin/topic/vern/macro-descriptions:
  Add missing include for <vector>
  Extended ZAM validation to include macros
This commit is contained in:
Tim Wojtulewicz 2025-01-09 13:47:29 -07:00
commit a919226b24
7 changed files with 29 additions and 9 deletions

View file

@ -1,3 +1,9 @@
7.2.0-dev.57 | 2025-01-09 13:47:29 -0700
* Add missing include for <vector> (Tim Wojtulewicz, Corelight)
* Extended ZAM validation to include macros (Vern Paxson, Corelight)
7.2.0-dev.54 | 2025-01-09 12:09:07 -0700 7.2.0-dev.54 | 2025-01-09 12:09:07 -0700
* factoring of some ZAM header files for better modularity (Vern Paxson, Corelight) * factoring of some ZAM header files for better modularity (Vern Paxson, Corelight)

View file

@ -1 +1 @@
7.2.0-dev.54 7.2.0-dev.57

@ -1 +1 @@
Subproject commit 517bf6a5c8dc6afdee2b854d575dbdd15736afc5 Subproject commit e780bb6c17f55ef5a4a739c14f49b3f454991dea

View file

@ -13,9 +13,11 @@ using std::string;
namespace zeek::detail { namespace zeek::detail {
std::unordered_map<ZOp, ZAMInstDesc> zam_inst_desc = { std::unordered_map<ZOp, ZAMInstDesc> zam_inst_desc = {
#include "ZAM-OpDesc.h"
};
#include "ZAM-Desc.h" std::vector<std::pair<string, string>> zam_macro_desc = {
#include "ZAM-MacroDesc.h"
}; };
// While the following has commonalities that could be factored out, // While the following has commonalities that could be factored out,
@ -107,7 +109,15 @@ void validate_ZAM_insts() {
for ( auto& zid : zam_inst_desc ) for ( auto& zid : zam_inst_desc )
analyze_ZAM_inst(ZOP_name(zid.first), zid.second); analyze_ZAM_inst(ZOP_name(zid.first), zid.second);
printf("%d valid, %d tested, %d skipped\n", num_valid, num_tested, num_skipped); int num_valid_macros = 0;
for ( auto& md : zam_macro_desc ) {
if ( std::regex_search(md.second, std::regex("\\$[0-9$]")) )
reporter->InternalError("macro %s contains dollar parameter: %s", md.first.c_str(), md.second.c_str());
++num_valid_macros;
}
printf("%d valid ops, %d tested, %d skipped, %d valid macros\n", num_valid, num_tested, num_skipped,
num_valid_macros);
} }
} // namespace zeek::detail } // namespace zeek::detail

View file

@ -6,6 +6,7 @@
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <vector>
namespace zeek::detail { namespace zeek::detail {
@ -72,6 +73,10 @@ struct ZAMInstDesc {
// Provides access to the validation description of each operation. // Provides access to the validation description of each operation.
extern std::unordered_map<ZOp, ZAMInstDesc> zam_inst_desc; extern std::unordered_map<ZOp, ZAMInstDesc> zam_inst_desc;
// Same, for the associated macros. First field is macro name, second is
// definition (including "#define" etc.).
extern std::vector<std::pair<std::string, std::string>> zam_macro_desc;
// Maps an operand to its flavor. // Maps an operand to its flavor.
extern ZAMOp1Flavor op1_flavor[]; extern ZAMOp1Flavor op1_flavor[];

View file

@ -1,2 +0,0 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
1255 valid, 1908 tested, 440 skipped

View file

@ -1,4 +1,5 @@
# @TEST-DOC: ZAM maintenance script for validating synthesized operations. # @TEST-DOC: ZAM maintenance script for validating synthesized operations.
# #
# @TEST-EXEC: zeek -b -O validate-ZAM %INPUT >output # We don't check the output, since it varies for benign reasons as ZAM
# @TEST-EXEC: btest-diff output # operations are modified. What matters is the exit status of success.
# @TEST-EXEC: zeek -b -O validate-ZAM %INPUT