From a0e612d13d479d1b0e65d11037060b473c9d722f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 27 Dec 2011 19:02:57 +0000 Subject: [PATCH] Move local writer definitions to a separate header file. --- cgltrace.py | 2 +- common/trace_writer.hpp | 42 +----------------- common/trace_writer_local.cpp | 2 +- common/trace_writer_local.hpp | 82 +++++++++++++++++++++++++++++++++++ d3d10trace.py | 2 +- d3d8trace.py | 2 +- d3d9trace.py | 2 +- ddrawtrace.py | 2 +- egltrace.py | 2 +- glxtrace.py | 2 +- wgltrace.py | 2 +- 11 files changed, 92 insertions(+), 50 deletions(-) create mode 100644 common/trace_writer_local.hpp diff --git a/cgltrace.py b/cgltrace.py index 2100723..e2e9874 100644 --- a/cgltrace.py +++ b/cgltrace.py @@ -45,7 +45,7 @@ if __name__ == '__main__': print '#include ' print '#include ' print - print '#include "trace_writer.hpp"' + print '#include "trace_writer_local.hpp"' print print '// To validate our prototypes' print '#define GL_GLEXT_PROTOTYPES' diff --git a/common/trace_writer.hpp b/common/trace_writer.hpp index f710588..e012a9b 100644 --- a/common/trace_writer.hpp +++ b/common/trace_writer.hpp @@ -105,46 +105,6 @@ namespace trace { }; - extern const FunctionSig memcpy_sig; - extern const FunctionSig malloc_sig; - extern const FunctionSig free_sig; - extern const FunctionSig realloc_sig; - - /** - * A specialized Writer class, mean to trace the current process. - * - * In particular: - * - it creates a trace file based on the current process name - * - uses mutexes to allow tracing from multiple threades - * - flushes the output to ensure the last call is traced in event of - * abnormal termination - */ - class LocalWriter : public Writer { - protected: - int acquired; - - public: - /** - * Should never called directly -- use localWriter singleton below instead. - */ - LocalWriter(); - ~LocalWriter(); - - void open(void); - - unsigned beginEnter(const FunctionSig *sig); - void endEnter(void); - - void beginLeave(unsigned call); - void endLeave(void); - - void flush(void); - }; - - /** - * Singleton. - */ - extern LocalWriter localWriter; -} +} /* namespace trace */ #endif /* _TRACE_WRITER_HPP_ */ diff --git a/common/trace_writer_local.cpp b/common/trace_writer_local.cpp index e72d5c0..52962c8 100644 --- a/common/trace_writer_local.cpp +++ b/common/trace_writer_local.cpp @@ -34,7 +34,7 @@ #include "os_thread.hpp" #include "os_string.hpp" #include "trace_file.hpp" -#include "trace_writer.hpp" +#include "trace_writer_local.hpp" #include "trace_format.hpp" diff --git a/common/trace_writer_local.hpp b/common/trace_writer_local.hpp new file mode 100644 index 0000000..7c70580 --- /dev/null +++ b/common/trace_writer_local.hpp @@ -0,0 +1,82 @@ +/************************************************************************** + * + * Copyright 2007-2010 VMware, Inc. + * All Rights Reserved. + * + * 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. + * + **************************************************************************/ + +/* + * Trace writing functions. + */ + +#ifndef _TRACE_WRITER_LOCAL_HPP_ +#define _TRACE_WRITER_LOCAL_HPP_ + + +#include "trace_writer.hpp" + + +namespace trace { + + extern const FunctionSig memcpy_sig; + extern const FunctionSig malloc_sig; + extern const FunctionSig free_sig; + extern const FunctionSig realloc_sig; + + /** + * A specialized Writer class, mean to trace the current process. + * + * In particular: + * - it creates a trace file based on the current process name + * - uses mutexes to allow tracing from multiple threades + * - flushes the output to ensure the last call is traced in event of + * abnormal termination + */ + class LocalWriter : public Writer { + protected: + int acquired; + + public: + /** + * Should never called directly -- use localWriter singleton below instead. + */ + LocalWriter(); + ~LocalWriter(); + + void open(void); + + unsigned beginEnter(const FunctionSig *sig); + void endEnter(void); + + void beginLeave(unsigned call); + void endLeave(void); + + void flush(void); + }; + + /** + * Singleton. + */ + extern LocalWriter localWriter; + +} /* namespace trace */ + +#endif /* _TRACE_WRITER_LOCAL_HPP_ */ diff --git a/d3d10trace.py b/d3d10trace.py index edcf38a..b94527c 100644 --- a/d3d10trace.py +++ b/d3d10trace.py @@ -29,7 +29,7 @@ from trace import DllTracer if __name__ == '__main__': - print '#include "trace_writer.hpp"' + print '#include "trace_writer_local.hpp"' print '#include "os.hpp"' print print '#include ' diff --git a/d3d8trace.py b/d3d8trace.py index 65e13ed..d3754e5 100644 --- a/d3d8trace.py +++ b/d3d8trace.py @@ -44,7 +44,7 @@ if __name__ == '__main__': print '#include ' print '#include "d3dshader.hpp"' print - print '#include "trace_writer.hpp"' + print '#include "trace_writer_local.hpp"' print '#include "os.hpp"' print tracer = D3D8Tracer('d3d8.dll') diff --git a/d3d9trace.py b/d3d9trace.py index e6bf000..27fbc35 100644 --- a/d3d9trace.py +++ b/d3d9trace.py @@ -40,7 +40,7 @@ class D3D9Tracer(DllTracer): if __name__ == '__main__': - print '#include "trace_writer.hpp"' + print '#include "trace_writer_local.hpp"' print '#include "os.hpp"' print print '#include "d3d9imports.hpp"' diff --git a/ddrawtrace.py b/ddrawtrace.py index fb8f2a5..7022e13 100644 --- a/ddrawtrace.py +++ b/ddrawtrace.py @@ -74,7 +74,7 @@ if __name__ == '__main__': #endif ''' - print '#include "trace_writer.hpp"' + print '#include "trace_writer_local.hpp"' print '#include "os.hpp"' print tracer = DDrawTracer('ddraw.dll') diff --git a/egltrace.py b/egltrace.py index de90799..8fa313a 100644 --- a/egltrace.py +++ b/egltrace.py @@ -76,7 +76,7 @@ if __name__ == '__main__': print '#include ' print '#include ' print - print '#include "trace_writer.hpp"' + print '#include "trace_writer_local.hpp"' print print '// To validate our prototypes' print '#define GL_GLEXT_PROTOTYPES' diff --git a/glxtrace.py b/glxtrace.py index c9e9518..9adcaaf 100644 --- a/glxtrace.py +++ b/glxtrace.py @@ -58,7 +58,7 @@ if __name__ == '__main__': print '#endif' print '#include ' print - print '#include "trace_writer.hpp"' + print '#include "trace_writer_local.hpp"' print print '// To validate our prototypes' print '#define GL_GLEXT_PROTOTYPES' diff --git a/wgltrace.py b/wgltrace.py index d5a5248..9dab406 100644 --- a/wgltrace.py +++ b/wgltrace.py @@ -66,7 +66,7 @@ if __name__ == '__main__': print '#include ' print '#include ' print - print '#include "trace_writer.hpp"' + print '#include "trace_writer_local.hpp"' print '#include "os.hpp"' print print '// To validate our prototypes' -- 2.43.0