|
14 | 14 | *
|
15 | 15 | * History
|
16 | 16 | *
|
| 17 | + * johnkenn 31-aug-2023 - Debug text tokens |
17 | 18 | * bengsig 7-aug-2023 - rwlstatsincr better documented
|
18 | 19 | * bengsig 19-jul-2023 - rwlstr2var: dbl/int NULL if string empty or only space
|
19 | 20 | * bengsig 30-jun-2023 - flushevery flushes count=0 for statisticsonly procedures
|
@@ -4487,4 +4488,116 @@ void rwlpfeng(rwl_main *rwm
|
4487 | 4488 | return;
|
4488 | 4489 | }
|
4489 | 4490 |
|
| 4491 | + |
| 4492 | + |
| 4493 | + |
| 4494 | +ub4 rwldebugconv(rwl_main * rwm |
| 4495 | +, text * arg) |
| 4496 | +{ |
| 4497 | + // Mapping strcut for for the debug names |
| 4498 | + struct rwl_debugmap |
| 4499 | + { |
| 4500 | + text * name; |
| 4501 | + ub4 val; |
| 4502 | + }; |
| 4503 | + |
| 4504 | + // Mapping the names of the debug codes to their values |
| 4505 | + static const struct rwl_debugmap debugmappings[] = { |
| 4506 | + {(text *)"exec", RWL_DEBUG_EXECUTE } |
| 4507 | + , {(text *)"var", RWL_DEBUG_VARIABLE} |
| 4508 | + , {(text *)"eval", RWL_THR_DEVAL} |
| 4509 | + , {(text *)"bison", RWL_DEBUG_YYDEBUG} |
| 4510 | + , {(text *)"pvinternal", RWL_DEBUG_PVINTERN} |
| 4511 | + , {(text *)"bind", RWL_DEBUG_BINDEF} |
| 4512 | + , {(text *)"define", RWL_DEBUG_BINDEF} |
| 4513 | + , {(text *)"misc", RWL_DEBUG_MISC} |
| 4514 | + , {(text *)"sql", RWL_THR_DSQL} |
| 4515 | + }; |
| 4516 | + |
| 4517 | + ub4 map_len = (ub4)(sizeof debugmappings / sizeof debugmappings[0]); |
| 4518 | + ub4 found_flag = 0; |
| 4519 | + ub4 bitval = 0; |
| 4520 | + text *token; |
| 4521 | + // First debug code |
| 4522 | + token = (text *) rwlstrtok(arg, ","); |
| 4523 | + |
| 4524 | + |
| 4525 | + while (token != NULL) |
| 4526 | + { |
| 4527 | + // Get the length of the token and convert token to uppercase |
| 4528 | + size_t token_len = rwlstrlen((char *)token); |
| 4529 | + for (ub4 index = 0; index < token_len; index++) |
| 4530 | + { |
| 4531 | + if (isupper(token[index])) |
| 4532 | + { |
| 4533 | + token[index] = (text)tolower(token[index]); |
| 4534 | + } |
| 4535 | + } |
| 4536 | + |
| 4537 | + // Check whether or not the debug code is a hex value |
| 4538 | + // No 0x prefex |
| 4539 | + if(rwlstrncmp("0x", token, 2) != 0) |
| 4540 | + { |
| 4541 | + |
| 4542 | + found_flag = 0; |
| 4543 | + |
| 4544 | + // Not a hex number, check for mapping |
| 4545 | + for(ub4 index = 0; index < map_len; index++) |
| 4546 | + { |
| 4547 | + if(rwlstrcmp(token, debugmappings[index].name) == 0 && found_flag == 0) |
| 4548 | + { |
| 4549 | + ub4 debug_value = debugmappings[index].val; |
| 4550 | + bitval |= debug_value; |
| 4551 | + found_flag = 1; |
| 4552 | + break; |
| 4553 | + } |
| 4554 | + } |
| 4555 | + // The debug token is a not prefixed with "0x" but is hex numeric, e.g. "1" |
| 4556 | + if(isxdigit((char)token[0]) && found_flag == 0) |
| 4557 | + { |
| 4558 | + // Verify that the whole token is hex numeric |
| 4559 | + ub4 token_valid = 1; |
| 4560 | + for (ub4 index = 0; index < token_len; index++) |
| 4561 | + { |
| 4562 | + // If a character in the token is not hex numeric |
| 4563 | + // raise a warning and dont process token |
| 4564 | + if (!isxdigit((char)token[index])) |
| 4565 | + { |
| 4566 | + token_valid = 0; |
| 4567 | + break; |
| 4568 | + } |
| 4569 | + } |
| 4570 | + if (token_valid != 0) |
| 4571 | + { |
| 4572 | + bitval |= (ub4) strtol((char*)token,0,16); |
| 4573 | + found_flag = 1; |
| 4574 | + } |
| 4575 | + } |
| 4576 | + if (found_flag != 1) |
| 4577 | + { |
| 4578 | + rwlerror(rwm, RWL_ERROR_INVALID_DEBUG_OPTION, token); |
| 4579 | + } |
| 4580 | + } |
| 4581 | + // Has the 0x prefix |
| 4582 | + else |
| 4583 | + { |
| 4584 | + ub4 token_valid = 1; |
| 4585 | + for (ub4 index = 2; index < token_len; index++) |
| 4586 | + { |
| 4587 | + if(!isxdigit(token[index])) |
| 4588 | + { |
| 4589 | + rwlerror(rwm, RWL_ERROR_INVALID_DEBUG_OPTION, token); |
| 4590 | + token_valid = 0; |
| 4591 | + break; |
| 4592 | + } |
| 4593 | + } |
| 4594 | + if (token_valid) bitval |= (ub4) strtol((char *)token,0,16); |
| 4595 | + } |
| 4596 | + token = (text *) rwlstrtok(NULL, ","); |
| 4597 | + } |
| 4598 | + return bitval&(RWL_DEBUG_MAIN|RWL_DEBUG_THREAD); |
| 4599 | +} |
| 4600 | + |
| 4601 | + |
| 4602 | + |
4490 | 4603 | rwlcomp(rwlmisc_c, RWL_GCCFLAGS)
|
0 commit comments