[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [win-pv-devel] [PATCH 2/4] Add more logging to xencons_tty in debug builds



> -----Original Message-----
> From: win-pv-devel [mailto:win-pv-devel-bounces@xxxxxxxxxxxxxxxxxxxx] On
> Behalf Of Owen Smith
> Sent: 05 November 2018 16:30
> To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: Owen Smith <owen.smith@xxxxxxxxxx>
> Subject: [win-pv-devel] [PATCH 2/4] Add more logging to xencons_tty in
> debug builds
> 
> Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>

Not sure this should just be limited to debug builds. The messages will be 
blocked by the DEFAULT filter unless it is explicitly enabled.

Acked-by: Paul Durrant <paul.durrant@xxxxxxxxxx>

> ---
>  src/tty/tty.c                          | 60
> ++++++++++++++++++++++++++++++++++
>  vs2017/xencons_tty/xencons_tty.vcxproj |  2 +-
>  2 files changed, 61 insertions(+), 1 deletion(-)
> 
> diff --git a/src/tty/tty.c b/src/tty/tty.c
> index 7d97df5..a6c15e9 100644
> --- a/src/tty/tty.c
> +++ b/src/tty/tty.c
> @@ -34,6 +34,10 @@
>  #include <strsafe.h>
>  #include <userenv.h>
> 
> +#define stringify_literal(_text) #_text
> +#define stringify(_text) stringify_literal(_text)
> +#define __MODULE__ stringify(PROJECT)
> +
>  typedef struct _TTY_STREAM {
>      HANDLE  Read;
>      HANDLE  Write;
> @@ -54,6 +58,54 @@ typedef struct _TTY_CONTEXT {
> 
>  TTY_CONTEXT TtyContext;
> 
> +#if DBG
> +
> +static VOID
> +#pragma prefast(suppress:6262) // Function uses '1036' bytes of stack:
> exceeds /analyze:stacksize'1024'
> +__Log(
> +    IN  const CHAR      *Format,
> +    IN  ...
> +    )
> +{
> +    CHAR                Buffer[MAXIMUM_BUFFER_SIZE];
> +    va_list             Arguments;
> +    size_t              Length;
> +    HRESULT             Result;
> +
> +    va_start(Arguments, Format);
> +    Result = StringCchVPrintfA(Buffer,
> +        MAXIMUM_BUFFER_SIZE,
> +        Format,
> +        Arguments);
> +    va_end(Arguments);
> +
> +    if (Result != S_OK && Result != STRSAFE_E_INSUFFICIENT_BUFFER)
> +        return;
> +
> +    Result = StringCchLengthA(Buffer, MAXIMUM_BUFFER_SIZE, &Length);
> +    if (Result != S_OK)
> +        return;
> +
> +    Length = __min(MAXIMUM_BUFFER_SIZE - 1, Length + 2);
> +
> +    __analysis_assume(Length < MAXIMUM_BUFFER_SIZE);
> +    __analysis_assume(Length >= 2);
> +    Buffer[Length] = '\0';
> +    Buffer[Length - 1] = '\n';
> +    Buffer[Length - 2] = '\r';
> +
> +    OutputDebugString(Buffer);
> +}
> +
> +#define Log(_Format, ...) \
> +    __Log(__MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
> +
> +#else
> +
> +#define Log(_Format, ...)   (VOID)0;
> +
> +#endif
> +
>  static BOOL
>  CreateChild(
>      VOID
> @@ -314,6 +366,7 @@ TtyIn(
> 
>      UNREFERENCED_PARAMETER(Argument);
> 
> +    Log("=====>");
>      for (;;) {
>          DWORD       Read;
>          CHAR        Buffer[MAXIMUM_BUFFER_SIZE];
> @@ -345,6 +398,7 @@ TtyIn(
>                  break;
>          }
>      }
> +    Log("<=====");
> 
>      return 0;
>  }
> @@ -358,6 +412,7 @@ TtyOut(
> 
>      UNREFERENCED_PARAMETER(Argument);
> 
> +    Log("=====>");
>      for (;;) {
>          DWORD       Read;
>          DWORD       Written;
> @@ -383,6 +438,7 @@ TtyOut(
>          if (!Success)
>              break;
>      }
> +    Log("<=====");
> 
>      return 0;
>  }
> @@ -402,6 +458,8 @@ _tmain(
>      UNREFERENCED_PARAMETER(argc);
>      UNREFERENCED_PARAMETER(argv);
> 
> +    Log("=====>");
> +
>      if (!WaitNamedPipe(PIPE_NAME, NMPWAIT_USE_DEFAULT_WAIT))
>          ExitProcess(1);
> 
> @@ -510,4 +568,6 @@ _tmain(
>              CloseHandle(Handle[Index]);
> 
>      CloseHandle(Context->ProcessInfo.hProcess);
> +
> +    Log("<=====");
>  }
> diff --git a/vs2017/xencons_tty/xencons_tty.vcxproj
> b/vs2017/xencons_tty/xencons_tty.vcxproj
> index 18ad81b..623595c 100644
> --- a/vs2017/xencons_tty/xencons_tty.vcxproj
> +++ b/vs2017/xencons_tty/xencons_tty.vcxproj
> @@ -20,7 +20,7 @@
>    <ItemDefinitionGroup>
>      <ClCompile>
> 
> <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalInclude
> Directories)</AdditionalIncludeDirectories>
> -
> <PreprocessorDefinitions>WIN32;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(Preproce
> ssorDefinitions)</PreprocessorDefinitions>
> +
> <PreprocessorDefinitions>PROJECT=$(ProjectName);WIN32;_WINDOWS;_CRT_SECURE
> _NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
>        <WarningLevel>EnableAllWarnings</WarningLevel>
> 
> <DisableSpecificWarnings>4127;4711;4548;4820;4668;4255;5032;5045;6001;6054
> ;28196;%(DisableSpecificWarnings)</DisableSpecificWarnings>
>        <MultiProcessorCompilation>true</MultiProcessorCompilation>
> --
> 2.16.2.windows.1
> 
> 
> _______________________________________________
> win-pv-devel mailing list
> win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> https://lists.xenproject.org/mailman/listinfo/win-pv-devel
_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/win-pv-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.