Re: [PATCH 2.6.27-rc1 2/25] mdb: Merkey's Kernel Debugger 2.6.27-rc1

From: Stefan Richter
Date: Mon Aug 04 2008 - 10:12:26 EST


jmerkey@xxxxxxxxxxxxxxxxxxxxx wrote:
> Netware style debugger for Linux written by Jeffrey Vernon Merkey
>
> --- a/arch/x86/kernel/traps_32.c 2008-08-03 16:09:54.000000000 -0600
> +++ b/arch/x86/kernel/traps_32.c 2008-08-03 17:33:06.000000000 -0600
...
> @@ -865,6 +896,16 @@
> }
> #endif
>
> +#if defined(CONFIG_MDB) && !defined(CONFIG_KPROBES)
> +fastcall void do_int3(struct pt_regs * regs, long error_code)
> +{
> +#ifdef CONFIG_MDB
> + if (mdb(BREAKPOINT_EXCEPTION, error_code, regs))
> + return;
> +#endif
> + do_trap(3, SIGTRAP, "int3", 1, regs, error_code, NULL);
> +}
> +#endif /* CONFIG_KDB && !CONFIG_KPROBES */

The inner #ifdef is always true.


> /*
> * Our handling of the processor debug registers is non-trivial.
> * We do not clear them on entry and exit from the kernel. Therefore
> @@ -895,6 +936,10 @@
> trace_hardirqs_fixup();
>
> get_debugreg(condition, 6);
> +#ifdef CONFIG_MDB
> + if (mdb(DEBUGGER_EXCEPTION, error_code, regs))
> + return;
> +#endif
>
> /*
> * The processor cleared BTF, so don't mark that we need it set.

I wonder if it would be beneficial to
- include an mdb header file in source files like this one,
- in the mdb header, define mdb() as a static inline function which
does nothing but return false if CONFIG_MDB is not defined.

Would get rid of the visual clutter introduced by #ifdef/#endif and
catch potential syntax errors when people later modify this code. I
assume that a compiler is used which eliminates code properly when mdb()
is nothing but constant false...
--
Stefan Richter
-=====-==--- =--- --=--
http://arcgraph.de/sr/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/