Commit Graph

16 Commits (b21dddb9dfe50ca1e205faf4b25900895494d25b)

Author SHA1 Message Date
Paul Gortmaker eb12a679b2 drivers/misc: Add module.h to files who are really modular.
These files really need the full module.h header file present, but
were just getting it implicitly before.  Fix it up in advance so we
avoid build failures once the cleanup commit is present.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2011-10-31 19:31:53 -04:00
Mike Frysinger 603d04b201 kgdbts: only use new asm-generic/ptrace.h api when needed
The new instruction_pointer_set helper is defined for people who have
converted to asm-generic/ptrace.h, so don't use it generally unless
the arch needs it (in which case it has been converted).  This should
fix building of kgdb tests for arches not yet converted.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Acked-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-06-01 16:35:01 +09:00
Mike Frysinger 63ab25ebbc kgdbts: unify/generalize gdb breakpoint adjustment
The Blackfin arch, like the x86 arch, needs to adjust the PC manually
after a breakpoint is hit as normally this is handled by the remote gdb.
However, rather than starting another arch ifdef mess, create a common
GDB_ADJUSTS_BREAK_OFFSET define for any arch to opt-in via their kgdb.h.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Acked-by: Dongdong Deng <dongdong.deng@windriver.com>
Cc: Sergei Shtylyov <sshtylyov@mvista.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-05-26 17:12:36 -07:00
Lucas De Marchi 25985edced Fix common misspellings
Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
2011-03-31 11:26:23 -03:00
Dan Carpenter adb4b83c12 kgdboc,kgdbts: strlen() doesn't count the terminator
This is an off by one because strlen() doesn't count the null
terminator.  We strcpy() these strings into an array of size
MAX_CONFIG_LEN.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
2011-03-25 16:37:30 -05:00
Dongdong Deng 4dacd5c073 kgdbts: prevent re-entry to kgdbts before it unregisters
The "kgdb_connected" variable of debug_core just indicates whether or
not kgdbts is connected to the debug_core.  It does not completely
prevent a script from trying invoke kgdbts again and possibly crashing
the system (see Call Trace below).

The configured variable in kgtbts can be used instead of
kgdb_connected instead of kgdb_connected. The cleanup_kgdbts() can
also be removed because there is no possible way to build kgdbts as a
kernel module that you could unload with rmmod.

Call Trace:
-----------------------------------------------------------------
root:/$ echo kgdbts=V1S1000 > /sys/module/kgdbts/parameters/kgdbts
kgdb: Unregistered I/O driver kgdbts, debugger disabled.
------------[ cut here ]------------
WARNING: at kernel/debug/debug_core.c:1002
kgdb_unregister_io_module+0xec/0x100()
Hardware name: Moon Creek platform
Modules linked in:
Pid: 664, comm: sh Not tainted 2.6.34.1-WR4.0.0.0_standard #58
Call Trace:
 [<c103b1ed>] warn_slowpath_common+0x6d/0xa0
 [<c1079fdc>] ? kgdb_unregister_io_module+0xec/0x100
 [<c1079fdc>] ? kgdb_unregister_io_module+0xec/0x100
 [<c10544e0>] ? param_attr_store+0x0/0x20
 [<c103b235>] warn_slowpath_null+0x15/0x20
 [<c1079fdc>] kgdb_unregister_io_module+0xec/0x100
 [<c124e4ea>] cleanup_kgdbts+0x1a/0x20
 [<c124eced>] param_set_kgdbts_var+0x6d/0xb0
 [<c124ec80>] ? param_set_kgdbts_var+0x0/0xb0
 [<c10544f7>] param_attr_store+0x17/0x20
 [<c105457c>] module_attr_store+0x2c/0x40
 [<c111fe84>] sysfs_write_file+0x94/0xf0
 [<c10d42f6>] vfs_write+0x96/0x130
 [<c111fdf0>] ? sysfs_write_file+0x0/0xf0
 [<c10d44d6>] sys_write+0x46/0xd0
 [<c13bf329>] system_call_done+0x0/0x4
---[ end trace 4eb028c6ee43154c ]---
kgdb: Unregistered I/O driver kgdbts, debugger disabled.
-----------------------------------------------------------------

