This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[wip] gdb_ari.sh


Just FYI,

I finally ripped the ARI script (well one part of it) out of the nightly snapshot process. ``going forward'' I'll tweak the snapshot scripts to use this (it will wait until after 5.3 though).

Andrew
#!/bin/sh

# Permenant checks (can't be removed) take the form: ``Uses XXXX, ISO
# C 90 implies YYYY'' or ``Uses XXXX, instead use YYYY''.

# Tempoary cheks (once everything has been replaced can be eliminated)
# take the form: ``Uses XXXX, replaced by YYYY''.

# FIXME: It should be able to override this on the command line
error='regression'
warning='regression'

while test $# -gt 0
do
    case "$1" in
    -Wall ) warning='regression code deprecated pedantic info' ; shift ;;
    -Werror ) Werror=1 ; shift ;;
    -W* ) warning="${warning} `echo x$1 | sed -e 's/x-W//'`" ; shift ;;
    -- ) shift ; break ;;
    - ) break ;;
    -* ) usage="$1" ; shift ;;
    * ) break ;;
    esac
done
if test $# -eq 0
then
    usage="missing file"
fi

if test "${Werror}"
then
    error="${error} ${warning}"
fi

for w in ${warning}
do
    warnings="${warnings} warning[ari_${w}] = 1;"
done
for e in ${error}
do
    errors="${errors} error[ari_${e}]  = 1;"
done

# Hack: Delay printing the usage until the very end.  To test the
# parser use the command: sh -x $0 arg arg -xxx

if test "x${usage}" != x
then
    echo "Usage: $0 -Wall -Werror -W<warning>" 1>&2
    exit 1
fi

awk -- '
BEGIN {
    # NOTE, for a per-file begin use FNR==1.
    ari_regression = "regression"
    ari_code = "code"
    ari_pedantic = "pedantic"
    ari_info = "info"
    ari_deprecated = "deprecated"
    '"${errors}"'
    '"${warnings}"'
}

function fail (bug) {
    if (doc[bug] == "") {
	print "internal-error: missing doc for bug: " bug
	exit
    }
    if (level[bug] == "") {
	print "internal-error: missing level for bug: " bug
	exit
    }
    # print FILENAME ":" FNR ": " bug ":" level[bug] ":" error[level[bug]] ":" warning[level[bug]] ":" doc[bug] 

    if (error[level[bug]]) {
	print FILENAME ":" FNR ": " level[bug] ": " doc[bug]
    } else if (warning[level[bug]]) {
	print FILENAME ":" FNR ": warning: " level[bug] ": " doc[bug]
    }
}
 
# Skip deprecated/obsolete lines
/(^|[^_[:alnum:]])OBSOLETE([^_[:alnum:]]|$)/ { next; }

# Skip OK lines
/\/\* OK \*\// { next; }

# Things in comments

BEGIN { doc["GNU/Linux"] = "\
Uses `Linux'\'', comments should clearly differentiate between the \
`Linux kernel'\'' and a `GNU/Linux system'\'' (this test assumes that \
word `Linux'\'' appears on the same line as the word `GNU'\'' or `kernel'\''"
    level["GNU/Linux"] = ari_regression
}
/(^|[^_[:alnum:]])Linux([^_[:alnum:]]|$)/ \
&& !/(^|[^_[:alnum:]])GNU\/Linux([^_[:alnum:]]|$)/ \
&& !/(^|[^_[:alnum:]])Linux kernel([^_[:alnum:]]|$)/ {
    fail("GNU/Linux")
}

BEGIN { doc["ARGSUSED"] = "\
Does the key word ARGSUSED in a comment ever do anything?"
    level["ARGSUSED"] = ari_info
}
/(^|[^_[:alnum:]])ARGSUSED([^_[:alnum:]]|$)/ {
    fail("ARGSUSED")
}


# SNIP - Strip out comments - SNIP

FNR == 1 { comment_p = 0; }
comment_p && /\*\// { gsub (/^([^\*]|\*+[^\/\*])*\*+\//, " "); comment_p = 0; }
comment_p { next; }
!comment_p { gsub (/\/\*([^\*]|\*+[^\/\*])*\*+\//, " "); }
!comment_p && /\/\*/ { gsub (/\/\*.*$/, " "); comment_p = 1; }

BEGIN { doc["error capital"] = "\
An error message should start with a capital letter"
    level["error capital"] = ari_pedantic
}
/(^[^_[:alnum:]])error[[:space:]]*\([[:space:]]*"[^A-Z]*[^\/]"/ {
    fail("error capital")
}

BEGIN { doc["error full-stop"] = "\
An error message should not have a trailing full-stop"
    level["error full-stop"] = ari_pedantic
}
/(^[^_[:alnum:]])error[[:space:]]*\([[:space:]]*"[^"]\."/ {
    fail("error full-stop")
}

BEGIN { doc["error underscore"] = "\
An error message should not refer to internal code such as function \
names  (an error message that contains an underscore in the first word \
most likely has this problem)"
    level["error underscore"] = ari_pedantic
}
/(^[^_[:alnum:]])error[[:space:]]*\([[:space:]]*"[[:alnum:]]*_/ {
    fail("error underscore")
}

# Include files for which GDB has a custom version.

BEGIN { doc["assert.h"] = "\
Uses <assert.h>, instead use \"gdb_assert.h\"";
    level["assert.h"] = ari_regression
    #fix("assert.h", "gdb/gdb_assert.h", 0) # it does not use it
}
/^#[[:blank:]]*include[[:blank:]]+.assert\.h./ {
    fail("assert.h")
}

BEGIN { doc["dirent.h"] = "\
Uses <dirent.h>, instead use \"gdb_dirent.h\"";
    level["dirent.h"] = ari_regression
    #fix("dirent.h", "gdb/gdb_dirent.h", 1);
}
/^#[[:blank:]]*include[[:blank:]]*.dirent\.h./ {
    fail("dirent.h")
}

BEGIN { doc["proc_service.h"] = "\
Uses <proc_service.h>, instead use \"gdb_proc_service.h\"";
    level["proc_service.h"] = ari_code
    #fix("proc_service.h", "gdb/gdb_proc_service.h", 1)
}
/^#[[:blank:]]*include[[:blank:]]*.proc_service\.h./ {
    fail("proc_service.h")
}

BEGIN { doc["regex.h"] = "\
Uses <regex.h>, instead use \"gdb_regex.h\"";
    level["regex.h"] = ari_regression
    #fix("regex.h", "gdb/gdb_regex.h", 1)
}
/^#[[:blank:]]*include[[:blank:]]*.regex\.h./ {
    fail("regex.h")
}

BEGIN { doc["xregex.h"] = "\
Uses <xregex.h>, instead use \"gdb_regex.h\"";
    level["xregex.h"] = ari_regression
    #fix("xregex.h", "gdb/gdb_regex.h", 1)
}
/^#[[:blank:]]*include[[:blank:]]*.xregex\.h./ {
    fail("xregex.h")
}

BEGIN { doc["gnu-regex.h"] = "\
Uses <gnu-regex.h>, instead use \"gdb_regex.h\"";
    level["gnu-regex.h"] = ari_regression
}
/^#[[:blank:]]*include[[:blank:]]*.gnu-regex\.h./ {
    fail("gnu regex.h")
}

BEGIN { doc["stat.h"] = "\
Uses <stat.h> or <sys/stat.h>, instead use \"gdb_stat.h\"";
    level["stat.h"] = ari_code
    #fix("stat.h", "gdb/gdb_stat.h", 1)
}
/^#[[:blank:]]*include[[:blank:]]*.stat\.h./ \
|| /^#[[:blank:]]*include[[:blank:]]*.sys\/stat\.h./ {
    fail("stat.h")
}

