Skip to content

Commit b9e8ee0

Browse files
committed
Merge branch 'debug-text' of github.com:oracle/rwloadsim into dev310
2 parents b227ef0 + 9c97a04 commit b9e8ee0

File tree

15 files changed

+237
-54
lines changed

15 files changed

+237
-54
lines changed

admin/.vim/syntax/rwl.vim

+2-4
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,8 @@ syn match rwlDirective '\$useroption:[a-zA-Z][-0-9a-zA-Z_]*'
154154
syn match rwlDirective '\$useroption:[a-zA-Z][-0-9a-zA-Z_]*:"[^"]*"'
155155
syn match rwlDirective '\$userswitch:[a-zA-Z][-0-9a-zA-Z_]*'
156156
syn match rwlDirective '\$userswitch:[a-zA-Z][-0-9a-zA-Z_]*:"[^"]*"'
157-
syn match rwlDirective '\$debugon:[0-9a-fA-F][0-9a-fA-F]*'
158-
syn match rwlDirective '\$debugoff:[0-9a-fA-F][0-9a-fA-F]*'
159-
syn match rwlDirective '\$debugon:0[xX][0-9a-fA-F][0-9a-fA-F]*'
160-
syn match rwlDirective '\$debugoff:0[xX][0-9a-fA-F][0-9a-fA-F]*'
157+
syn match rwlDirective '\$debugon:[0-9A-Za-z][0-9a-zA-Z,]*'
158+
syn match rwlDirective '\$debugoff:[0-9A-Za-z][0-9a-zA-Z,]*'
161159
syn match rwlDirective '\$include:"[^"<>]*"'
162160
syn match rwlDirective '\$include:<[^"<>]*>'
163161
syn match rwlDirective '\$sqllogging:file:"[^"<>]*"'

man/man1rwl/directive.1rwl

+5-5
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,17 @@ Lowercase conversion is controlled via the $lowercase directive as explained abo
173173
.RE
174174
.PP
175175
.PP
176-
.B $debugon:<hexdigits>
176+
.B $debugon:<debuglist>
177177
.br
178-
.B $debugoff:<hexdigits>
178+
.B $debugoff:<debuglist>
179179
.RS 4
180180
The debugon directive has the same effect as using the
181181
.B -D
182182
option to the rwloadsim executable;
183183
debugoff reverses it.
184-
Both of these take a string of hexadecimal digits as argument;
185-
0x or 0X in front of them is optional.
186-
See the rwloadsim(1rwl) page for description of some of the bit values.
184+
The argument is a debug option (or a comma separated list without spaces);
185+
each option either a hexadecimal value (potentially prefixed by 0x or 0X)
186+
or one of the text strings shown at the rwloadsim(1rwl) page.
187187
.RE
188188
.P
189189
.B $mute:<integer>

man/man1rwl/rwloadsim.1rwl

+14-12
Original file line numberDiff line numberDiff line change
@@ -130,32 +130,34 @@ The same for a double variable.
130130
.PP
131131
.B -D --debug X
132132
.RS 4
133-
Set debug bits, mostly used for program debugging;
134-
the argument is a sequence of hexadecimal digits optionally preceded by 0x or 0X.
135-
You need to read the source code to get all information about debug bits,
136-
the following lists those that are potentially useful to ordinary users:
133+
Set debug bits, mostly used for program debugging.
134+
You need to read the source code to get all information about debug bits.
135+
The argument is a debug option (or a comma separated list without spaces); each option
136+
either a hexadecimal value (potentially prefixed by 0x or 0X) or one of the
137+
text strings shown in the following table:
137138
.TP 8
138-
.B 0x004
139+
.B 0x004 bison
139140
Set the debug flag in the bison(1) parser.
140141
.TP
141-
.B 0x010
142+
.B 0x010 var
142143
Debug handling of variables such as declarations.
143144
.TP
144-
.B 0x020
145+
.B 0x020 exec
145146
Debug execution of generated code; this does not include code executed directly in main.
146147
.TP
147-
.B 0x040
148+
.B 0x040 pvinternal
148149
The \fBprintvar all\fR will also print all internally generated variables.
149150
.TP
150-
.B 0x100
151+
.B 0x100 eval
151152
Debug evaluation of expressions.
152153
.TP
153-
.B 0x200
154+
.B 0x200 sql
154155
Debug execution of sql and other database operations.
155156
.TP
156-
.B 0x800
157+
.B 0x800 bind define
157158
Output information about all binds and defines before first execute
158-
of some SQL.
159+
of some SQL; both debug texts have the same impact as there is no way to ask
160+
for debug of bind or define separately.
159161
This is primarily useful if you are using implicit binds and/or defines.
160162
.TP 0
161163
Note that some debug may cause extensive output and that the actual debug bits may change between versions.

src/rwl.h

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* History
1515
*
1616
* bengsig 6-sep-2023 - sql logging
17+
* johnkenn 31-aug-2023 - Debugconv function header added
1718
* bengsig 10-aug-2023 - session pool timeout then action
1819
* bengsig 7-aug-2023 - rwlstatsincr better documented
1920
* bengsig 17-jul-2023 - rwlrem doing reminder per D. Knuth
@@ -316,6 +317,7 @@ struct rwl_location
316317
ub4 inpos; // position on line
317318
};
318319

320+
319321
// types
320322
enum rwl_type
321323
{
@@ -749,6 +751,7 @@ struct rwl_pathlist
749751
* were global variables, but we do everything reentrant
750752
* */
751753

754+
752755
struct rwl_main
753756
{
754757
ub4 maxcode; /* # array elements in code array */
@@ -1786,6 +1789,7 @@ extern void rwlfreelob(rwl_xeqenv *, rwl_location *, OCILobLocator *);
17861789
extern void rwlwritelob(rwl_xeqenv *, OCILobLocator *, rwl_cinfo *, rwl_value *, rwl_location *, text *);
17871790
extern void rwlreadlob(rwl_xeqenv *, OCILobLocator *, rwl_cinfo *, rwl_value *, rwl_location *, text *);
17881791
extern void rwldummyonbad(rwl_xeqenv *, text *); // Use dummy database if default is bad
1792+
extern ub4 rwldebugconv(rwl_main *,text *);
17891793

17901794
extern void rwlbuilddb(rwl_main *);
17911795
#define RWL_DEFAULT_DBNAME (text *)"default$database" // used with -l option

src/rwlerror.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
*
1212
* History
1313
*
14+
<<<<<<< HEAD
1415
* bengsig 6-sep-2023 - sql logging
1516
* bengsig 10-aug-2023 - session pool timeout then action
1617
* bengsig 26-jul-2023 - Add run/threads error
18+
=======
19+
* johnkenn 31-aug-2023 - debug text warning
20+
>>>>>>> 9c97a043dcdb3961635d95dcce63745e28be418a
1721
* bengsig 15-may-2023 - statisticsonly
1822
* bengsig 3-feb-2023 - No OCI_ATTR_TRANSACTION_IN_PROGRESS in 11.2
1923
* bengsig 26-jan-2023 - RWL-046 changed; removed some punctuation
@@ -1680,8 +1684,10 @@ RWLEDESC("The statisticsonly attribute can only be used with procdures that do n
16801684
"activity from the procedure or remove the statisticsonly attribute")
16811685

16821686
#define RWL_ERROR_INVALID_DEBUG_OPTION 303
1683-
RWLERROR("jack does this", RWL_ERROR_PARSE)
1684-
RWLEDESC("jack does this")
1687+
RWLERROR("the debug options '%s' could not be resolved", RWL_ERROR_NOFILE)
1688+
RWLEDESC("debug arugments must be a comma separated list of debug options without\n"
1689+
"spaces; each option either a hexadeciman number (potentially prefixed by\n"
1690+
"0x or 0X) or one of the text values exec, var, eval, bison, or sql\n")
16851691

16861692
#define RWL_ERROR_COMMAND_NOT_LOCAL 304
16871693
RWLERROR("%s cannot be used inside procedure or function", RWL_ERROR_PARSE)

src/rwllexer.l

+10-24
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* History
1313
*
1414
* bengsig 6-sep-2023 - sql logging
15+
* johnkenn 31-aug-2023 - Changed debugon and debug off for debug Text
1516
* bengsig 29-aug-2023 - lobprefetch
1617
* bengsig 10-jul-2023 - ceil, trunc, floor functions
1718
* bengsig 12-jun-2023 - Make rwm a variable in scanners
@@ -1389,22 +1390,23 @@
13891390
rwlcheckdformat(rwm);
13901391
}
13911392

1392-
\$debugon:[0-9a-fA-F][0-9a-fA-F]* if (!rwm->ifdirbit) {
1393-
ub4 newdebug = (ub4) rwlhex2ub8(yytext+9, 2*sizeof(ub4));
1394-
bis(rwm->mflags, newdebug&(RWL_DEBUG_MAIN|RWL_DEBUG_THREAD));
1393+
\$debugon:[0-9a-zA-Z][0-9a-zA-Z,]* if (!rwm->ifdirbit) {
1394+
ub4 newdebug = rwldebugconv(rwm, (text *)yytext+9);
1395+
bis(rwm->mflags, newdebug);
13951396
if (rwm->mxq)
1396-
bis(rwm->mxq->tflags, newdebug&(RWL_DEBUG_MAIN|RWL_DEBUG_THREAD));
1397+
bis(rwm->mxq->tflags, newdebug);
13971398
if (bit(rwm->mflags, RWL_DEBUG_ALLOWHACK))
13981399
{
13991400
rwlerror(rwm, RWL_ERROR_HACK_ALLOWED);
14001401
}
14011402
}
14021403

1403-
\$debugoff:[0-9a-fA-F][0-9a-fA-F]* if (!rwm->ifdirbit) {
1404-
ub4 newdebug = (ub4) rwlhex2ub8(yytext+10, 2*sizeof(ub4));
1405-
bic(rwm->mflags, newdebug&(RWL_DEBUG_MAIN|RWL_DEBUG_THREAD));
1404+
\$debugoff:[0-9a-zA-Z][0-9a-zA-Z,]* if (!rwm->ifdirbit) {
1405+
ub4 newdebug = rwldebugconv(rwm, (text *)yytext+10);
1406+
// ub4 newdebug = (ub4) rwlhex2ub8(yytext+10, 2*sizeof(ub4));
1407+
bic(rwm->mflags, newdebug);
14061408
if (rwm->mxq)
1407-
bic(rwm->mxq->tflags, newdebug&(RWL_DEBUG_MAIN|RWL_DEBUG_THREAD));
1409+
bic(rwm->mxq->tflags, newdebug);
14081410
}
14091411

14101412
\$randseed:[0-9a-fA-F][0-9a-fA-F]* if (!rwm->ifdirbit) {
@@ -1422,23 +1424,7 @@
14221424
rwm->mxq->xsubi[2]=0;
14231425
}
14241426

1425-
\$debugon:0[xX][0-9a-fA-F][0-9a-fA-F]* if (!rwm->ifdirbit) {
1426-
ub4 newdebug = (ub4) rwlhex2ub8(yytext+11, 2*sizeof(ub4));
1427-
bis(rwm->mflags, newdebug&(RWL_DEBUG_MAIN|RWL_DEBUG_THREAD));
1428-
if (rwm->mxq)
1429-
bis(rwm->mxq->tflags, newdebug&(RWL_DEBUG_MAIN|RWL_DEBUG_THREAD));
1430-
if (bit(rwm->mflags, RWL_DEBUG_ALLOWHACK))
1431-
{
1432-
rwlerror(rwm, RWL_ERROR_HACK_ALLOWED);
1433-
}
1434-
}
14351427

1436-
\$debugoff:0[xX][0-9a-fA-F][0-9a-fA-F]* if (!rwm->ifdirbit) {
1437-
ub4 newdebug = (ub4) rwlhex2ub8(yytext+12, 2*sizeof(ub4));
1438-
bic(rwm->mflags, newdebug&(RWL_DEBUG_MAIN|RWL_DEBUG_THREAD));
1439-
if (rwm->mxq)
1440-
bic(rwm->mxq->tflags, newdebug&(RWL_DEBUG_MAIN|RWL_DEBUG_THREAD));
1441-
}
14421428

14431429
\$randseed:0[xX][0-9a-fA-F][0-9a-fA-F]* if (!rwm->ifdirbit) {
14441430
rwm->mxq->xsubi[0] = (unsigned short)

src/rwlmain.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*
1414
* bengsig 6-sep-2023 - sql logging
1515
* bengsig 25-jul-2023 - -l option sets RWL_DB_DEFAULT
16+
* johnkenn 26-jun-2023 - Alias for 0x20 debug option
1617
* bengsig 21-jun-2023 - Preparing for 3.1
1718
* bengsig 17-apr-2023 - Engineering notation output
1819
* bengsig 1-mar-2023 - Optimize snprintf [id]format
@@ -242,6 +243,8 @@ struct option rwllongoptions[] = {
242243
ub4 rwloptcount = sizeof(rwllongoptions)/sizeof(struct option);
243244

244245

246+
247+
245248
sb4 main(sb4 main_ac, char **main_av)
246249
{
247250
rwl_main *rwm;
@@ -329,10 +332,10 @@ sb4 main(sb4 main_ac, char **main_av)
329332
switch(opt)
330333
{
331334
case 'D': /* add debug bit */
332-
rwm->mflags |= (ub4) strtol(optarg,0,16) & (RWL_DEBUG_MAIN|RWL_DEBUG_THREAD);
333-
if (bit(rwm->mflags,RWL_DEBUG_YYDEBUG))
334-
rwlydebug = 1;
335-
break;
335+
rwm->mflags |= rwldebugconv(rwm, (text *)optarg);
336+
if (bit(rwm->mflags,RWL_DEBUG_YYDEBUG))
337+
rwlydebug = 1;
338+
break;
336339

337340
case '_': // --pretend-gen-banner
338341
#ifndef RWL_GEN_EXEC

src/rwlmisc.c

+113
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*
1515
* History
1616
*
17+
* johnkenn 31-aug-2023 - Debug text tokens
1718
* bengsig 7-aug-2023 - rwlstatsincr better documented
1819
* bengsig 19-jul-2023 - rwlstr2var: dbl/int NULL if string empty or only space
1920
* bengsig 30-jun-2023 - flushevery flushes count=0 for statisticsonly procedures
@@ -4487,4 +4488,116 @@ void rwlpfeng(rwl_main *rwm
44874488
return;
44884489
}
44894490

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+
44904603
rwlcomp(rwlmisc_c, RWL_GCCFLAGS)

test/238.rwl

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
integer debug238 := 0; $userswitch:debug238
44

55
$if debug238 $then
6-
$debugon:200 # used to inspect that return causes cursor cancel
6+
$debugon:sql # used to inspect that return causes cursor cancel
77
$endif
88

99
$include:"testuserinfo.rwl"

test/348-1.rwl

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
$debugon:0x20
2+
$include:"testuserinfo.rwl"
3+
$include:"testdefault.rwl"
4+
$debugoff:sql
5+
integer one:=1; # operator precedence
6+
integer two:=2;
7+
8+
printline one>0 and two*3>5;
9+
printline (one or two*one>5) + (one-1 and two);
10+
11+
procedure hello()
12+
printline one>0 and two*3>5;
13+
printline (one or two*one>5) + (one-1 and two);
14+
end;
15+
hello();
16+
printline "\n\n";
17+
$debugoff:exec,0x800

test/348-2.rwl

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
printline "DEBUG CODE EVAL\n";
2+
$debugon:eval
3+
integer three=1; # operator precedence
4+
integer four:=2;
5+
6+
printline three>0 and four*3>5;
7+
printline (three or four*three>5) + (three-1 and four);
8+
printline "\n\n";
9+
$debugoff:eval

0 commit comments

Comments
 (0)