[jason.wessel@windriver.com: remove cleanup_kgdbts() ]
Signed-off-by: Dongdong Deng <dongdong.deng@windriver.com>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
2010-10-29 13:14:41 -05:00
Jason Wessel cad08acebf kgdbts,sh: Add in breakpoint pc offset for superh
The kgdb test suite mimics the behavior of gdb.  For the sh
architecture the pc must be decremented by 2 for software breakpoint.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
2010-04-02 14:58:17 -05:00
Geert Uytterhoeven 59d309f9c8 kgdb: Replace strstr() by strchr() for single-character needles
Some versions of gcc replace calls to strstr() with single-character
"needle" string parameters by calls to strchr() behind our back.
This causes linking errors if strchr() is defined as an inline function
in <asm/string.h> (e.g. on m68k, which BTW doesn't have kgdb support).

Prevent this by explicitly calling strchr() instead.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
2009-12-11 08:43:15 -06:00
Roel Kluin b4f1b67be9 kgdbts: Read buffer overflow
Prevent write to put_buf[BUFMAX] in kgdb test suite.

If put_buf_cnt was BUFMAX - 1 at the earlier test,
`\0' is written to put_buf[BUFMAX].

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
2009-12-11 08:43:15 -06:00
Jason Wessel b33cb815b5 kgdbts: Use HW breakpoints with CONFIG_DEBUG_RODATA
Whenever CONFIG_DEBUG_RODATA is set in the kernel config many kernel
text sections become read-only, and the use of software breakpoints in
the kgdb tests will cause the kernel to fail to complete the start up.

Until such time that there is an official API for modifying read-only
text sections hardware breakpoints must be used to run the do_fork or
sys_open tests or the tests get skipped.

Also fix the duplicated include reported by:
Huang Weiyi <weiyi.huang@gmail.com>

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
2008-05-28 12:49:57 -05:00
Harvey Harrison 827e609b45 kgdb: use common ascii helpers and put_unaligned_be32 helper
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
2008-05-28 12:49:56 -05:00
Jason Wessel 7cfcd985d3 kgdb: 1000 loops for the single step test in kgdbts
The single step test is not terribly costly and it should be able to
pass at 1000 loops successfully in under 1 second.  A non-kgdb timing
regression was found using this test, but it did not occur frequently
because by default the test was only executed a single time.

This patch changes the default for the single step test to 1000
iterations and allows for individual configuration of the single step
test to further exercise the kgdb subsystem when needed.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
2008-05-05 07:13:21 -05:00
Harvey Harrison 001fddf5fd kgdb: trivial sparse fixes in kgdb test-suite
Shadowed variable and integer as NULL pointer fixes:
drivers/misc/kgdbts.c:877:6: warning: symbol 'sys_open_test' shadows an earlier one
drivers/misc/kgdbts.c:537:27: originally declared here
drivers/misc/kgdbts.c:378:22: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:386:22: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:468:30: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:472:15: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:502:30: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:506:30: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:509:30: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:523:20: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:527:20: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:530:15: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:541:21: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:545:21: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:548:15: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:559:30: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:563:15: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:573:16: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:574:19: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:578:15: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:588:16: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:589:19: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:593:15: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:602:16: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:604:15: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:925:3: warning: Using plain integer as NULL pointer
drivers/misc/kgdbts.c:938:3: warning: Using plain integer as NULL pointer

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
2008-05-05 07:13:21 -05:00
David S. Miller 4d7ffa4990 kgdbts: Sparc needs sstep emulation.
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-04-29 01:36:14 -07:00
Jason Wessel 974460c5bf kgdb: allow static kgdbts boot configuration
This patch adds in the ability to compile the kgdb internal test
string into the kernel so as to run the tests at boot without changing
the kernel boot arguments.  This patch also changes all the error
paths to invoke WARN_ON(1) which will emit the line number of the file
and dump the kernel stack when an error occurs.

You can disable the tests in a kernel that is built this way
using "kgdbts="

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-04-17 20:05:43 +02:00
Jason Wessel e8d31c204e kgdb: add kgdb internal test suite
This patch adds regression tests for testing the kgdb core and arch
specific implementation.

The kgdb test suite is designed to be built into the kernel and not as
a module because it uses a number of low level kernel and kgdb
primitives which should not be exported externally.

The kgdb test suite is designed as a KGDB I/O module which
simulates the communications that a debugger would have with kgdb.
The tests are broken up in to a line by line and referenced here as
a "get" which is kgdb requesting input and "put" which is kgdb
sending a response.

The kgdb suite can be invoked from the kernel command line
arguments system or executed dynamically at run time.  The test
suite uses the variable "kgdbts" to obtain the information about
which tests to run and to configure the verbosity level.  The
following are the various characters you can use with the kgdbts=
line:

When using the "kgdbts=" you only choose one of the following core
test types:
A = Run all the core tests silently
V1 = Run all the core tests with minimal output
V2 = Run all the core tests in debug mode

You can also specify optional tests:
N## = Go to sleep with interrupts of for ## seconds
      to test the HW NMI watchdog
F## = Break at do_fork for ## iterations
S## = Break at sys_open for ## iterations

NOTE: that the do_fork and sys_open tests are mutually exclusive.

To invoke the kgdb test suite from boot you use a kernel start
argument as follows:
	kgdbts=V1 kgdbwait
Or if you wanted to perform the NMI test for 6 seconds and do_fork
test for 100 forks, you could use:
	kgdbts=V1N6F100 kgdbwait

The test suite can also be invoked at run time with:
echo kgdbts=V1N6F100 > /sys/module/kgdbts/parameters/kgdbts
Or as another example:
echo kgdbts=V2 > /sys/module/kgdbts/parameters/kgdbts

When developing a new kgdb arch specific implementation or
using these tests for the purpose of regression testing,
several invocations are required.

1) Boot with the test suite enabled by using the kernel arguments
      "kgdbts=V1F100 kgdbwait"
   ## If kgdb arch specific implementation has NMI use
      "kgdbts=V1N6F100

2) After the system boot run the basic test.
echo kgdbts=V1 > /sys/module/kgdbts/parameters/kgdbts

3) Run the concurrency tests.  It is best to use n+1
   while loops where n is the number of cpus you have
   in your system.  The example below uses only two
   loops.

## This tests break points on sys_open
while [ 1 ] ; do find / > /dev/null 2>&1 ; done &
while [ 1 ] ; do find / > /dev/null 2>&1 ; done &
echo kgdbts=V1S10000 > /sys/module/kgdbts/parameters/kgdbts
fg # and hit control-c
fg # and hit control-c
## This tests break points on do_fork
while [ 1 ] ; do date > /dev/null ; done &
while [ 1 ] ; do date > /dev/null ; done &
echo kgdbts=V1F1000 > /sys/module/kgdbts/parameters/kgdbts
fg # and hit control-c

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-04-17 20:05:42 +02:00