GDB Testsuite Coding Standards

The GDB testsuite has historically had fewer rules than GDB itself. This has led to several "styles".

Plus there are occasions when a particular style is required by the test. GDB has to debug all different styles of code, and style can and has affected the debugging experience. The author recalls an issue regarding whether the opening { of a function is placed on the same line as the function name or on the next line.

The best guidance one can give is that unless a test requires a particular style (which is rare) you can't go wrong following the GDB coding standards. Failing that, cut-n-pasting from existing tests is typically OK, but see the rules below.

Rules For New Tests

Setting aside the various "styles" that appear in existing tests, there are a few (well, as of this writing one :-) ) rules for new tests.

In C code, don't use K&R function definitions

For example, write this

void
foo (void)
{
  /* blah */
}

Not this:

void
foo ()
{
  /* blah */
}

All content (C) 2008 Free Software Foundation. For terms of use, redistribution, and modification, please see the WikiLicense page.