4#ifdef AVM_INCLUDE_DEBUGGER
28std::vector<std::string> get_command()
36std::string str_replace(
const std::string& s,
const std::string& search,
const std::string& replace)
40 while ((pos = res.find(search, pos)) != std::string::npos) {
41 res.replace(pos, search.length(), replace);
42 pos += replace.length();
47std::string to_binary(uint64_t n,
bool leading_zeroes =
true)
50 for (
int i = 0; i < 64; ++i) {
54 if (!leading_zeroes) {
55 size_t first_one =
result.find(
'1');
56 if (first_one != std::string::npos) {
75 std::cout <<
" /testrelation <relation_name> [subrelation_name_or_number] - test relation" <<
std::endl;
88 auto command = get_command();
89 if (command.empty()) {
92 if (command[0] ==
"'") {
94 }
else if (command[0] ==
",") {
100 }
else if (command[0].starts_with(
"@")) {
101 row =
static_cast<uint32_t
>(
std::stoi(command[0].substr(1)));
102 }
else if (command[0] ==
"exit" || command[0] ==
"e" || command[0] ==
"q") {
104 }
else if (command[0] ==
"/set" || command[0] ==
"/s") {
105 if (command.size() != 3) {
110 }
else if (command[0] ==
"/prefix" || command[0] ==
"/p") {
111 if (command.size() != 2) {
116 }
else if (command[0] ==
"/noprefix" || command[0] ==
"/np") {
118 }
else if (command[0] ==
"/testrelation" || command[0] ==
"/tr") {
119 if (command.size() != 2 && command.size() != 3) {
120 std::cout <<
"Usage: /testrelation <relation_name> [subrelation_name_or_number]" <<
std::endl;
124 }
else if (command[0].starts_with(
".")) {
126 command[0].erase(0, 1);
138 std::string joined_regex;
139 for (
const auto& str : regexes) {
140 joined_regex +=
prefix + str_replace(str,
"'",
"_shift") +
"|";
142 joined_regex.pop_back();
145 re.assign(joined_regex);
155 if (val ==
FF(
static_cast<uint64_t
>(val))) {
156 uint64_t n =
static_cast<uint64_t
>(val);
157 std::cout <<
" (" << n <<
", " << to_binary(n,
false) <<
"b)";
170 std::string final_name =
prefix + column_name;
187 bb::constexpr_for<0, std::tuple_size_v<typename AvmFlavor::MainRelations>, 1>([&]<
size_t i>() {
190 if (Relation::NAME != relation_name) {
198 for (
size_t j = 0; j <
result.size(); ++j) {
199 if (!
result[j].is_zero() &&
200 (!subrelation_name || Relation::get_subrelation_label(j) == *subrelation_name)) {
204 Relation::get_subrelation_label(j),
216 }
else if (!failed) {
217 std::cout <<
"Relation " << relation_name <<
" ("
218 << (subrelation_name.has_value() ? *subrelation_name :
"all subrelations") <<
")"
ArrayOfValues< FF, RelationImpl::SUBRELATION_PARTIAL_LENGTHS > SumcheckArrayOfValuesOverSubrelations
void run(uint32_t starting_row=0)
tracegen::TraceContainer & trace
void print_columns(const std::vector< std::string > ®ex)
void test_relation(const std::string &relation_name, std::optional< std::string > subrelation_name)
void set_column(const std::string &column_name, const std::string &value)
const FF & get_column_or_shift(ColumnAndShifts col, uint32_t row) const
void set(Column col, uint32_t row, const FF &value, bool use_atomic_limbs=false)
std::string format(Args... args)
AvmFullRow get_full_row(const TraceContainer &trace, uint32_t row)
const std::vector< std::string > & COLUMN_NAMES
std::string field_to_string(const FF &ff)
std::vector< std::string > split_and_trim(const std::string &str, char delimiter)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept