Browse Source
backport of dbug extensions from 6.0:
backport of dbug extensions from 6.0:
function/ syntax glob(7) wildcards unit testspull/374/head
29 changed files with 1317 additions and 789 deletions
-
2.bzrignore
-
1client/mysqltest.cc
-
3dbug/.cvsignore
-
15dbug/Makefile.am
-
876dbug/dbug.c
-
4dbug/dbug_add_tags.pl
-
15dbug/doinstall.sh
-
64dbug/install.sh
-
30dbug/mklintlib.sh
-
4dbug/qmake.cmd
-
26dbug/remove_function_from_trace.pl
-
496dbug/tests-t.pl
-
87dbug/tests.c
-
54dbug/user.r
-
139dbug/vargs.h
-
187include/my_dbug.h
-
4include/my_global.h
-
1include/my_pthread.h
-
2libmysql/libmysql.c
-
9mysys/my_thr_init.c
-
2sql-common/client.c
-
8sql/debug_sync.cc
-
5sql/field.cc
-
6sql/ha_ndbcluster.cc
-
22sql/ha_ndbcluster_binlog.cc
-
30sql/log_event.cc
-
4sql/slave.cc
-
8sql/sql_select.cc
-
2sql/sql_table.cc
@ -1,3 +0,0 @@ |
|||
.deps |
|||
Makefile |
|||
Makefile.in |
876
dbug/dbug.c
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,15 +0,0 @@ |
|||
|
|||
# Warning - first line left blank for sh/csh/ksh compatibility. Do not |
|||
# remove it. fnf@Unisoft |
|||
|
|||
# doinstall.sh --- figure out environment and do recursive make with |
|||
# appropriate pathnames. Works under SV or BSD. |
|||
|
|||
if [ -r /usr/include/search.h ] |
|||
then |
|||
# System V |
|||
$* LLIB=/usr/lib |
|||
else |
|||
# 4.2 BSD |
|||
$* LLIB=/usr/lib/lint |
|||
fi |
@ -1,64 +0,0 @@ |
|||
|
|||
# WARNING -- first line intentionally left blank for sh/csh/ksh |
|||
# compatibility. Do not remove it! FNF, UniSoft Systems. |
|||
# |
|||
# Usage is: |
|||
# install <from> <to> |
|||
# |
|||
# The file <to> is replaced with the file <from>, after first |
|||
# moving <to> to a backup file. The backup file name is created |
|||
# by prepending the filename (after removing any leading pathname |
|||
# components) with "OLD". |
|||
# |
|||
# This script is currently not real robust in the face of signals |
|||
# or permission problems. It also does not do (by intention) all |
|||
# the things that the System V or BSD install scripts try to do |
|||
# |
|||
|
|||
if [ $# -ne 2 ] |
|||
then |
|||
echo "usage: $0 <from> <to>" |
|||
exit 1 |
|||
fi |
|||
|
|||
# Now extract the dirname and basename components. Unfortunately, BSD does |
|||
# not have dirname, so we do it the hard way. |
|||
|
|||
fd=`expr $1'/' : '\(/\)[^/]*/$' \| $1'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \| .` |
|||
ff=`basename $1` |
|||
td=`expr $2'/' : '\(/\)[^/]*/$' \| $2'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \| .` |
|||
tf=`basename $2` |
|||
|
|||
# Now test to make sure that they are not the same files. |
|||
|
|||
if [ $fd/$ff = $td/$tf ] |
|||
then |
|||
echo "install: input and output are same files" |
|||
exit 2 |
|||
fi |
|||
|
|||
# Save a copy of the "to" file as a backup. |
|||
|
|||
if test -f $td/$tf |
|||
then |
|||
if test -f $td/OLD$tf |
|||
then |
|||
rm -f $td/OLD$tf |
|||
fi |
|||
mv $td/$tf $td/OLD$tf |
|||
if [ $? != 0 ] |
|||
then |
|||
exit 3 |
|||
fi |
|||
fi |
|||
|
|||
# Now do the copy and return appropriate status |
|||
|
|||
cp $fd/$ff $td/$tf |
|||
if [ $? != 0 ] |
|||
then |
|||
exit 4 |
|||
else |
|||
exit 0 |
|||
fi |
|||
|
@ -1,30 +0,0 @@ |
|||
|
|||
# Warning - first line left blank for sh/csh/ksh compatibility. Do not |
|||
# remove it. fnf@Unisoft |
|||
|
|||
# mklintlib --- make a lint library, under either System V or 4.2 BSD |
|||
# |
|||
# usage: mklintlib <infile> <outfile> |
|||
# |
|||
|
|||
if test $# -ne 2 |
|||
then |
|||
echo "usage: mklintlib <infile> <outfile>" |
|||
exit 1 |
|||
fi |
|||
|
|||
if grep SIGTSTP /usr/include/signal.h >/dev/null |
|||
then # BSD |
|||
if test -r /usr/include/whoami.h # 4.1 |
|||
then |
|||
/lib/cpp -C -Dlint $1 >hlint |
|||
(/usr/lib/lint/lint1 <hlint >$2) 2>&1 | grep -v warning |
|||
else # 4.2 |
|||
lint -Cxxxx $1 |
|||
mv llib-lxxxx.ln $2 |
|||
fi |
|||
else # USG |
|||
cc -E -C -Dlint $1 | /usr/lib/lint1 -vx -Hhlint >$2 |
|||
rm -f hlint |
|||
fi |
|||
exit 0 # don't kill make |
@ -1,4 +0,0 @@ |
|||
CL -I\my\include -AL -Gsm2 -FPi -DDBUG_OFF *.c |
|||
rm \my\lib\dbug.lib |
|||
lib.exe \my\lib\dbug dbug.obj sanity.obj; |
|||
link /NOD /STACK:8000 main factoria,factoria,,DBUG+STRINGS+LLIBCEP+DOSCALLS; |
@ -0,0 +1,26 @@ |
|||
#!/usr/bin/perl |
|||
|
|||
|
|||
die <<EEE unless @ARGV; |
|||
Usage: $0 func1 [func2 [ ...] ] |
|||
|
|||
This filter (stdin->stdout) removes lines from dbug trace that were generated |
|||
by specified functions and all functions down the call stack. Produces the |
|||
same effect as if the original source had DBUG_PUSH(""); right after |
|||
DBUG_ENTER() and DBUG_POP(); right before DBUG_RETURN in every such a function. |
|||
EEE |
|||
|
|||
$re=join('|', @ARGV); |
|||
$skip=''; |
|||
|
|||
while(<STDIN>) { |
|||
print unless $skip; |
|||
next unless /^(?:.*: )*((?:\| )*)([<>])($re)\n/o; |
|||
if ($2 eq '>') { |
|||
$skip=$1.$3 unless $skip; |
|||
next; |
|||
} |
|||
next if $skip ne $1.$3; |
|||
$skip=''; |
|||
print; |
|||
} |
@ -0,0 +1,496 @@ |
|||
#!/usr/bin/env perl |
|||
|
|||
# |
|||
# A driver program to test DBUG features - runs tests (shell commands) |
|||
# from the end of file to invoke tests.c, which does the real dbug work. |
|||
# |
|||
|
|||
use Test::More; |
|||
|
|||
$exe=$0; |
|||
|
|||
die unless $exe =~ s/(tests)-t(\.exe)?$/$1$2 /; |
|||
|
|||
# load tests |
|||
@tests=(); |
|||
while (<DATA>) { |
|||
if (/^% \.\/tests /) { |
|||
push @tests, [ $' ] |
|||
} elsif (/^#/) { |
|||
next; |
|||
} else { |
|||
push @{$tests[$#tests]}, $_ |
|||
} |
|||
} |
|||
|
|||
plan skip_all => "because dbug is disabled" if system $exe; |
|||
|
|||
plan tests => scalar(@tests); |
|||
|
|||
for (@tests) { |
|||
$t=$exe . shift @$_; |
|||
chomp($t); |
|||
open F, '-|', $t or die "open($t|): $!"; |
|||
local $"; |
|||
$out=join($", <F>); close(F); |
|||
# special cases are handled here: |
|||
$out =~ s/Memory: 0x[0-9A-Fa-f]+/Memory: 0x####/g if $t =~ /dump/; |
|||
# compare ("\n" at the beginning makes better output in case of errors) |
|||
is("\n$out","\n@$_", $t); |
|||
} |
|||
|
|||
__DATA__ |
|||
% ./tests -#d |
|||
func2: info: s=ok |
|||
=> execute |
|||
=> evaluate: ON |
|||
=> evaluate_if: OFF |
|||
main: explain: dbug explained: d |
|||
func2: info: s=ok |
|||
% ./tests d,ret3 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
# |
|||
## Testing negative lists |
|||
# |
|||
% ./tests d:-d,ret3 |
|||
func2: info: s=ko |
|||
=> execute |
|||
=> evaluate: ON |
|||
=> evaluate_if: OFF |
|||
main: explain: dbug explained: d:-d,ret3 |
|||
func2: info: s=ko |
|||
% ./tests t:-d,ret3 |
|||
>main |
|||
| >func1 |
|||
| | >func2 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| | <func2 |
|||
| <func1 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
| >func2 |
|||
| | >func3 |
|||
| | <func3 |
|||
| <func2 |
|||
<main |
|||
% ./tests t:d,info:-d,ret3 |
|||
>main |
|||
| >func1 |
|||
| | >func2 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| | | info: s=ko |
|||
| | <func2 |
|||
| <func1 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
| >func2 |
|||
| | >func3 |
|||
| | <func3 |
|||
| | info: s=ko |
|||
| <func2 |
|||
<main |
|||
% ./tests t:d,info:-d,ret3:-f,func2 |
|||
>main |
|||
| >func1 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| <func1 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
| | >func3 |
|||
| | <func3 |
|||
<main |
|||
% ./tests t:d,info:-d,ret3:-f,func2 d,evaluate |
|||
=> evaluate: ON |
|||
=> evaluate_if: OFF |
|||
% ./tests t:d,info:-d,ret3:-f,func2 d,evaluate_if |
|||
=> evaluate: OFF |
|||
=> evaluate_if: ON |
|||
% ./tests t:d:-d,ret3:-f,func2 d,evaluate_if |
|||
=> evaluate: OFF |
|||
=> evaluate_if: ON |
|||
% ./tests t:d:-d,ret3:-f,func2 |
|||
>main |
|||
| >func1 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| <func1 |
|||
=> execute |
|||
=> evaluate: ON |
|||
=> evaluate_if: OFF |
|||
| explain: dbug explained: d:-d,ret3:f:-f,func2:t |
|||
| | >func3 |
|||
| | <func3 |
|||
<main |
|||
# |
|||
## Adding incremental settings to the brew |
|||
# |
|||
% ./tests t:d:-d,ret3:-f,func2 +d,evaluate_if |
|||
>main |
|||
| >func1 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| <func1 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: ON |
|||
| | >func3 |
|||
| | <func3 |
|||
<main |
|||
# |
|||
## DBUG_DUMP |
|||
# |
|||
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump |
|||
>main |
|||
| >func1 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| <func1 |
|||
| dump: Memory: 0x#### Bytes: (27) |
|||
64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A |
|||
74 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
| | >func3 |
|||
| | <func3 |
|||
<main |
|||
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump |
|||
>main |
|||
| >func1 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| <func1 |
|||
| dump: Memory: 0x#### Bytes: (27) |
|||
64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A |
|||
74 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
| | >func3 |
|||
| | <func3 |
|||
<main |
|||
% ./tests t:d:-d,ret3:f:-f,func2:+d,dump |
|||
>main |
|||
| >func1 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| <func1 |
|||
| dump: Memory: 0x#### Bytes: (27) |
|||
64 2C 64 75 6D 70 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D 66 2C 66 75 6E 63 32 3A |
|||
74 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
| | >func3 |
|||
| | <func3 |
|||
<main |
|||
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump,explain |
|||
>main |
|||
| >func1 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| <func1 |
|||
| dump: Memory: 0x#### Bytes: (35) |
|||
64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D |
|||
66 2C 66 75 6E 63 32 3A 74 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
| explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:t |
|||
| | >func3 |
|||
| | <func3 |
|||
<main |
|||
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump,explain:P |
|||
dbug: >main |
|||
dbug-tests: | >func1 |
|||
dbug-tests: | | | >func3 |
|||
dbug-tests: | | | <func3 |
|||
dbug-tests: | <func1 |
|||
dbug-tests: | dump: Memory: 0x#### Bytes: (37) |
|||
64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D |
|||
66 2C 66 75 6E 63 32 3A 50 3A 74 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
dbug-tests: | explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:P:t |
|||
dbug-tests: | | >func3 |
|||
dbug-tests: | | <func3 |
|||
dbug-tests: <main |
|||
% ./tests t:d:-d,ret3:f:-f,func2 +d,dump,explain:P:F |
|||
dbug: tests.c: >main |
|||
dbug-tests: tests.c: | >func1 |
|||
dbug-tests: tests.c: | | | >func3 |
|||
dbug-tests: tests.c: | | | <func3 |
|||
dbug-tests: tests.c: | <func1 |
|||
dbug-tests: tests.c: | dump: Memory: 0x#### Bytes: (39) |
|||
64 2C 64 75 6D 70 2C 65 78 70 6C 61 69 6E 3A 2D 64 2C 72 65 74 33 3A 66 3A 2D |
|||
66 2C 66 75 6E 63 32 3A 46 3A 50 3A 74 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
dbug-tests: tests.c: | explain: dbug explained: d,dump,explain:-d,ret3:f:-f,func2:F:P:t |
|||
dbug-tests: tests.c: | | >func3 |
|||
dbug-tests: tests.c: | | <func3 |
|||
dbug-tests: tests.c: <main |
|||
# |
|||
## DBUG_EXPLAIN, DBUG_PUSH, DBUG_POP, DBUG_SET |
|||
# |
|||
% ./tests t:d:-d,ret3:f:-f,func2 |
|||
>main |
|||
| >func1 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| <func1 |
|||
=> execute |
|||
=> evaluate: ON |
|||
=> evaluate_if: OFF |
|||
| explain: dbug explained: d:-d,ret3:f:-f,func2:t |
|||
| | >func3 |
|||
| | <func3 |
|||
<main |
|||
% ./tests t:d:-d,ret3 |
|||
>main |
|||
| >func1 |
|||
| | >func2 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| | | info: s=ko |
|||
| | <func2 |
|||
| <func1 |
|||
=> execute |
|||
=> evaluate: ON |
|||
=> evaluate_if: OFF |
|||
| explain: dbug explained: d:-d,ret3:t |
|||
| >func2 |
|||
| | >func3 |
|||
| | <func3 |
|||
| | info: s=ko |
|||
| <func2 |
|||
<main |
|||
% ./tests d,info:-d,ret3:d,push |
|||
func2: info: s=ko |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
| >func2 |
|||
| | >func3 |
|||
| | <func3 |
|||
| | info: s=ko |
|||
| <func2 |
|||
<main |
|||
% ./tests d,info:-d,ret3:d,push,explain |
|||
func2: info: s=ko |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
| explain: dbug explained: d,info,push,explain:-d,ret3:t |
|||
| >func2 |
|||
| | >func3 |
|||
| | <func3 |
|||
| | info: s=ko |
|||
| <func2 |
|||
<main |
|||
% ./tests d,info:-d,ret3:d,explain |
|||
func2: info: s=ko |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
main: explain: dbug explained: d,info,explain:-d,ret3 |
|||
func2: info: s=ko |
|||
% ./tests d,info:-d,ret3:d,explain,pop |
|||
func2: info: s=ko |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
% ./tests d,info:-d,ret3:d,explain t:d,pop |
|||
>main |
|||
| >func1 |
|||
| | >func2 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| | <func2 |
|||
| <func1 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
main: explain: dbug explained: d,info,explain:-d,ret3 |
|||
func2: info: s=ko |
|||
% ./tests d,info:-d,ret3:d,explain,pop +t |
|||
>main |
|||
| >func1 |
|||
| | >func2 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| | | info: s=ko |
|||
| | <func2 |
|||
| <func1 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
main: explain: dbug explained: d,info,explain,pop:-d,ret3 |
|||
func2: info: s=ko |
|||
% ./tests d,info:-d,ret3:d,explain,set |
|||
func2: info: s=ko |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
tests.c: main: explain: dbug explained: d,info,explain,set:-d,ret3:F |
|||
tests.c: func2: info: s=ko |
|||
% ./tests d,info:-d,ret3:d,explain,set:t |
|||
>main |
|||
| >func1 |
|||
| | >func2 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| | | info: s=ko |
|||
| | <func2 |
|||
| <func1 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
tests.c: | explain: dbug explained: d,info,explain,set:-d,ret3:F:t |
|||
tests.c: | >func2 |
|||
tests.c: | | >func3 |
|||
tests.c: | | <func3 |
|||
tests.c: | | info: s=ko |
|||
tests.c: | <func2 |
|||
tests.c: <main |
|||
% ./tests t d,info:-d,ret3:d,explain,set:t |
|||
>main |
|||
| >func1 |
|||
| | >func2 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| | | info: s=ko |
|||
| | <func2 |
|||
| <func1 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
tests.c: | explain: dbug explained: d,info,explain,set:-d,ret3:F:t |
|||
tests.c: | >func2 |
|||
tests.c: | | >func3 |
|||
tests.c: | | <func3 |
|||
tests.c: | | info: s=ko |
|||
tests.c: | <func2 |
|||
tests.c: <main |
|||
% ./tests t d,info:-d,ret3:d,explain,set,pop |
|||
func2: info: s=ko |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
| >func2 |
|||
| | >func3 |
|||
| | <func3 |
|||
| <func2 |
|||
<main |
|||
% ./tests t:f,func2 |
|||
| | >func2 |
|||
| | <func2 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
| >func2 |
|||
| <func2 |
|||
# |
|||
## Testing SUBDIR rules |
|||
# |
|||
% ./tests t:-f,func2/:d |
|||
>main |
|||
| >func1 |
|||
| <func1 |
|||
=> execute |
|||
=> evaluate: ON |
|||
=> evaluate_if: OFF |
|||
| explain: dbug explained: d:f:-f,func2/:t |
|||
<main |
|||
% ./tests t:f,func1/:d |
|||
| >func1 |
|||
| | >func2 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| | | info: s=ok |
|||
| | <func2 |
|||
| <func1 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
% ./tests t:f,main/:d,pop |
|||
>main |
|||
| >func1 |
|||
| | >func2 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| | <func2 |
|||
| <func1 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
% ./tests f,main/:d,push |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
| >func2 |
|||
| | >func3 |
|||
| | <func3 |
|||
| <func2 |
|||
<main |
|||
# |
|||
## Testing FixTraceFlags() - when we need to traverse the call stack |
|||
# (these tests fail with FixTraceFlags() disabled) |
|||
# |
|||
# delete the INCLUDE rule up the stack |
|||
% ./tests t:f,func1/ --push1=t:f,func3/ |
|||
| >func1 |
|||
| | >func2 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| | <func2 |
|||
=> push1 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
| | >func3 |
|||
| | <func3 |
|||
# delete the EXCLUDE rule up the stack |
|||
% ./tests t:-f,func1/ --push1=t |
|||
>main |
|||
=> push1 |
|||
| <func1 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
| >func2 |
|||
| | >func3 |
|||
| | <func3 |
|||
| <func2 |
|||
<main |
|||
# add the INCLUDE rule up the stack |
|||
% ./tests t:f,func3 --push1=t:f,main/ |
|||
| | | >func3 |
|||
| | | <func3 |
|||
=> push1 |
|||
| <func1 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
| >func2 |
|||
| | >func3 |
|||
| | <func3 |
|||
| <func2 |
|||
<main |
|||
# add the EXCLUDE rule up the stack |
|||
% ./tests t --push1=t:-f,main/ |
|||
>main |
|||
| >func1 |
|||
| | >func2 |
|||
| | | >func3 |
|||
| | | <func3 |
|||
| | <func2 |
|||
=> push1 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
# change the defaults |
|||
% ./tests t:f,func3 --push1=t |
|||
| | | >func3 |
|||
| | | <func3 |
|||
=> push1 |
|||
| <func1 |
|||
=> evaluate: OFF |
|||
=> evaluate_if: OFF |
|||
| >func2 |
|||
| | >func3 |
|||
| | <func3 |
|||
| <func2 |
|||
<main |
|||
# repeated keyword |
|||
% ./tests d:-d,info,info |
|||
=> execute |
|||
=> evaluate: ON |
|||
=> evaluate_if: OFF |
|||
main: explain: dbug explained: d:-d,info |
|||
% ./tests d:-d,info/,info |
|||
=> execute |
|||
=> evaluate: ON |
|||
=> evaluate_if: OFF |
|||
main: explain: dbug explained: d:-d,info/ |
@ -0,0 +1,87 @@ |
|||
/* |
|||
A program to test DBUG features. Used by tests-t.pl |
|||
*/ |
|||
|
|||
char *push1=0; |
|||
|
|||
#include <my_global.h> /* This includes dbug.h */ |
|||
#include <my_pthread.h> |
|||
#include <string.h> |
|||
|
|||
const char *func3() |
|||
{ |
|||
DBUG_ENTER("func3"); |
|||
DBUG_RETURN(DBUG_EVALUATE("ret3", "ok", "ko")); |
|||
} |
|||
|
|||
void func2() |
|||
{ |
|||
const char *s; |
|||
DBUG_ENTER("func2"); |
|||
s=func3(); |
|||
DBUG_PRINT("info", ("s=%s", s)); |
|||
DBUG_VOID_RETURN; |
|||
} |
|||
|
|||
int func1() |
|||
{ |
|||
DBUG_ENTER("func1"); |
|||
func2(); |
|||
if (push1) |
|||
{ |
|||
DBUG_PUSH(push1); |
|||
fprintf(DBUG_FILE, "=> push1\n"); |
|||
} |
|||
DBUG_RETURN(10); |
|||
} |
|||
|
|||
int main (int argc, char *argv[]) |
|||
{ |
|||
int i; |
|||
#ifdef DBUG_OFF |
|||
return 1; |
|||
#endif |
|||
if (argc == 1) |
|||
return 0; |
|||
|
|||
#if defined(HAVE_PTHREAD_INIT) && defined(THREAD) |
|||
pthread_init(); /* Must be called before DBUG_ENTER */ |
|||
#endif |
|||
#ifdef THREAD |
|||
my_thread_global_init(); |
|||
#endif |
|||
dup2(1, 2); |
|||
for (i = 1; i < argc; i++) |
|||
{ |
|||
if (strncmp(argv[i], "--push1=", 8) == 0) |
|||
push1=argv[i]+8; |
|||
else |
|||
DBUG_PUSH (argv[i]); |
|||
} |
|||
{ |
|||
DBUG_ENTER ("main"); |
|||
DBUG_PROCESS ("dbug-tests"); |
|||
func1(); |
|||
DBUG_EXECUTE_IF("dump", |
|||
{ |
|||
char s[1000]; |
|||
DBUG_EXPLAIN(s, sizeof(s)-1); |
|||
DBUG_DUMP("dump", (uchar*)s, strlen(s)); |
|||
}); |
|||
DBUG_EXECUTE_IF("push", DBUG_PUSH("+t"); ); |
|||
DBUG_EXECUTE("execute", fprintf(DBUG_FILE, "=> execute\n"); ); |
|||
DBUG_EXECUTE_IF("set", DBUG_SET("+F"); ); |
|||
fprintf(DBUG_FILE, "=> evaluate: %s\n", |
|||
DBUG_EVALUATE("evaluate", "ON", "OFF")); |
|||
fprintf(DBUG_FILE, "=> evaluate_if: %s\n", |
|||
DBUG_EVALUATE_IF("evaluate_if", "ON", "OFF")); |
|||
DBUG_EXECUTE_IF("pop", DBUG_POP(); ); |
|||
{ |
|||
char s[1000] __attribute__((unused)); |
|||
DBUG_EXPLAIN(s, sizeof(s)-1); |
|||
DBUG_PRINT("explain", ("dbug explained: %s", s)); |
|||
} |
|||
func2(); |
|||
DBUG_RETURN (0); |
|||
} |
|||
} |
@ -1,139 +0,0 @@ |
|||
/****************************************************************************** |
|||
* * |
|||
* N O T I C E * |
|||
* * |
|||
* Copyright Abandoned, 1987, Fred Fish * |
|||
* * |
|||
* * |
|||
* This previously copyrighted work has been placed into the public * |
|||
* domain by the author and may be freely used for any purpose, * |
|||
* private or commercial. * |
|||
* * |
|||
* Because of the number of inquiries I was receiving about the use * |
|||
* of this product in commercially developed works I have decided to * |
|||
* simply make it public domain to further its unrestricted use. I * |
|||
* specifically would be most happy to see this material become a * |
|||
* part of the standard Unix distributions by AT&T and the Berkeley * |
|||
* Computer Science Research Group, and a standard part of the GNU * |
|||
* system from the Free Software Foundation. * |
|||
* * |
|||
* I would appreciate it, as a courtesy, if this notice is left in * |
|||
* all copies and derivative works. Thank you. * |
|||
* * |
|||
* The author makes no warranty of any kind with respect to this * |
|||
* product and explicitly disclaims any implied warranties of mer- * |
|||
* chantability or fitness for any particular purpose. * |
|||
* * |
|||
****************************************************************************** |
|||
*/ |
|||
|
|||
|
|||
/* |
|||
* FILE |
|||
* |
|||
* vargs.h include file for environments without varargs.h |
|||
* |
|||
* SCCS |
|||
* |
|||
* @(#)vargs.h 1.2 5/8/88 |
|||
* |
|||
* SYNOPSIS |
|||
* |
|||
* #include "vargs.h" |
|||
* |
|||
* DESCRIPTION |
|||
* |
|||
* This file implements a varargs macro set for use in those |
|||
* environments where there is no system supplied varargs. This |
|||
* generally works because systems which don't supply a varargs |
|||
* package are precisely those which don't strictly need a varargs |
|||
* package. Using this one then allows us to minimize source |
|||
* code changes. So in some sense, this is a "portable" varargs |
|||
* since it is only used for convenience, when it is not strictly |
|||
* needed. |
|||
* |
|||
*/ |
|||
|
|||
/* |
|||
* These macros allow us to rebuild an argument list on the stack |
|||
* given only a va_list. We can use these to fake a function like |
|||
* vfprintf, which gets a fixed number of arguments, the last of |
|||
* which is a va_list, by rebuilding a stack and calling the variable |
|||
* argument form fprintf. Of course this only works when vfprintf |
|||
* is not available in the host environment, and thus is not available |
|||
* for fprintf to call (which would give us an infinite loop). |
|||
* |
|||
* Note that ARGS_TYPE is a long, which lets us get several bytes |
|||
* at a time while also preventing lots of "possible pointer alignment |
|||
* problem" messages from lint. The messages are valid, because this |
|||
* IS nonportable, but then we should only be using it in very |
|||
* nonrestrictive environments, and using the real varargs where it |
|||
* really counts. |
|||
* |
|||
*/ |
|||
|
|||
#define ARG0 a0 |
|||
#define ARG1 a1 |
|||
#define ARG2 a2 |
|||
#define ARG3 a3 |
|||
#define ARG4 a4 |
|||
#define ARG5 a5 |
|||
#define ARG6 a6 |
|||
#define ARG7 a7 |
|||
#define ARG8 a8 |
|||
#define ARG9 a9 |
|||
|
|||
#define ARGS_TYPE long |
|||
#define ARGS_LIST ARG0,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7,ARG8,ARG9 |
|||
#define ARGS_DCL auto ARGS_TYPE ARGS_LIST |
|||
|
|||
/* |
|||
* A pointer of type "va_list" points to a section of memory |
|||
* containing an array of variable sized arguments of unknown |
|||
* number. This pointer is initialized by the va_start |
|||
* macro to point to the first byte of the first argument. |
|||
* We can then use it to walk through the argument list by |
|||
* incrementing it by the size of the argument being referenced. |
|||
*/ |
|||
|
|||
typedef char *va_list; |
|||
|
|||
/* |
|||
* The first variable argument overlays va_alist, which is |
|||
* nothing more than a "handle" which allows us to get the |
|||
* address of the first argument on the stack. Note that |
|||
* by definition, the va_dcl macro includes the terminating |
|||
* semicolon, which makes use of va_dcl in the source code |
|||
* appear to be missing a semicolon. |
|||
*/ |
|||
|
|||
#define va_dcl ARGS_TYPE va_alist; |
|||
|
|||
/* |
|||
* The va_start macro takes a variable of type "va_list" and |
|||
* initializes it. In our case, it initializes a local variable |
|||
* of type "pointer to char" to point to the first argument on |
|||
* the stack. |
|||
*/ |
|||
|
|||
#define va_start(list) list = (char *) &va_alist |
|||
|
|||
/* |
|||
* The va_end macro is a null operation for our use. |
|||
*/ |
|||
|
|||
#define va_end(list) |
|||
|
|||
/* |
|||
* The va_arg macro is the tricky one. This one takes |
|||
* a va_list as the first argument, and a type as the second |
|||
* argument, and returns a value of the appropriate type |
|||
* while advancing the va_list to the following argument. |
|||
* For our case, we first increment the va_list arg by the |
|||
* size of the type being recovered, cast the result to |
|||
* a pointer of the appropriate type, and then dereference |
|||
* that pointer as an array to get the previous arg (which |
|||
* is the one we wanted. |
|||
*/ |
|||
|
|||
#define va_arg(list,type) ((type *) (list += sizeof (type)))[-1] |
Write
Preview
Loading…
Cancel
Save
Reference in new issue