BEGIN { doc["string.h"] = "\
Uses <string.h> or <strings.h> or <memory.h>, instead use \"gdb_string.h\"";
    level["string.h"] = ari_regression
    #fix("string.h", "gdb/gdb_string.h", 4)
}
/^#[[:blank:]]*include[[:blank:]]*.string\.h./ \
|| /^#[[:blank:]]*include[[:blank:]]*.strings\.h./ \
|| /^#[[:blank:]]*include[[:blank:]]*.memory\.h./ {
    fail("string.h")
}

BEGIN { doc["thread_db.h"] = "\
Uses <thread_db.h>, instead use \"gdb_thread_db.h\"";
    #fix("thread_db.h", "gdb/gdb_thread_db.h", 1);
    level["thread_db.h"] = ari_code
}
/^#[[:blank:]]*include[[:blank:]]*.thread_db\.h./ {
    fail("thread_db.h")
}

BEGIN { doc["wait.h"] = "\
Uses <wait.h> or <sys/wait.h>, instead use \"gdb_wait.h\"";
    #fix("wait.h", "gdb/gdb_wait.h", 2);
    level["wait.h"] = ari_code
}
/^#[[:blank:]]*include[[:blank:]]*.wait\.h./ \
|| /^#[[:blank:]]*include[[:blank:]]*.sys\/wait\.h./ {
    fail("wait.h")
}

BEGIN { doc["vfork.h"] = "\
Uses <vfork.h>, instead use \"gdb_vfork.h\"";
    #fix("vfork.h", "gdb/gdb_vfork.h", 1);
    level["vfork.h"] = ari_regression
}
/^#[[:blank:]]*include[[:blank:]]*.vfork\.h./ {
    fail("vfork.h")
}

BEGIN { doc["Xm-OS.h"] = "\
Some config/ARCH/Xm-OS.h files use #include \"Xm-OS.h\".  To include the \
file \"config/Xm-OS.h\".  They should use the latter path"
    level["Xm-OS.h"] = ari_regression
}
/^#[[:blank:]]*include[[:blank:]]*.nm-[^\.]*\.h./ \
|| /^#[[:blank:]]*include[[:blank:]]*.tm[^\.]*-\.h./ \
|| /^#[[:blank:]]*include[[:blank:]]*.xm-[^\.]*\.h./ {
    fail("Xm-OS.h")
}

BEGIN { doc["error printing internal error"] = "\
Uses error(\"internal-error\"), instead use internal_error()"
    level["error printing internal error"] = ari_pedantic
}
/error.*\"[Ii]nternal.error/ {
    fail("error printing internal error")
}

BEGIN { doc["error printing internal warning"] = "\
Uses error(\"internal-warning\"), instead use internal_error()"
    level["error printing internal warning"] = ari_pedantic
}
/error.*\"[Ii]nternal.warning/ {
    fail("error printing internal warning")
}

BEGIN { doc["%p"] = "\
Uses printf(\"%p\"), instead use printf(\"%s\",paddr()) to dump a \
target address"
    level["%p"] = ari_code
}
/%p/ && !/%prec/ {
    fail("%p")
}

BEGIN { doc["%ll"] = "\
Uses printf(\"%ll\"), instead use printf(\"%s\",phex()) to dump a \
`long long'\'' value"
    level["%ll"] = ari_code
}
/%ll/ {
    fail("%ll")
}


# SNIP - Strip out strings - SNIP

# Test on top.c, scm-valprint.c, remote-rdi.c, ada-lang.c
FNR == 1 { string_p = 0; }
# Strip escaped characters.
{ gsub(/\\./, "."); }
# Strip quoted quotes.
{ gsub(/'\''.'\''/, "'\''.'\''"); }
# End of multi-line string
string_p && /\"/ {
    # print "EOS:", $0;
    gsub (/^[^\"]*\"/, "'\''");
    string_p = 0;
}
# Middle of multi-line string, discard line.
string_p {
    # print "MOS:", $0;
    $0 = ""
}
# Strip complete strings from the middle of the line
!string_p {
    # print "COS:", $0;
    gsub (/\"[^\"]*\"/, "'\''");
}
# Start of multi-line string
!string_p && /\"/ {
    # print "SOS:", $0;
    gsub (/\"[^\"]*$/, "'\''");
    string_p = 1;
}
# { print }


# Accumulate continuation lines
FNR == 1 { cont_p = 0; }
!cont_p { full_line = ""; }
/[^\\]\\$/ { gsub (/\\$/, ""); full_line = full_line $0; cont_p = 1; next; }
cont_p { $0 = full_line $0; cont_p = 0; full_line = ""; }


# GDB uses ISO C 90.  Check for any non pure ISO C 90 code

BEGIN { doc["PARAMS"] = "\
Uses PARAMS(), ISO C 90 implies prototypes"
    level["PARAMS"] = ari_regression
}
/(^|[^_[:alnum:]])PARAMS([^_[:alnum:]]|$)/ {
    fail("PARAMS")
}

BEGIN { doc["__STDC__"] = "\
Uses __STDC__, ISO C 90 implies __STDC__";
    level["__STDC__"] = ari_regression
}
/(^|[^_[:alnum:]])__STDC__([^_[:alnum:]]|$)/ {
    fail("__STDC__")
}

BEGIN { doc["__func__"] = "\
Uses __func__, ISO C 90 does not support this macro"
    level["__func__"] = ari_regression
    #fix("__func__", "gdb/gdb_assert.h", 1)
}
/(^|[^_[:alnum:]])__func__([^_[:alnum:]]|$)/ {
    fail("__func__")
}

BEGIN { doc["__FUNCTION__"] = "\
Uses __FUNCTION__, ISO C 90 does not support this macro"
    level["__FUNCTION__"] = ari_regression
}
/(^|[^_[:alnum:]])__FUNCTION__([^_[:alnum:]]|$)/ {
    fail("__FUNCTION__")
}

BEGIN { doc["__CYGWIN32__"] = "\
Uses __CYGWIN32__, instead use __CYGWIN__ or, better, an explicit \
autoconf tests";
    level["__CYGWIN32__"] = ari_regression
}
/(^|[^_[:alnum:]])__CYGWIN32__([^_[:alnum:]]|$)/ {
    fail("__CYGWIN32__")
}

BEGIN { doc["PTR"] = "\
Uses PTR, ISO C 90 implies `void *'\''"
    level["PTR"] = ari_code
}
/(^|[^_[:alnum:]])PTR([^_[:alnum:]]|$)/ {
    fail("PTR")
}

BEGIN { doc["//"] = "\
Uses `//'\'', ISO C 90 does not support C++ comments"
    level["//"] = ari_regression
}
/\/\// {
    fail("//")
}

BEGIN { doc["CONST_PTR"] = "\
Uses CONST_PTR, ISO C 90 implies `const void *'\''"
    level["CONST_PTR"] = ari_regression
}
/(^|[^_[:alnum:]])CONST_PTR([^_[:alnum:]]|$)/ {
    fail("CONST_PTR")
}

BEGIN { doc["grep ^func"] = "\
A function declaration with the function name positioned at the very start \
of a line.  Only as part of the function definition should the function \
name appear at the very start of a line.  This is so that \
`grep ^func'\'' works";
    level["grep ^func"] = ari_code
}
{ grep_func = 0; }
/^[[:alnum:]_]+[[:blank:]]*\([[:blank:]]*[^\*].*\);[[:blank:]]*/ {
    # FYI, it matches:
    #NAME (...);
    # when a normal declaration would have:
    #TYPE NAME (...);
    fail("grep ^func")
    grep_func = 1;
}

BEGIN { doc["K&R defn"] = "\
Still uses an old style K&R function definition (not declaration). \
This check also trips up on incorrectly indented function declarations \
(see `grep ^func'\'')"
    level["K&R defn"] = ari_regression
    #fix("K&R defn", "gdb/ser-go32.c", 2)
}
/^[[:alnum:]_]+[[:blank:]]*\([[:alnum:]_]*[[:blank:]]*[,\)]/ && \
! /\(void\)/ && ! /\);/ && !grep_func {
    fail("K&R defn")
}

