<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 16, 2016 at 6:59 PM, Frediano Ziglio <span dir="ltr"><<a href="mailto:fziglio@redhat.com" target="_blank">fziglio@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">><br>
> From: Sandy Stutsman <<a href="mailto:sstutsma@redhat.com">sstutsma@redhat.com</a>><br>
><br>
> Allows the usage of Kd_IHVVIDEO_Mask to control print level while debugging<br>
><br>
> Signed-off-by: Sameeh Jubran <<a href="mailto:sameeh@daynix.com">sameeh@daynix.com</a>><br>
> ---<br>
> qxldod/driver.cpp | 24 +++++++++++++++++++++++-<br>
> qxldod/driver.h | 20 ++++++++++++++++----<br>
> 2 files changed, 39 insertions(+), 5 deletions(-)<br>
><br>
> diff --git a/qxldod/driver.cpp b/qxldod/driver.cpp<br>
> index 4d1913c..d9946aa 100755<br>
> --- a/qxldod/driver.cpp<br>
> +++ b/qxldod/driver.cpp<br>
> @@ -667,7 +667,29 @@ void DebugPrintFunc(const char *format, ...)<br>
> va_start(list, format);<br>
> vDbgPrintEx(DPFLTR_DEFAULT_ID, 9 | DPFLTR_MASK, format, list);<br>
> }<br>
> +<br>
> +kd_debug_printer::kd_debug_<wbr>printer(ULONG level)<br>
> +{<br>
> + static const ULONG xlate[] = { 0, 0, 1, 2, 3 };<br>
> + if (!level || level > 5) {<br>
> + _level = 0xffffffff;<br>
> +<br>
> + }<br>
> + else {<br>
> + _level = xlate[level - 1];<br>
> + }<br>
> +}<br>
> +<br>
> +void kd_debug_printer::print(const char * fmt, ...)<br>
> +{<br>
> + if (_level == 0xffffffff) {<br>
> + return;<br>
> + }<br>
> + va_list list;<br>
> + va_start(list, fmt);<br>
> + vDbgPrintEx(DPFLTR_IHVVIDEO_<wbr>ID, _level, fmt, list);<br>
> + va_end(list);<br>
> +}<br>
> #endif<br>
><br>
> #pragma code_seg(pop) // End Non-Paged Code<br>
> -<br>
> diff --git a/qxldod/driver.h b/qxldod/driver.h<br>
> index e64c098..752f8e4 100755<br>
> --- a/qxldod/driver.h<br>
> +++ b/qxldod/driver.h<br>
> @@ -208,15 +208,27 @@ DodSystemDisplayWrite(<br>
> _In_ UINT PositionY);<br>
><br>
> #if DBG<br>
> +class kd_debug_printer<br>
> +{<br>
> +public:<br>
> + kd_debug_printer(ULONG level);<br>
> + void print(const char * fmt, ...);<br>
> +private:<br>
> + ULONG _level;<br>
> + };<br>
><br>
> extern int nDebugLevel;<br>
> void DebugPrintFuncSerial(const char *format, ...);<br>
><br>
> -void DebugPrintFunc(const char *format, ...);<br>
> +void DebugPrintFunc(const char *format, ...);<br>
> +<br>
> +#define DbgPrint(level, line) \<br>
> + if (level > nDebugLevel) {} \<br>
> + else { \<br>
> + DebugPrintFuncSerial line; \<br>
> + } \<br>
> + kd_debug_printer(level).print line<br>
><br>
> -#define DbgPrint(level, line) \<br>
> - if (level > nDebugLevel) {} \<br>
> - else DebugPrintFuncSerial line<br>
> #else<br>
> #define DbgPrint(level, line)<br>
> #endif<br>
<br>
</div></div>This can be done much easier with variadic macros and a simple function.<br>
<br>
void DebugPrint(int level, const char *fmt, ...);<br>
<br>
#define DbgExpandArguments(...) __VA_ARGS__<br>
#define DbgPrint(level, line) do { \<br>
if (level <= nDebugLevel) DebugPrintFuncSerial line; \<br>
DebugPrint(level, DbgExpandArguments line); \<br>
} while(0)<br>
<br>
<br>
and the definition<br>
<br>
<br>
void DebugPrint(int level, const char *fmt, ...)<br>
{<br>
<span class=""> static const ULONG xlate[] = { 0, 0, 1, 2, 3 };<br>
</span> if (level <= 0 || level > 5)<br>
return;<br>
<br>
va_list list;<br>
va_start(list, fmt);<br>
vDbgPrintEx(DPFLTR_IHVVIDEO_<wbr>ID, xlate[level - 1], fmt, list);<br>
va_end(list);<br>
}<br></blockquote><div>I'll rework this and resend it. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
Cannot test but I can see the print is duplicated to DebugPrintFuncSerial<br>
and vDbgPrintEx. Is this wanted?<br></blockquote><div>Yes, we print to both serial and Windbg simultaneously. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
Frediano<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font size="4" color="#0b5394" face="times new roman, serif">Respectfully,<br></font><div style="font-size:12.8px;color:rgb(136,136,136)"><font size="4" color="#0b5394" face="times new roman, serif"><b><i>Sameeh Jubran</i></b></font></div><div style="font-size:12.8px;color:rgb(136,136,136)"><i style="color:rgb(7,55,99);font-family:"times new roman",serif;font-size:large"><span style="line-height:15px"><a href="https://il.linkedin.com/pub/sameeh-jubran/87/747/a8a" title="View public profile" name="UNIQUE_ID_SafeHtmlFilter_UNIQUE_ID_SafeHtmlFilter_UNIQUE_ID_SafeHtmlFilter_UNIQUE_ID_SafeHtmlFilter_14e2c1de96f8c195_UNIQUE_ID_SafeHtmlFilter_SafeHtmlFilter_SafeHtmlFilter_webProfileURL" style="color:rgb(17,85,204);margin:0px;padding:0px;border-width:0px;outline:none;vertical-align:baseline;text-decoration:none" target="_blank">Linkedin</a></span></i><br></div><div style="font-size:12.8px;color:rgb(136,136,136)"><font size="4" face="times new roman, serif" color="#073763"><i>Junior Software Engineer @ <a href="http://www.daynix.com" target="_blank">Daynix</a>.</i></font></div></div></div></div></div></div></div>
</div></div>