Re: [linux-usb-devel] Re: [BK PATCH] USB changes for 2.5.34

From: Linus Torvalds (torvalds@transmeta.com)
Date: Mon Sep 09 2002 - 20:48:35 EST


On Mon, 9 Sep 2002, Linus Torvalds wrote:
>
> On the whole, it's a lot better to just print out a message (and call
> traces are often very useful) and continue. That's not always possible, of
> course, and a lot of BUG() and BUG_ON() cases are perfectly valid simply
> because sometimes there isn't anything you can do except kill the machine
> and try to inform the user.

Note that from an implementation standpoint I suspect that a "trap and
continue" thing can easily be pretty much exactly as the current BUG()
with a flag somewhere, say in the "third byte" of the "ud2" instruction.

That would also make it easy to dynamically change the behaviour (ie some
people might want to explicitly make even the "warnings" fatal - a kernel
version of -Werror), and the implementation should be trivial:

#define TRAP_INSTRUCTION( lethal ) \
        __asm__ __volatile__( "ud2\n" \
                        "\t.byte %0\n" \
                        "\t.word %c1\n" \
                        "\t.long %c2\n" \
                        : :"i" (lethal), "i" (__LINE__), "i" (__FILE__))

and then you have

        #define BUG() TRAP_INSTRUCTION(1)
        #define WARN() TRAP_INSTRUCTION(0)

or something like that (where the non-lethal version just increments eip
by 9 to jump over the extended ud2 and the information pointers).

                Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Sep 15 2002 - 22:00:20 EST