[Spice-devel] [PATCH qxl-wddm-dod 03/26] Add printer class to dump debug print statements to kernel debugger output

Sameeh Jubran sameeh at daynix.com
Wed Aug 24 13:05:07 UTC 2016


On Tue, Aug 16, 2016 at 6:59 PM, Frediano Ziglio <fziglio at redhat.com> wrote:

> >
> > From: Sandy Stutsman <sstutsma at redhat.com>
> >
> > Allows the usage of Kd_IHVVIDEO_Mask to control print level while
> debugging
> >
> > Signed-off-by: Sameeh Jubran <sameeh at daynix.com>
> > ---
> >  qxldod/driver.cpp | 24 +++++++++++++++++++++++-
> >  qxldod/driver.h   | 20 ++++++++++++++++----
> >  2 files changed, 39 insertions(+), 5 deletions(-)
> >
> > diff --git a/qxldod/driver.cpp b/qxldod/driver.cpp
> > index 4d1913c..d9946aa 100755
> > --- a/qxldod/driver.cpp
> > +++ b/qxldod/driver.cpp
> > @@ -667,7 +667,29 @@ void DebugPrintFunc(const char *format, ...)
> >      va_start(list, format);
> >      vDbgPrintEx(DPFLTR_DEFAULT_ID, 9 | DPFLTR_MASK, format, list);
> >  }
> > +
> > +kd_debug_printer::kd_debug_printer(ULONG level)
> > +{
> > +    static const ULONG xlate[] = { 0, 0, 1, 2, 3 };
> > +    if (!level || level > 5) {
> > +        _level = 0xffffffff;
> > +
> > +    }
> > +    else {
> > +        _level = xlate[level - 1];
> > +    }
> > +}
> > +
> > +void kd_debug_printer::print(const char * fmt, ...)
> > +{
> > +    if (_level == 0xffffffff) {
> > +        return;
> > +    }
> > +    va_list list;
> > +    va_start(list, fmt);
> > +    vDbgPrintEx(DPFLTR_IHVVIDEO_ID, _level, fmt, list);
> > +    va_end(list);
> > +}
> >  #endif
> >
> >  #pragma code_seg(pop) // End Non-Paged Code
> > -
> > diff --git a/qxldod/driver.h b/qxldod/driver.h
> > index e64c098..752f8e4 100755
> > --- a/qxldod/driver.h
> > +++ b/qxldod/driver.h
> > @@ -208,15 +208,27 @@ DodSystemDisplayWrite(
> >      _In_  UINT  PositionY);
> >
> >  #if DBG
> > +class kd_debug_printer
> > +{
> > +public:
> > +    kd_debug_printer(ULONG level);
> > +    void print(const char * fmt, ...);
> > +private:
> > +    ULONG _level;
> > + };
> >
> >  extern int nDebugLevel;
> >  void DebugPrintFuncSerial(const char *format, ...);
> >
> > -void DebugPrintFunc(const char *format, ...);
> > +void DebugPrintFunc(const char *format, ...);
> > +
> > +#define DbgPrint(level, line)           \
> > +    if (level > nDebugLevel) {}         \
> > +    else {                              \
> > +       DebugPrintFuncSerial line;       \
> > +     }                                  \
> > +     kd_debug_printer(level).print line
> >
> > -#define DbgPrint(level, line) \
> > -    if (level > nDebugLevel) {} \
> > -    else DebugPrintFuncSerial line
> >  #else
> >  #define DbgPrint(level, line)
> >  #endif
>
> This can be done much easier with variadic macros and a simple function.
>
> void DebugPrint(int level, const char *fmt, ...);
>
> #define DbgExpandArguments(...) __VA_ARGS__
> #define DbgPrint(level, line) do { \
>     if (level <= nDebugLevel) DebugPrintFuncSerial line; \
>     DebugPrint(level, DbgExpandArguments line); \
> } while(0)
>
>
> and the definition
>
>
> void DebugPrint(int level, const char *fmt, ...)
> {
>    static const ULONG xlate[] = { 0, 0, 1, 2, 3 };
>    if (level <= 0 || level > 5)
>        return;
>
>    va_list list;
>    va_start(list, fmt);
>    vDbgPrintEx(DPFLTR_IHVVIDEO_ID, xlate[level - 1], fmt, list);
>    va_end(list);
> }
>
I'll rework this and resend it.

>
>
> Cannot test but I can see the print is duplicated to DebugPrintFuncSerial
> and vDbgPrintEx. Is this wanted?
>
Yes, we print to both serial and Windbg simultaneously.

>
> Frediano
>



-- 
Respectfully,
*Sameeh Jubran*
*Linkedin <https://il.linkedin.com/pub/sameeh-jubran/87/747/a8a>*
*Junior Software Engineer @ Daynix <http://www.daynix.com>.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160824/777e7ccc/attachment.html>


More information about the Spice-devel mailing list