BEGIN { doc["hash"] = "\
Uses ` #...'\'', instead use `#...'\''(some compilers only correctly \
parse a C preprocessor directive when `#'\'' is the first character on \
the line)"
    level["hash"] = ari_regression
}
/^[[:blank:]]+#/ {
    fail("hash")
}

BEGIN { doc["#define JB_..."] = "\
The system header <setjmp.h> is free to define macros with the JB_ prefix"
    level["#define JB_..."] = ari_code
}
/^#[[:space:]]*define[[:space:]]*JB_/ {
    fail("#define JB_...")
}

BEGIN { doc["make_cleanup_func"] = "\
Type casting using make_cleanup_func is invalid ISO C 90";
    level["make_cleanup_func"] = ari_regression
}
/(^|[^_[:alnum:]])make_cleanup_func([^_[:alnum:]]|$)/ {
    fail("make_cleanup_func")
}

BEGIN { doc["catch_errors_ftype"] = "\
Type casting using catch_errors_ftype is invalid ISO C 90";
    level["catch_errors_ftype"] = ari_pedantic
}
/(^|[^_[:alnum:]])catch_errors_ftype([^_[:alnum:]]|$)/ {
    fail("catch_errors_ftype")
}

BEGIN { doc["catch_errors"] = "\
Uses catch_errors(), replaced by catch_exceptions()"
    level["catch_errors"] = ari_pedantic
}
/(^|[^_[:alnum:]])catch_errors[[:space:]]*\(/ {
    fail("catch_errors")
}

BEGIN { doc["strerror"] = "\
Uses strerror(), instead use safe_strerror()"
    level["strerror"] = ari_regression
    #fix("strerror", "gdb/gdb_string.h", 2)
    #fix("strerror", "gdb/utils.c", 1)
}
/(^|[^_[:alnum:]])strerror[[:space:]]*\(/ {
    fail("strerror")
}

BEGIN { doc["long long"] = "\
Uses `long long'\'', instead use LONGEST"
    level["long long"] = ari_code
}
/(^|[^_[:alnum:]])long[[:space:]]+long([^_[:alnum:]]|$)/ {
    fail("long long")
}

BEGIN { doc["ATTRIBUTE_UNUSED"] = "\
Uses ATTRIBUTE_UNUSED, do not bother (GDB is compiled with -Werror and, \
consequently, is not able to tolerate false warnings.  Since -Wunused-param \
produces such warnings, neither that warning flag nor ATTRIBUTE_UNUSED \
are used by GDB"
    level["ATTRIBUTE_UNUSED"] = ari_regression
}
/(^|[^_[:alnum:]])ATTRIBUTE_UNUSED([^_[:alnum:]]|$)/ {
    fail("ATTRIBUTE_UNUSED")
}

# General problems

BEGIN { doc["_func"] = "\
The suffixes ..._func and ..._ftype are used inconsistently in the source, \
perhaps just ..._ftype should be used"
    level["_func"] = ari_info
}
/(^|[^_[:alnum:]])[[:alpha:]_][[:alnum:]_]*_func([^_[:alnum:]]|$)/ {
    fail("_func")
}

BEGIN { doc["TARGET_BYTE_ORDER_SELECTABLE"] = "\
Uses TARGET_BYTE_ORDER_SELECTABLE, replaced by multi-arch"
    level["TARGET_BYTE_ORDER_SELECTABLE"] = ari_regression
}
/TARGET_BYTE_ORDER_SELECTABLE/ {
    fail("TARGET_BYTE_ORDER_SELECTABLE")
}

BEGIN { doc["TARGET_BYTE_ORDER_DEFAULT"] = "\
Uses TARGET_BYTE_ORDER_DEFAULT, replaced by multi-arch"
    level["TARGET_BYTE_ORDER_DEFAULT"] = ari_regression
}
/TARGET_BYTE_ORDER_DEFAULT/ {
    fail("TARGET_BYTE_ORDER_DEFAULT")
}

# Correct use of initialized?
BEGIN {
    doc["_initialize decl"] = "\
Declaration of _initialize*() missing.  The declaration stops a \
-Wmissing-declarations warning from GCC"
    level["_initialize decl"] = ari_info
    doc["_initialize ftype"] = "\
Declaration of _initialize*() does not use initialize_file_ftype, should it?";
    level["_initialize ftype"] = ari_info
}
# Remember what type declaration, if any, we see
FNR == 1 {
    initialize_decl = 0;
    initialize_ftype = 0;
}
/^extern[[:space:]]+void[[:space:]]+_initialize_[_[:alnum:]]*/ {
    initialize_decl = 1
}
/^extern[[:space:]]+initialize_file_ftype[[:space:]]+_initialize_[_[:alnum:]]*/ {
    initialize_ftype = 1
}
# Check it against the definition
/^_initialize_[_[:alnum:]]*[[:space:]]+/ {
    if (!initialize_decl && !initialize_ftype) {
	fail("_initialize decl")
    }
    if (!initialize_ftype) {
	fail("_initialize ftype")
    }
}

BEGIN { doc["inline"] = "\
Uses `inline'\'', in general in-line suggests a micro-optimization - a \
better algorithm will produce greater performance improvements - \
let the compiler decide if/when something needs to be made in-line"
    level["inline"] = ari_pedantic
}
/(^|[^_[:alnum:]])inline([^_[:alnum:]]|$)/ {
    fail("inline")
}

BEGIN { doc["register"] = "\
Uses `register'\'', instead let the compiler decide"
    level["register"] = ari_pedantic
}
/(^|[^_[:alnum:]])register([^_[:alnum:]]|$)/ {
    fail("register")
}

BEGIN { doc["return_to_top_level"] = "\
Uses return_to_top_level(), replaced by verror() et.al."
    level["return_to_top_level"] = ari_regression
}
/(^|[^_[:alnum:]])return_to_top_level[[:blank:]]*\(/ {
    fail("return_to_top_level")
}

BEGIN { doc["error_begin"] = "\
Uses error_begin(), replaced by verror() et.al."
    level["error_begin"] = ari_regression
}
/(^|[^_[:alnum:]])error_begin[[:blank:]]*\(/ {
    fail("error_begin")
}

BEGIN { doc["warning_begin"] = "\
Uses warning_begin(), replaced by vwarning() et.al."
    level["warning_begin"] = ari_regression
}
/(^|[^_[:alnum:]])warning_begin[[:blank:]]*\(/ {
    fail("warning_begin")
}

BEGIN { doc["sizeof CORE_ADDR"] = "\
Uses `sizeof CORE_ADDR'\'', instead use TARGET_PTR_BIT or TARGET_ADDR_BIT \
(taking the sizeof a CORE_ADDR is wrong.  CORE_ADDR is at least as big as \
the target pointer, _not_ the same size)"
    level["sizeof CORE_ADDR"] = ari_pedantic
}
/(^|[^_[:alnum:]])sizeof[[:blank:]]*\(CORE_ADDR\)/ \
|| /(^|[^_[:alnum:]])sizeof[[:blank:]]*CORE_ADDR([^_[:alnum:]]|$)/ {
    fail("sizeof CORE_ADDR")
}

BEGIN { doc["REGNO"] = "\
Uses ..._REGNO suffix, instead use ..._REGNUM suffix"
    level["REGNO"] = ari_info
}
/_REGNO([^_[:alnum:]]|$)/ || /_regno([^_[:alnum:]]|$)/ {
    fail("REGNO")
}

BEGIN { doc["abort"] = "\
Uses abort(), instead use internal_error() (GDB should never abort)"
    level["abort"] = ari_regression
    #fix("abort", "gdb/utils.c", 3)
}
/(^|[^_[:alnum:]])abort[[:blank:]]*\(/ {
    fail("abort")
}

BEGIN { doc["basename"] = "\
Uses basename(), instead use `const char *lbasename(const char *)'\''";
    level["basename"] = ari_regression
}
/(^|[^_[:alnum:]])basename[[:blank:]]*\(/ {
    fail("basename")
}

BEGIN { doc["assert"] = "\
Uses assert(), instead use gdb_assert() or internal_error() (assert() \
calls abort() and GDB should never call abort)"
    level["assert"] = ari_regression
}
/(^|[^_[:alnum:]])assert[[:blank:]]*\(/ {
    fail("assert")
}

BEGIN { doc["CORE_ADDR cast"] = "\
Casting something to a CORE_ADDR is typically dangerous and non-portable. \
(The data from this pattern may be wrong)";
    level["CORE_ADDR cast"] = ari_pedantic
}
/\(CORE_ADDR\)[:blank:]*[^,);]/ {
    fail("CORE_ADDR cast")
}

BEGIN { doc["QUIT"] = "\
Uses QUIT, should be replaced by the safer `if (QUIT_P ()) \
return ...;'\'' (which does not yet exist)"
    level["QUIT"] = ari_info
}
/QUIT[[:blank:]]*[^;]/ {
    fail("QUIT")
}

BEGIN { doc["quit_flag"] = "\
Uses quit_flag, should it instead use `if (QUIT_P ()) ...'\'' \
(which does not yet exist)"
    level["quit_flag"] = ari_info
}
/(^|[^_[:alnum:]])quit_flag([^_[:alnum:]]|$)/ {
    fail("quit_flag")
}

BEGIN { doc["extern"] = "\
An `extern'\'' declaration appears in a .c file";
    level["extern"] = ari_pedantic
    #fix("extern", "gdb/ser-go32.c", 1) # extern *environ;
}
/^[[:blank:]]*extern[[:blank:]]*/ && ! /_initialize_/ && FILENAME ~ /\.c$/ { 
    fail("extern")
}

BEGIN { doc["#define"] = "\
Delcare an enum in preference to define a macro. ???";
    level["#define"] = ari_info
}
/^#[[:blank:]]*define[[:blank:]]+[[:alnum:]_]+[[:blank:]]+/ {
    fail("#define")
}

BEGIN { doc["#if"] = "\
Use an if statement in preference to conditionally compiled code. ???";
    level["#if"] = ari_info
}
/^#[[:blank:]]*if/ && ! / HAVE_/ {
    fail("#if")
}

BEGIN { doc["GDBTK"] = "\
#ifdef GDBTK should not be needed"
    level["GDBTK"] = ari_pedantic
}
/(^|[^_[:alnum:]])GDBTK([^_[:alnum:]]|$)/ {
    fail("GDBTK")
}

BEGIN { doc["TUI"] = "\
#ifdef TUI should not be needed"
    level["TUI"] = ari_pedantic
}
/(^|[^_[:alnum:]])TUI([^_[:alnum:]]|$)/ {
    fail("TUI")
}

BEGIN { doc["HAVE_VFORK"] = "\
#ifdef HAVE_VFORK is redundant.  Include \"gdb_vfork.h\" and call vfork() \
unconditionally"
    level["HAVE_VFORK"] = ari_regression
}
/(^|[^_[:alnum:]])HAVE_VFORK([^_[:alnum:]]|$)/ {
    fail("HAVE_VFORK")
}

BEGIN { doc["DEBUG"] = "\
Nothing should depend on a macro like DEBUG"
    level["DEBUG"] = ari_info
}
/^#[[:blank:]]*if.*DEBUG/ {
    fail("DEBUG")
}

BEGIN { doc["union"] = "\
The union construct always leads to problems."
    level["union"] = ari_info
}
/[[:blank:]]*union[[:blank:]]*/ {
    fail("union")
}

BEGIN { doc["unsafe getpkt"] = "\
Function that can call longjmp"
    level["unsafe getpkt"] = ari_info
}
/^[^_[:alnum:]]getpkt([^_[:alnum:]]|$)/ {
    fail("unsafe getpkt")
}

BEGIN { doc["readchar"] = "\
Parameterise the remote serial read/write code with the serial device \
being read"
    level["readchar"] = ari_info
}
/(^|[^_[:alnum:]])readchar[[:blank:]]*\(/ {
    fail("readchar")
}

BEGIN { doc["sigsetmask"] = "\
Uses sigsetmask(), instead use sigprocmask()"
    level["sigsetmask"] = ari_code
}
/(^|[^_[:alnum:]])sigsetmask[[:blank:]]*\(/ {
    fail("sigsetmask")
}

BEGIN { doc["bcmp"] = "\
Uses bcmp(), ISO C 90 implies memcmp()"
    level["bcmp"] = ari_regression
}
/(^|[^_[:alnum:]])bcmp[[:blank:]]*\(/ {
    fail("bcmp")
}

BEGIN { doc["bzero"] = "\
Uses bzero(), ISO C 90 implies memset()"
    level["bzero"] = ari_pedantic
}
/(^|[^_[:alnum:]])bzero[[:blank:]]*\(/ {
    fail("bzero")
}

BEGIN { doc["bcopy"] = "\
Uses bcopy(), ISO C 90 implies memcpy() and memmove()"
    level["bcopy"] = ari_pedantic
}
/(^|[^_[:alnum:]])bcopy[[:blank:]]*\(/ {
    fail("bcopy")
}

BEGIN { doc["atoi"] = "\
Uses atoi(), GDB needs a string to LONGEST conversion function.  Something \
like string_to_core_addr() but in the style of strtol().  The latter has \
a habit of accepting dud strings"
    level["atoi"] = ari_info
}
/(^|[^_[:alnum:]])atoi[[:blank:]]*\(/ {
    fail("atoi")
}

BEGIN { doc["strtol"] = "\
GDB needs a string to LONGEST conversion function.  Something like \
string_to_core_addr() but in the style of strtol().  The latter has a habit \
of accepting dud strings"
    level["strtol"] = ari_info
}
/(^|[^_[:alnum:]])strtol[[:blank:]]*\(/ {
    fail("strtol")
}

BEGIN { doc["printf"] = "\
Uses printf(), instead use printf*filtered()"
    level["printf"] = ari_pedantic
}
/(^|[^_[:alnum:]])printf[[:blank:]]*\(/ {
    fail("printf")
}

BEGIN { doc["extract_floating"] = "\
Uses extract_floating(), replaced by extract_typed_floating()"
    level["extract_floating"] = ari_deprecated
    #fix("extract_floating", "gdb/floatformat.c", 1)
}
/(^|[^_[:alnum:]])extract_floating[[:blank:]]*\(/ {
    fail("extract_floating")
}

BEGIN { doc["store_floating"] = "\
Uses store_floating(), replaced by store_typed_floating()"
    level["store_floating"] = ari_deprecated
    #fix("store_floating", "gdb/floatformat.c", 1)
}
/(^|[^_[:alnum:]])store_floating[[:blank:]]*\(/ {
    fail("store_floating")
}

BEGIN { doc["floatformat_to_double"] = "\
Uses floatformat_to_double(), replaced by floatformat_to_doublest()"
    level["floatformat_to_double"] = ari_deprecated
}
/(^|[^_[:alnum:]])floatformat_to_double[[:blank:]]*\(/ {
    fail("floatformat_to_double")
}

BEGIN { doc["floatformat_from_double"] = "\
Uses floatformat_from_double(), replaced by floatformat_from_doublest()"
    level["floatformat_from_double"] = ari_deprecated
}
/(^|[^_[:alnum:]])floatformat_from_double[[:blank:]]*\(/ {
    fail("floatformat_from_double")
}

BEGIN { doc["floatformat_arm_ext"] = "\
Uses floatformat_arm_ext, replaced by floatformat_arm_big and \
floatformat_arm_littlebyte_bigword"
    level["floatformat_arm_ext"] = ari_regression
}
/(^|[^_[:alnum:]])floatformat_arm_ext([^_[:alnum:]]|$)/ {
    fail("floatformat_arm_ext")
}

BEGIN { doc["IEEE_FLOAT"] = "\
Uses IEEE_FLOAT, replaced by DOUBLEST"
    level["IEEE_FLOAT"] = ari_regression
}
/(^|[^_[:alnum:]])IEEE_FLOAT([^_[:alnum:]]|$)/ {
    fail("IEEE_FLOAT")
}

BEGIN { doc["address of builtin_type"] = "\
The builtin_type* defined in \"gdbtypes.h\" are going to be changed to either \
dynamic variables or functions.  Taking their address - as is often done in \
c-lang.c - will no longer be possible";
    level["address of builtin_type"] = ari_pedantic
}
/\&builtin_type/ {
    fail("address of builtin_type")
}

BEGIN { doc["FLOAT_INFO"] = "\
Uses FLOAT_INFO, replaced by PRINT_FLOAT_INFO"
    level["FLOAT_INFO"] = ari_deprecated
}
/(^|[^_[:alnum:]])FLOAT_INFO([^_[:alnum:]]|$)/ {
    fail("FLOAT_INFO")
}

BEGIN { doc["PRINT_REGISTER_HOOK"] = "\
Uses PRINT_REGISTER_HOOK, replaced by PRINT_REGISTERS_INFO"
    level["PRINT_REGISTER_HOOK"] = ari_deprecated
}
/(^|[^_[:alnum:]])PRINT_REGISTER_HOOK([^_[:alnum:]]|$)/ {
    fail("PRINT_REGISTER_HOOK")
}

BEGIN { doc["INVALID_FLOAT"] = "\
Uses INVALID_FLOAT, replaced by nothing"
    level["INVALID_FLOAT"] = ari_regression
    #fix("INVALID_FLOAT", "gdb/vax-tdep.c", 3);
}
/(^|[^_[:alnum:]])INVALID_FLOAT([^_[:alnum:]]|$)/ {
    fail("INVALID_FLOAT")
}

BEGIN { doc["HOST_BYTE_ORDER"] = "\
Uses HOST_BYTE_ORDER, replaced by nothing"
    level["HOST_BYTE_ORDER"] = ari_regression
}
/(^|[^_[:alnum:]])HOST_BYTE_ORDER([^_[:alnum:]]|$)/ {
    fail("HOST_BYTE_ORDER")
}

BEGIN { doc["BIG_ENDIAN"] = "\
Uses BIG_ENDIAN, replaced by BFD_ENDIAN_BIG"
    level["BIG_ENDIAN"] = ari_regression
}
/(^|[^_[:alnum:]])BIG_ENDIAN([^_[:alnum:]]|$)/ {
    fail("BIG_ENDIAN")
}

BEGIN { doc["LITTLE_ENDIAN"] = "\
Uses LITTLE_ENDIAN, replaced by BFD_ENDIAN_LITTLE";
    level["LITTLE_ENDIAN"] = ari_regression
}
/(^|[^_[:alnum:]])LITTLE_ENDIAN([^_[:alnum:]]|$)/ {
    fail("LITTLE_ENDIAN")
}

BEGIN { doc["report_transfer_performance"] = "\
?????";
    level["report_transfer_performance"] = ari_info
}
/(^|[^_[:alnum:]])report_transfer_performance([^_[:alnum:]]|$)/ {
    fail("report_transfer_performance")
}

BEGIN { doc["DECR_PC_AFTER_BREAK"] = "\
I wish this would just go away.  An ISA has one or more hardware registers \
that define a processors current execution point in an instruction stream. \
Sometimes those registers specify the instruction about to be executed \
and sometimes one beyond that.  None of this is of interest to core-gdb. \
Instead the architecture should provide a current instruction address \
method that always returns the address of the instruction about to be \
executed (as determined from the hardware registers)"
    level["DECR_PC_AFTER_BREAK"] = ari_pedantic
}
/(^|[^_[:alnum:]])DECR_PC_AFTER_BREAK([^_[:alnum:]]|$)/ {
    fail("DECR_PC_AFTER_BREAK")
}

BEGIN { doc["USG"] = "\
What does USG even tell us?";
    level["USG"] = ari_info
}
/(^|[^_[:alnum:]])USG([^_[:alnum:]]|$)/ {
    fail("USG")
}

BEGIN { doc["EXTRA_FRAME_INFO"] = "\
Uses EXTRA_FRAME_INFO, replaced by `struct frame_extra_info'\''";
    level["EXTRA_FRAME_INFO"] = ari_deprecated
}
/(^|[^_[:alnum:]])EXTRA_FRAME_INFO([^_[:alnum:]]|$)/ {
    fail("EXTRA_FRAME_INFO")
}

BEGIN { doc["FRAME_FIND_SAVED_REGS"] = "\
Uses FRAME_FIND_SAVED_REGS, replaced by FRAME_INIT_SAVED_REGS"
    level["FRAME_FIND_SAVED_REGS"] = ari_pedantic
}
/(^|[^_[:alnum:]])FRAME_FIND_SAVED_REGS([^_[:alnum:]]|$)/ {
    fail("FRAME_FIND_SAVED_REGS")
}

BEGIN { doc["SIZEOF_FRAME_SAVED_REGS"] = "\
The macro SIZEOF_FRAME_SAVED_REGS typically should not be needed"
    level["SIZEOF_FRAME_SAVED_REGS"] = ari_pedantic
}
/(^|[^_[:alnum:]])SIZEOF_FRAME_SAVED_REGS([^_[:alnum:]]|$)/ {
    fail("SIZEOF_FRAME_SAVED_REGS")
}

BEGIN { doc["strsignal"] = "\
GDB should be using the ABI to convert a signal into a string"
    level["strsignal"] = ari_code
}
/(^|[^_[:alnum:]])strsignal[[:blank:]]*\(/ {
    fail("strsignal")
}

BEGIN { doc["target_signal"] = "\
This is really badly named.  It should be called something like gdb_signal \
as it is GDBs internal representation of the target signal.  It gets worse \
as target_signal_to_host() is actually translating to/from the true target \
signal"
    level["target_signal"] = ari_info
}
/(^|[^_[:alnum:]])target_signal([^_[:alnum:]]|$)/ {
    fail("target_signal")
}

# The register cache and the addition of a frame argument.

BEGIN { doc["registers []"] = "\
Uses registers[], replaced by supply_register() and regcache_collect()";
    level["registers []"] = ari_deprecated
}
/(^|[^_[:alnum:]])registers([^_[:alnum:]]|$)/ && ! /->registers([^_[:alnum:]]|$)/ {
    fail("registers []")
}

BEGIN { doc["register_valid []"] = "\
Uses register_valid[], replaced by supply_register() and \
regcache_collect()"
    level["register_valid []"] = ari_deprecated
}
/(^|[^_[:alnum:]])register_valid([^_[:alnum:]]|$)/ {
    fail("register_valid []")
}

BEGIN { doc["read_register_gen in nat"] = "\
Native code should fetch values from the cache using \
regcache_collect()"
    level["read_register_gen in target"] = ari_deprecated
}
/(^|[^_[:alnum:]])read_register_gen([^_[:alnum:]]|$)/ && FILENAME ~ /.*-nat\.c/ {
    fail("read_register_gen in target")
}

BEGIN { doc["read_register_bytes"] = "\
Uses read_register_bytes(), replaced by regcache_cooked_read()"
    level["read_register_bytes"] = ari_deprecated
}
/(^|[^_[:alnum:]])read_register_bytes[[:blank:]]*\(/ {
    fail("read_register_bytes")
}

BEGIN { doc["write_register_bytes"] = "\
Uses write_register_bytes(), replaced by regcache_cooked_write()"
    level["write_register_bytes"] = ari_deprecated
}
/(^|[^_[:alnum:]])write_register_bytes[[:blank:]]*\(/ {
    fail("write_register_bytes")
}

BEGIN { doc["registers_fetched"] = "\
Uses registers_fetched(), replaced by supply_register()";
    level["registers_fetched"] = ari_deprecated
}
/(^|[^_[:alnum:]])registers_fetched[[:blank:]]*\(/ {
    fail("registers_fetched")
}

BEGIN { doc["generic_get_saved_register"] = "\
Uses generic_get_saved_register(), replaced by \
generic_unwind_get_saved_register() (which really should be made the \
default)"
    level["generic_get_saved_register"] = ari_deprecated
}
/(^|[^_[:alnum:]])generic_get_saved_register[[:blank:]]*\(/ {
    fail("generic_get_saved_register")
}

# BEGIN { doc["DEPRECATED"] = "\
# Uses the deprecated function or macro"
#     level["DEPRECATED"] = ari_deprecated
# }
/(^|[^_[:alnum:]])(DEPRECATED_|deprecated_)/ {
    # Nasty, pull the deprecated function name out
    name = gensub(/^.*((DEPRECATED_|deprecated_)[_[:alnum:]]*).*$/, "\\1", 1)
    doc[name] = "Uses `" name "'\'', see declaration for details"
    level[name] = ari_deprecated
    fail(name)
}

BEGIN { doc["REGISTER_NAME_ALIAS_HOOK"] = "\
Uses REGISTER_NAME_ALIAS_HOOK(), replaced by nothing"
    level["REGISTER_NAME_ALIAS_HOOK"] = ari_regression
}
/(^|[^_[:alnum:]])REGISTER_NAME_ALIAS_HOOK[[:blank:]]*\(/ \
|| /(^|[^_[:alnum:]])REGISTER_NAME_ALIAS_HOOK[[:blank:]]*\(/ {
    fail("REGISTER_NAME_ALIAS_HOOK")
}

BEGIN { doc["STORE_PSEUDO_REGISTER"] = "\
Uses STORE_PSEUDO_REGISTER(), replaced by gdbarch_register_write()"
    level["STORE_PSEUDO_REGISTER"] = ari_regression
}
/(^|[^_[:alnum:]])STORE_PSEUDO_REGISTER[[:blank:]]*\(/ \
|| /(^|[^_[:alnum:]])set_gdbarch_store_pseudo_register[[:blank:]]*\(/ {
    fail("STORE_PSEUDO_REGISTER")
}

BEGIN { doc["FETCH_PSEUDO_REGISTER"] = "\
Uses FETCH_PSEUDO_REGISTER(), replaced by gdbarch_register_read()"
    level["FETCH_PSEUDO_REGISTER"] = ari_regression
}
/(^|[^_[:alnum:]])FETCH_PSEUDO_REGISTER[[:blank:]]*\(/ || \
/(^|[^_[:alnum:]])set_gdbarch_fetch_pseudo_register[[:blank:]]*\(/ {
    fail("FETCH_PSEUDO_REGISTER")
}

BEGIN { doc["IS_TRAPPED_INTERNALVAR"] = "\
Uses IS_TRAPPED_INTERNALVAR(), replaced by gdbarch_register_read()"
    level["IS_TRAPPED_INTERNALVAR"] = ari_deprecated
}
/(^|[^_[:alnum:]])IS_TRAPPED_INTERNALVAR[[:blank:]]*\(/ {
    fail("IS_TRAPPED_INTERNALVAR")
}

BEGIN { doc["REGISTER_BYTE"] = "\
REGISTER_BYTE and its co-conspirator, registers[] should both be deleted.  \
The successor, computed at run-time, should be local to regcache.c"
    level["REGISTER_BYTE"] = ari_pedantic
}
/(^|[^_[:alnum:]])REGISTER_BYTE[[:blank:]]*\(/ {
    fail("REGISTER_BYTE")
}

BEGIN { doc["REGISTER_BYTES"] = "\
REGISTER_BYTES the size of the regcache can be computed at run time"
    level["REGISTER_BYTES"] = ari_pedantic
}
/(^|[^_[:alnum:]])REGISTER_BYTES[[:blank:]]*\(/ {
    fail("REGISTER_BYTES")
}

BEGIN { doc["REGISTER_VIRTUAL_TYPE"] = "\
Uses REGISTER_VIRTUAL_TYPE(), replaced by register_type(gdbarch,regnum)"
    level["REGISTER_VIRTUAL_TYPE"] = ari_pedantic
}
/(^|[^_[:alnum:]])REGISTER_VIRTUAL_TYPE[[:blank:]]*\(/ {
    fail("REGISTER_VIRTUAL_TYPE")
}

BEGIN { doc["REGISTER_{RAW,VIRTUAL}_SIZE"] = "\
The methods REGISTER_RAW_SIZE() and REGISTER_VIRTUAL_SIZE() have been \
replaced by the function register_size(gdbarch,regnum)"
    level["REGISTER_{RAW,VIRTUAL}_SIZE"] = ari_pedantic
}
/(^|[^_[:alnum:]])REGISTER_RAW_SIZE[[:blank:]]*\(/ || \
/(^|[^_[:alnum:]])REGISTER_VIRTUAL_SIZE[[:blank:]]*\(/ {
    fail("REGISTER_{RAW,VIRTUAL}_SIZE")
}

BEGIN { doc["MAX_REGISTER_{RAW,VIRTUAL}_SIZE"] = "\
The methods MAX_REGISTER_RAW_SIZE and MAX_REGISTER_VIRTUAL_SIZE have been \
replaced by the function max_register_size(gdbarch,regnum)"
    level["MAX_REGISTER_{RAW,VIRTUAL}_SIZE"] = ari_pedantic
}
/(^|[^_[:alnum:]])MAX_REGISTER_RAW_SIZE([^_[:alnum:]]|$)/ || \
/(^|[^_[:alnum:]])MAX_REGISTER_VIRTUAL_SIZE([^_[:alnum:]]|$)/ {
    fail("MAX_REGISTER_{RAW,VIRTUAL}_SIZE")
}

BEGIN { doc["[MAX_REGISTER_{RAW,VIRTUAL}_SIZE]"] = "\
MAX_REGISTER_{RAW,VIRTUAL}_SIZE is a function and, hence, can not be \
used to specify the size of an array"
    level["[MAX_REGISTER_{RAW,VIRTUAL}_SIZE]"] = ari_code
}
/\[[[:blank:]]*MAX_REGISTER_RAW_SIZE[[:blank:]]*\]/ || \
/\[[[:blank:]]*MAX_REGISTER_VIRTUAL_SIZE[[:blank:]]*\]/ {
    fail("[MAX_REGISTER_{RAW,VIRTUAL}_SIZE]")
}

BEGIN { doc["DO_REGISTERS_INFO"] = "\
Uses DO_REGISTERS_INFO(), replaced by FRAME_REGISTERS_INFO"
    level["DO_REGISTERS_INFO"] = ari_pedantic
}
/(^|[^_[:alnum:]])DO_REGISTERS_INFO[[:blank:]]*\(/ {
    fail("DO_REGISTERS_INFO")
}

BEGIN { doc["REGISTER_CONVERTIBLE"] = "\
REGISTER_CONVERTIBLE() has overloaded semantics"
    level["REGISTER_CONVERTIBLE"] = ari_pedantic
}
/(^|[^_[:alnum:]])REGISTER_CONVERTIBLE[[:blank:]]*\(/ {
    fail("REGISTER_CONVERTIBLE")
}

BEGIN { doc["REGISTER_CONVERT_TO_RAW"] = "\
REGISTER_CONVERT_TO_RAW() has overloaded semantics"
    level["REGISTER_CONVERT_TO_RAW"] = ari_pedantic
}
/(^|[^_[:alnum:]])REGISTER_CONVERT_TO_RAW[[:blank:]]*\(/ {
    fail("REGISTER_CONVERT_TO_RAW")
}

BEGIN { doc["REGISTER_CONVERT_TO_VIRTUAL"] = "\
REGISTER_CONVERT_TO_VIRTUAL() has overloaded semantics"
    level["REGISTER_CONVERT_TO_VIRTUAL"] = ari_pedantic
}
/(^|[^_[:alnum:]])REGISTER_CONVERT_TO_VIRTUAL[[:blank:]]*\(/ {
    fail("REGISTER_CONVERT_TO_VIRTUAL")
}

# The totally dreaded FP REGNUM code.

BEGIN { doc["FP_REGNUM"] = "\
FP_REGNUM() is going to be deleted"
    level["FP_REGNUM"] = ari_info
}
/(^|[^_[:alnum:]])FP_REGNUM[[:blank:]]*\(/ {
    fail("FP_REGNUM")
}

BEGIN { doc["TARGET_WRITE_FP"] = "\
TARGET_WRITE_FP() has been deleted"
    level["TARGET_WRITE_FP"] = ari_regression
}
/(^|[^_[:alnum:]])TARGET_WRITE_FP[[:blank:]]*\(/ {
    fail("TARGET_WRITE_FP")
}

BEGIN { doc["write_fp"] = "\
write_fp() has been deleted"
    level["write_fp"] = ari_regression
}
/(^|[^_[:alnum:]])write_fp[[:blank:]]*\(/ {
    fail("write_fp")
}

BEGIN { doc["TARGET_READ_FP"] = "\
TARGET_READ_FP() might be deleted"
    level["TARGET_READ_FP"] = ari_info
}
/(^|[^_[:alnum:]])TARGET_READ_FP[[:blank:]]*\(/ {
    fail("TARGET_READ_FP")
}

BEGIN { doc["read_fp"] = "\
read_fp() might be deleted"
    level["read_fp"] = ari_info
}
/(^|[^_[:alnum:]])read_fp[[:blank:]]*\(/ {
    fail("read_fp")
}

# Print functions: Use versions that either check for buffer overflow
# or safely allocate a fresh buffer.

BEGIN { doc["sprintf"] = "\
Uses sprintf(), instead use xasprintf() or snprintf()"
    level["sprintf"] = ari_pedantic
}
/(^|[^_[:alnum:]])sprintf[[:blank:]]*\(/ {
    fail("sprintf")
}

BEGIN { doc["vsprint"] = "\
Uses vsprint(), instead use xvasprint() or vsnprintf()"
    level["vsprint"] = ari_regression
}
/(^|[^_[:alnum:]])vsprint[[:blank:]]*\(/ {
    fail("vsprint")
}

BEGIN { doc["asprintf"] = "\
Uses asprintf(), instead use xasprintf()"
    level["asprintf"] = ari_regression
}
/(^|[^_[:alnum:]])asprintf[[:blank:]]*\(/ {
    fail("asprintf")
}

BEGIN { doc["vasprintf"] = "\
Uses vasprintf(), instead use xvasprintf()"
    #fix("vasprintf", "gdb/utils.c", 1)
    level["vasprintf"] = ari_regression
}
/(^|[^_[:alnum:]])vasprintf[[:blank:]]*\(/ {
    fail("vasprintf")
}

# Memory allocation: malloc(): Use versions that check for NULL memory
# buffers.  gdb/utils.c contains wrappers that call the underlying
# functions.

BEGIN { doc["malloc"] = "\
Uses malloc(), instead use xmalloc()";
    level["malloc"] = ari_regression;
    #fix("malloc", "gdb/utils.c", 2); # decl, use
}
/(^|[^_[:alnum:]])malloc[[:blank:]]*\(/ {
    fail("malloc")
}

BEGIN { doc["calloc"] = "\
Uses calloc(), instead use xcalloc()";
    level["calloc"] = ari_regression;
    #fix("calloc", "gdb/utils.c", 1);
}
/(^|[^_[:alnum:]])calloc[[:blank:]]*\(/ {
    fail("calloc")
}

BEGIN { doc["realloc"] = "\
Uses realloc(), instead use xrealloc()"
    level["realloc"] = ari_regression;
    #fix("realloc", "gdb/utils.c", 2); # decl, use
}
/(^|[^_[:alnum:]])realloc[[:blank:]]*\(/ {
    fail("realloc")
}

BEGIN { doc["free"] = "\
Uses free(), instead use xfree() (xfree() can handle NULL)"
    level["free"] = ari_regression;
    #fix("free", "gdb/utils.c", 2); # decl, use
}
/(^|[^_[:alnum:]>\.])free[[:blank:]]*\(/ {
    fail("free")
}

# Memory allocation: mmalloc(): Use versions that check for NULL memory
# buffers.  gdb/utils.c contains wrappers that call the underlying
# functions.

BEGIN { doc["mmalloc"] = "\
Uses mmalloc(), instead use xmmalloc()";
    level["mmalloc"] = ari_regression
    #fix("mmalloc", "gdb/utils.c", 4);
}
/(^|[^_[:alnum:]])mmalloc[[:blank:]]*\(/ {
    fail("mmalloc")
}

BEGIN { doc["mcalloc"] = "\
Uses mcalloc(), instead use xmcalloc()";
    level["mcalloc"] = ari_regression
    #fix("mcalloc", "gdb/utils.c", 2);
}
/(^|[^_[:alnum:]])mcalloc[[:blank:]]*\(/ {
    fail("mcalloc")
}

BEGIN { doc["mrealloc"] = "\
Uses mrealloc(), instead use xmrealloc()";
    level["mrealloc"] = ari_regression
    #fix("mrealloc", "gdb/utils.c", 2);
}
/(^|[^_[:alnum:]])mrealloc[[:blank:]]*\(/ {
    fail("mrealloc")
}

BEGIN { doc["mfree"] = "\
Uses mfree(), instead use xmfree()";
    level["mfree"] = ari_regression
    #fix("mfree", "gdb/utils.c", 3);
}
/(^|[^_[:alnum:]>\.])mfree[[:blank:]]*\(/ {
    fail("mfree")
}

# Memory allocation: xmmalloc(): We are trying to eliminate these
# versions and just use simple xmalloc() and obstacks.

BEGIN { doc["xmmalloc"] = "\
GDB is trying to elminate the [x]mmalloc() family"
    level["xmmalloc"] = ari_info
}
/(^|[^_[:alnum:]])xmmalloc[[:blank:]]*\(/ {
    fail("xmmalloc")
}

BEGIN { doc["xmcalloc"] = "\
GDB is trying to elminate the [x]mmalloc() family"
    level["xmcalloc"] = ari_info
}
/(^|[^_[:alnum:]])xmcalloc[[:blank:]]*\(/ {
    fail("xmcalloc")
}

BEGIN { doc["xmrealloc"] = "\
GDB is trying to elminate the [x]mmalloc() family"
    level["xmrealloc"] = ari_info
}
/(^|[^_[:alnum:]])xmrealloc[[:blank:]]*\(/ {
    fail("xmrealloc")
}

BEGIN { doc["xmfree"] = "\
GDB is trying to elminate the [x]mmalloc() family"
    level["xmfree"] = ari_info
}
/(^|[^_[:alnum:]>\.])xmfree[[:blank:]]*\(/ {
    fail("xmfree")
}

# More generic memory operations

BEGIN { doc["FREEIF"] = "\
Uses FREEIF(), instead use xfree() (xfree() handles NULL)"
    level["FREEIF"] = ari_regression
}
/(^|[^_[:alnum:]])FREEIF[[:blank:]]*\(/ {
    fail("FREEIF")
}

BEGIN { doc["MALLOC_INCOMPATIBLE"] = "\
MALLOC_INCOMPATIBLE should be handled by autoconf"
    level["MALLOC_INCOMPATIBLE"] = ari_regression
}
/(^|[^_[:alnum:]])MALLOC_INCOMPATIBLE([^_[:alnum:]]|$)/ {
    fail("MALLOC_INCOMPATIBLE")
}

BEGIN { doc["strdup"] = "\
Uses strdup(), instead use xstrdup()";
    level["strdup"] = ari_regression
}
/(^|[^_[:alnum:]])strdup[[:blank:]]*\(/ {
    fail("strdup")
}

BEGIN { doc["strsave"] = "\
Uses strsave(), instead use xstrdup() et.al."
    level["strsave"] = ari_regression
}
/(^|[^_[:alnum:]])strsave[[:blank:]]*\(/ {
    fail("strsave")
}

BEGIN { doc["savestring"] = "\
savestring() needs a rethink, should there be a xstrldup() (???)"
    level["savestring"] = ari_info
}
/(^|[^_[:alnum:]])savestring[[:blank:]]*\(/ {
    fail("savestring")
}

BEGIN { doc["alloca"] = "\
Uses alloca(), alloca() is non-portable but its use is tolerated";
    level["alloca"] = ari_info
}
/(^|[^_[:alnum:]])alloca[[:blank:]]*\(/ {
    fail("alloca")
}

# String compare functions

BEGIN { doc["STREQ"] = "\
Uses STREQ(), replaced by `strcmp (...) == 0'\''"
    level["STREQ"] = ari_code
}
/(^|[^_[:alnum:]])STREQ[[:blank:]]*\(/ {
    fail("STREQ")
}

BEGIN { doc["STRCMP"] = "\
Uses `STRCMP(), replaced by `strcmp (...) == 0'\''"
    level["STRCMP"] = ari_regression
}
/(^|[^_[:alnum:]])STRCMP[[:blank:]]*\(/ {
    fail("STRCMP")
}

BEGIN { doc["STREQN"] = "\
Uses `STREQN(), replaced by `strcmp (...) != 0'\''"
    level["STREQN"] = ari_code
}
/(^|[^_[:alnum:]])STREQN[[:blank:]]*\(/ {
    fail("STREQN")
}

BEGIN { doc["strncpy"] = "\
Should GDB use strlcpy() instead of strncpy()?";
    level["strncpy"] = ari_info
}
/(^|[^_[:alnum:]])strncpy[[:blank:]]*\(/ {
    fail("strncpy")
}

BEGIN { doc["!strcmp"] = "\
Use `strcmp() == 0'\'' rather than `!strcmp() (The statement \
`string-compare a, b, equal'\'' is easier to read than the backward \
logic of `Not string-compare a, b'\'')"
    level["!strcmp"] = ari_info
}
/\![[:blank:]]*str/ {
    fail("!strcmp")
}

BEGIN { doc["strnicmp"] = "\
Uses strnicmp(), instead use strncasecmp()"
    level["strnicmp"] = ari_regression
}
/(^|[^_[:alnum:]])strnicmp[[:blank:]]*\(/ {
    fail("strnicmp")
}

# Boolean expressions and conditionals

BEGIN { doc["FALSE"] = "\
Definitely do not use FALSE in boolean expressions"
    level["FALSE"] = ari_pedantic
}
/(^|[^_[:alnum:]])FALSE([^_[:alnum:]]|$)/ {
    fail("FALSE")
}

BEGIN { doc["TRUE"] = "\
Do not try to use TRUE in boolean expressions"
    level["TRUE"] = ari_pedantic
}
/(^|[^_[:alnum:]])TRUE([^_[:alnum:]]|$)/ {
    fail("TRUE")
}

BEGIN { doc["false"] = "\
Definitely do not use `false'\'' in boolean expressions"
    level["false"] = ari_regression
}
/(^|[^_[:alnum:]])false([^_[:alnum:]]|$)/ {
    fail("false")
}

BEGIN { doc["true"] = "\
Do not try to use `true'\'' in boolean expressions"
    level["true"] = ari_regression
}
/(^|[^_[:alnum:]])true([^_[:alnum:]]|$)/ {
    fail("true")
}

BEGIN { doc["if assignment"] = "\
An IF statement'\''s expression contains an assignment (the GNU coding \
standard discourages this)"
    level["if assignment"] = ari_code
}
/ if .* = / {
    fail("if assignment")
}

# Typedefs that are either redundant or can be reduced to `struct
# type *''.

BEGIN { doc["GDB_FILE"] = "\
Uses GDB_FILE, replaced by `struct ui_file'\''";
    level["GDB_FILE"] = ari_regression
}
/(^|[^_[:alnum:]])GDB_FILE([^_[:alnum:]]|$)/ {
    fail("GDB_FILE")
}

BEGIN { doc["struct complaint"] = "\
Uses `struct complaint'\'', replaced by complaint()"
    level["struct complaint"] = ari_deprecated
}
/(^|[^_[:alnum:]])struct complaint([^_[:alnum:]]|$)/ {
    fail("struct complaint")
}

BEGIN { doc["complain"] = "\
Uses `complain(), replaced by complaint()"
    level["complain"] = ari_deprecated
}
/(^|[^_[:alnum:]])complain[[:space:]]*\(/ {
    fail("complain")
}

BEGIN { doc["serial_t"] = "\
Uses `serial_t'\'', replaced by `struct serial'\''"
    level["serial_t"] = ari_regression
}
/(^|[^_[:alnum:]])serial_t([^_[:alnum:]]|$)/ {
    fail("serial_t")
}

BEGIN { doc["value_ptr"] = "\
Uses `value_ptr'\'', replaced by `struct value *'\''"
    level["value_ptr"] = ari_regression
}
/(^|[^_[:alnum:]])value_ptr([^_[:alnum:]]|$)/ {
    fail("value_ptr")
}

BEGIN { doc["tm_print_insn"] = "\
Uses `tm_print_insn'\'', replaced by multi-arched"
    level["tm_print_insn"] = ari_deprecated
}
/tm_print_insn[[:space:]]*=/ {
    fail("tm_print_insn")
}

BEGIN { doc["goto"] = "\
Please do not use `goto'\''"
    level["goto"] = ari_info
}
/(^|[^_[:alnum:]])goto([^_[:alnum:]]|$)/ {
    fail("goto")
}

BEGIN { doc["label"] = "\
Please do not use labels"
    level["label"] = ari_info
}
/^[[:space:]]*[[:alpha:]_][[:alnum:]_]*[[:space:]]*:/ \
    && ! /^[[:space:]]*default[[:space:]]*:/ {
    fail("label")
}

BEGIN { doc["codestream"] = "\
Several targets contain a codestream - aka instruction cache.  More than \
anything is is probably caused by the broken target stack.  New targets \
should not clone this.  Existing targets should have it removed"
    level["codestream"] = ari_pedantic
}
/codestream/ {
    fail("codestream")
}

BEGIN { doc["wrap_"] = "\
Several targets are using a wrapper function found in wrapper.c. \
Unfortunatly, they are hard to debug and contain a bad cast"
    level["wrap_"] = ari_info
}
/wrap_/ {
    fail("wrap_")
}

BEGIN { doc["var_auto_boolean"] = "\
Use the function add_setshow_auto_boolean_cmd() instead of var_auto_boolean"
    #fix("var_auto_boolean", "gdb/cli/cli-decode.c", 1)
    #fix("var_auto_boolean", "gdb/cli/cli-decode.h", 1)
    #fix("var_auto_boolean", "gdb/cli/cli-setshow.c", 2)
    #fix("var_auto_boolean", "gdb/command.h", 1)
    level["var_auto_boolean"] = ari_regression
}
/(^|[^_[:alnum:]])var_auto_boolean([^_[:alnum:]]|$)/ {
    fail("var_auto_boolean")
}

BEGIN { doc["var_boolean"] = "\
Uses var_boolean, replaced by add_setshow_boolean_cmd()"
    level["var_boolean"] = ari_pedantic
}
/(^|[^_[:alnum:]])var_boolean([^_[:alnum:]]|$)/ {
    fail("var_boolean")
}

BEGIN { doc["add_show_from_set"] = "\
Uses add_show_from_set(), instead use add_setshow...() (add_show_from_set() \
is very I18N unfriendly - see PR gdb/434)"
    level["add_show_from_set"] = ari_pedantic
}
/(^|[^_[:alnum:]])add_show_from_set([^_[:alnum:]]|$)/ {
    fail("add_show_from_set")
}
' "$@"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]