Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/windirstat.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/tracer.cpp105
-rw-r--r--common/tracer.h93
-rw-r--r--premake4.lua5
-rw-r--r--windirstat/windirstat.cpp21
-rw-r--r--windirstat/windirstat.h4
-rw-r--r--windirstat/windirstat.vs8.vcproj14
6 files changed, 160 insertions, 82 deletions
diff --git a/common/tracer.cpp b/common/tracer.cpp
new file mode 100644
index 0000000..6acdf98
--- /dev/null
+++ b/common/tracer.cpp
@@ -0,0 +1,105 @@
+// tracer.h - Implementation of tracer class for debugging purposes
+//
+// NOTE: this file is under MIT license as opposed to the project as a whole.
+//
+// WinDirStat - Directory Statistics
+// Copyright (C) 2010 Oliver Schneider (assarbad.net)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+// Author(s): - assarbad -> http://windirstat.info/contact/oliver/
+//
+
+#ifndef __TRACER_CPP_VER__
+#define __TRACER_CPP_VER__ 2014012617
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+#pragma once
+#endif // Check for "#pragma once" support
+#include "tracer.h"
+#include <cstdarg>
+#include <fcntl.h>
+#include <io.h>
+
+#if VTRACE_TO_CONSOLE
+CWDSTracerConsole::CWDSTracerConsole()
+{
+ ::AllocConsole();
+ // Standard output
+ int hCrt = _open_osfhandle((intptr_t)::GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
+ FILE *hf = _fdopen(hCrt, "w");
+ *stdout = *hf;
+ setvbuf(stdout, NULL, _IONBF, 0);
+ // Standard error
+ hCrt = _open_osfhandle((intptr_t)::GetStdHandle(STD_ERROR_HANDLE), _O_TEXT);
+ hf = _fdopen(hCrt, "w");
+ *stderr = *hf;
+ setvbuf(stderr, NULL, _IONBF, 0);
+}
+
+CWDSTracerConsole::~CWDSTracerConsole()
+{
+ ::FreeConsole();
+}
+#endif // VTRACE_TO_CONSOLE
+
+CWDSTracer::CWDSTracer(LPCSTR srcfile, LPCSTR fctname, unsigned int srcline)
+ : m_srcfile(srcfile)
+ , m_srcfunc(fctname)
+ , m_srcline(srcline)
+ // we can rely on the format with back slashes, no need to check forward slashes here
+ , m_srcbasename((srcfile) ? strrchr(srcfile, '\\') : NULL)
+{
+ // Skip over the backslash
+ m_srcbasename = (m_srcbasename) ? m_srcbasename + 1 : srcfile;
+}
+
+void CWDSTracer::operator()(LPCSTR format, ...) // ANSI
+{
+ CStringA str;
+ va_list args;
+ va_start(args, format);
+ str.FormatV(format, args);
+ va_end(args);
+ CStringA strDbg;
+ strDbg.Format("[%hs:%u:%hs] %hs\n", m_srcbasename, m_srcline, m_srcfunc, str.GetBuffer());
+# if !VTRACE_TO_CONSOLE || (VTRACE_TO_CONSOLE && !VTRACE_NO_OUTPUTDEBUGSTRING)
+ OutputDebugStringA(strDbg.GetBuffer());
+# endif
+# if VTRACE_TO_CONSOLE
+ printf(strDbg.GetBuffer());
+# endif // VTRACE_TO_CONSOLE
+}
+
+void CWDSTracer::operator()(LPCWSTR format, ...) // Unicode
+{
+ CStringW str;
+ va_list args;
+ va_start(args, format);
+ str.FormatV(format, args);
+ va_end(args);
+ CStringW strDbg;
+ strDbg.Format(L"[%hs:%u:%hs] %ws\n", m_srcbasename, m_srcline, m_srcfunc, str.GetBuffer());
+# if !VTRACE_TO_CONSOLE || (VTRACE_TO_CONSOLE && !VTRACE_NO_OUTPUTDEBUGSTRING)
+ OutputDebugStringW(strDbg.GetBuffer());
+# endif
+# ifdef VTRACE_TO_CONSOLE
+ wprintf(strDbg.GetBuffer());
+# endif // VTRACE_TO_CONSOLE
+}
+#endif // __TRACER_CPP_VER__
diff --git a/common/tracer.h b/common/tracer.h
index 7797567..3ee72dc 100644
--- a/common/tracer.h
+++ b/common/tracer.h
@@ -1,82 +1,65 @@
// tracer.h - Implementation of tracer class for debugging purposes
//
+// NOTE: this file is under MIT license as opposed to the project as a whole.
+//
// WinDirStat - Directory Statistics
// Copyright (C) 2010 Oliver Schneider (assarbad.net)
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
//
// Author(s): - assarbad -> http://windirstat.info/contact/oliver/
//
-#ifndef __TRACER_CPP_VER__
-#define __TRACER_CPP_VER__ 2010073115
+#ifndef __TRACER_H_VER__
+#define __TRACER_H_VER__ 2014012617
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif // Check for "#pragma once" support
#ifdef _DEBUG
-#include <afxwin.h> // MFC core and standard components
-#include <cstdarg>
+#if VTRACE_TO_CONSOLE
+class CWDSTracerConsole
+{
+public:
+ CWDSTracerConsole();
+ ~CWDSTracerConsole();
+};
+#endif // VTRACE_TO_CONSOLE
class CWDSTracer
{
public:
- CWDSTracer(LPCSTR srcfile, unsigned int srcline)
- : m_srcfile(srcfile)
- , m_srcline(srcline)
- // we can rely on the format with back slashes, no need to check forward slashes here
- , m_srcbasename((srcfile) ? strrchr(srcfile, '\\') : NULL)
- {
- // Skip over the backslash
- m_srcbasename = (m_srcbasename) ? m_srcbasename + 1 : srcfile;
- }
-
- void operator()(LPCSTR format, ...) // ANSI
- {
- CStringA str;
- va_list args;
- va_start(args, format);
- str.FormatV(format, args);
- va_end(args);
- CStringA strDbg;
- strDbg.Format("[%hs:%u] %hs\n", m_srcbasename, m_srcline, str.GetBuffer());
- OutputDebugStringA(strDbg.GetBuffer());
- }
-
- void operator()(LPCWSTR format, ...) // Unicode
- {
- CStringW str;
- va_list args;
- va_start(args, format);
- str.FormatV(format, args);
- va_end(args);
- CStringW strDbg;
- strDbg.Format(L"[%hs:%u] %ws\n", m_srcbasename, m_srcline, str.GetBuffer());
- OutputDebugStringW(strDbg.GetBuffer());
- }
-
+ CWDSTracer(LPCSTR srcfile, LPCSTR fctname, unsigned int srcline);
+ void operator()(LPCSTR format, ...);
+ void operator()(LPCWSTR format, ...);
private:
const CStringA m_srcfile;
+ const CStringA m_srcfunc;
unsigned int m_srcline;
LPCSTR m_srcbasename;
+ CWDSTracer& operator=(const CWDSTracer&); // hide it
};
// Use as VTRACE(format, ...) ... *must* be on one long line ;)
-# define VTRACE CWDSTracer(__##FILE##__, __##LINE##__)
-#else // note _DEBUG
+# define VTRACE CWDSTracer(__##FILE##__, __##FUNCTION##__, __##LINE##__)
+#else // not _DEBUG, ... please note that this trick works _because_ of the VC++ preprocessor
# define VTRACE /##/
#endif // _DEBUG
-#endif // __TRACER_CPP_VER__ \ No newline at end of file
+#endif // __TRACER_H_VER__ \ No newline at end of file
diff --git a/premake4.lua b/premake4.lua
index 892db3e..737c727 100644
--- a/premake4.lua
+++ b/premake4.lua
@@ -178,7 +178,7 @@ solution (iif(release, slnname, "windirstat"))
"windirstat/Dialogs/*.h",
"windirstat/windirstat.rc",
"windirstat/res/*.*",
- "*.txt", "*.rst",
+ "*.txt", "*.md",
"common/BUILD",
"common/*.cmd",
"premake4.lua",
@@ -186,6 +186,7 @@ solution (iif(release, slnname, "windirstat"))
excludes
{
+ "common/tracer.cpp", -- this one gets an #include via windirstat.cpp
"windirstat/stdafx.cpp",
}
@@ -219,7 +220,7 @@ solution (iif(release, slnname, "windirstat"))
targetsuffix ("64")
configuration {"Debug"}
- defines ("_DEBUG")
+ defines {"_DEBUG", "VTRACE_TO_CONSOLE=1"}
flags {"Symbols"}
configuration {"Release"}
diff --git a/windirstat/windirstat.cpp b/windirstat/windirstat.cpp
index 5f1415c..1808911 100644
--- a/windirstat/windirstat.cpp
+++ b/windirstat/windirstat.cpp
@@ -35,27 +35,13 @@
#include <Dbghelp.h> // for mini dumps
#ifdef _DEBUG
-#define new DEBUG_NEW
+# include <common/tracer.cpp>
+# define new DEBUG_NEW
#endif
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' "\
"version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
-class CMiniDumper
-{
-private:
- typedef BOOL (WINAPI *TFNMiniDumpWriteDump)
- (
- HANDLE hProcess,
- DWORD ProcessId,
- HANDLE hFile,
- MINIDUMP_TYPE DumpType,
- PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
- PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
- PMINIDUMP_CALLBACK_INFORMATION CallbackParam
- );
-};
-
CMainFrame *GetMainFrame()
{
// Not: return (CMainFrame *)AfxGetMainWnd();
@@ -111,6 +97,9 @@ CDirstatApp::CDirstatApp()
# if SUPPORT_ELEVATION
, m_ElevationEvent(NULL)
# endif // SUPPORT_ELEVATION
+# ifdef VTRACE_TO_CONSOLE
+ , m_vtrace_console(new CWDSTracerConsole())
+# endif // VTRACE_TO_CONSOLE
{
# ifdef _DEBUG
TestScanResourceDllName();
diff --git a/windirstat/windirstat.h b/windirstat/windirstat.h
index 80941a3..0e3c798 100644
--- a/windirstat/windirstat.h
+++ b/windirstat/windirstat.h
@@ -35,6 +35,7 @@
#include "options.h"
#include "mountpoints.h"
#include "helpmap.h"
+#include <common/tracer.h>
typedef CMap<CString, LPCTSTR, COLORREF, COLORREF> CExtensionColorMap; // ".bmp" -> color
@@ -129,6 +130,9 @@ protected:
#if SUPPORT_ELEVATION
HANDLE m_ElevationEvent;
#endif // SUPPORT_ELEVATION
+#ifdef VTRACE_TO_CONSOLE
+ CAutoPtr<CWDSTracerConsole> m_vtrace_console;
+#endif // VTRACE_TO_CONSOLE
DECLARE_MESSAGE_MAP()
afx_msg void OnFileOpen();
diff --git a/windirstat/windirstat.vs8.vcproj b/windirstat/windirstat.vs8.vcproj
index f56de5d..5cf6855 100644
--- a/windirstat/windirstat.vs8.vcproj
+++ b/windirstat/windirstat.vs8.vcproj
@@ -46,7 +46,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..;.;..\common;Controls;Dialogs;..\3rdparty\lua\src"
- PreprocessorDefinitions="_DEBUG;WINVER=0x0500;HAVE_WIN7_SDK=1"
+ PreprocessorDefinitions="_DEBUG;VTRACE_TO_CONSOLE=1;WINVER=0x0500;HAVE_WIN7_SDK=1"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
EnableFunctionLevelLinking="true"
@@ -64,7 +64,7 @@
<Tool
Name="VCResourceCompilerTool"
AdditionalOptions="/nologo /l409"
- PreprocessorDefinitions="_DEBUG;WINVER=0x0500;HAVE_WIN7_SDK=1"
+ PreprocessorDefinitions="_DEBUG;VTRACE_TO_CONSOLE=1;WINVER=0x0500;HAVE_WIN7_SDK=1"
AdditionalIncludeDirectories="..;.;..\common;Controls;Dialogs;..\3rdparty\lua\src;..;$(IntDir)"
/>
<Tool
@@ -137,7 +137,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..;.;..\common;Controls;Dialogs;..\3rdparty\lua\src"
- PreprocessorDefinitions="_DEBUG;WINVER=0x0500;HAVE_WIN7_SDK=1"
+ PreprocessorDefinitions="_DEBUG;VTRACE_TO_CONSOLE=1;WINVER=0x0500;HAVE_WIN7_SDK=1"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
EnableFunctionLevelLinking="true"
@@ -155,7 +155,7 @@
<Tool
Name="VCResourceCompilerTool"
AdditionalOptions="/nologo /l409"
- PreprocessorDefinitions="_DEBUG;WINVER=0x0500;HAVE_WIN7_SDK=1"
+ PreprocessorDefinitions="_DEBUG;VTRACE_TO_CONSOLE=1;WINVER=0x0500;HAVE_WIN7_SDK=1"
AdditionalIncludeDirectories="..;.;..\common;Controls;Dialogs;..\3rdparty\lua\src;..;$(IntDir)"
/>
<Tool
@@ -611,7 +611,7 @@
</File>
</Filter>
<File
- RelativePath="..\README.rst"
+ RelativePath="..\README.md"
>
</File>
<Filter
@@ -902,10 +902,6 @@
RelativePath="..\TODO.txt"
>
</File>
- <File
- RelativePath="..\manifest.txt"
- >
- </File>
</Files>
<Globals>
</Globals>