diff --git a/import-chrome/build/unix/Makefile b/import-chrome/build/unix/Makefile new file mode 100644 index 00000000..3b50301c --- /dev/null +++ b/import-chrome/build/unix/Makefile @@ -0,0 +1,12 @@ +all: debug + +debug: + @+make -f debug.mk all + +release: + @+make -f release.mk all + +clean: + @+make -f build.mk clean + +.PHONY: all clean debug release diff --git a/import-chrome/build/unix/build.mk b/import-chrome/build/unix/build.mk new file mode 100644 index 00000000..78ec38ba --- /dev/null +++ b/import-chrome/build/unix/build.mk @@ -0,0 +1,60 @@ +CFLAGS += +CXXFLAGS := $(CFLAGS) -std=gnu++17 +DEFINES += -DTRACY_NO_STATISTICS +INCLUDES := +LIBS := -lpthread +PROJECT := import-chrome +IMAGE := $(PROJECT)-$(BUILD) + +FILTER := + +BASE := $(shell egrep 'ClCompile.*cpp"' ../win32/$(PROJECT).vcxproj | sed -e 's/.*\"\(.*\)\".*/\1/' | sed -e 's@\\@/@g') +BASE2 := $(shell egrep 'ClCompile.*c"' ../win32/$(PROJECT).vcxproj | sed -e 's/.*\"\(.*\)\".*/\1/' | sed -e 's@\\@/@g') + +SRC := $(filter-out $(FILTER),$(BASE)) +SRC2 := $(filter-out $(FILTER),$(BASE2)) + +TBB := $(shell ld -ltbb -o /dev/null 2>/dev/null; echo $$?) +ifeq ($(TBB),0) + LIBS += -ltbb +endif + +OBJDIRBASE := obj/$(BUILD) +OBJDIR := $(OBJDIRBASE)/o/o/o + +OBJ := $(addprefix $(OBJDIR)/,$(SRC:%.cpp=%.o)) +OBJ2 := $(addprefix $(OBJDIR)/,$(SRC2:%.c=%.o)) + +all: $(IMAGE) + +$(OBJDIR)/%.o: %.cpp + $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< -o $@ + +$(OBJDIR)/%.d : %.cpp + @echo Resolving dependencies of $< + @mkdir -p $(@D) + @$(CXX) -MM $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< > $@.$$$$; \ + sed 's,.*\.o[ :]*,$(OBJDIR)/$(<:.cpp=.o) $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + +$(OBJDIR)/%.o: %.c + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +$(OBJDIR)/%.d : %.c + @echo Resolving dependencies of $< + @mkdir -p $(@D) + @$(CC) -MM $(INCLUDES) $(CFLAGS) $(DEFINES) $< > $@.$$$$; \ + sed 's,.*\.o[ :]*,$(OBJDIR)/$(<:.c=.o) $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + +$(IMAGE): $(OBJ) $(OBJ2) + $(CXX) $(CXXFLAGS) $(DEFINES) $(OBJ) $(OBJ2) $(LIBS) -o $@ + +ifneq "$(MAKECMDGOALS)" "clean" +-include $(addprefix $(OBJDIR)/,$(SRC:.cpp=.d)) %(addprefix $(OBJDIR)/,$(SRC2:.c=.d)) +endif + +clean: + rm -rf $(OBJDIRBASE) $(IMAGE)* + +.PHONY: clean all diff --git a/import-chrome/build/unix/debug.mk b/import-chrome/build/unix/debug.mk new file mode 100644 index 00000000..04d925a6 --- /dev/null +++ b/import-chrome/build/unix/debug.mk @@ -0,0 +1,11 @@ +ARCH := $(shell uname -m) + +CFLAGS := -g3 -Wall +DEFINES := -DDEBUG +BUILD := debug + +ifeq ($(ARCH),x86_64) +CFLAGS += -msse4.1 +endif + +include build.mk diff --git a/import-chrome/build/unix/release.mk b/import-chrome/build/unix/release.mk new file mode 100644 index 00000000..030063e3 --- /dev/null +++ b/import-chrome/build/unix/release.mk @@ -0,0 +1,11 @@ +ARCH := $(shell uname -m) + +CFLAGS := -O3 -s -fomit-frame-pointer +DEFINES := -DNDEBUG +BUILD := release + +ifeq ($(ARCH),x86_64) +CFLAGS += -msse4.1 +endif + +include build.mk diff --git a/import-chrome/build/win32/import-chrome.sln b/import-chrome/build/win32/import-chrome.sln new file mode 100644 index 00000000..2971a376 --- /dev/null +++ b/import-chrome/build/win32/import-chrome.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2002 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "import-chrome", "import-chrome.vcxproj", "{447D58BF-94CD-4469-BB90-549C05D03E00}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {447D58BF-94CD-4469-BB90-549C05D03E00}.Debug|x64.ActiveCfg = Debug|x64 + {447D58BF-94CD-4469-BB90-549C05D03E00}.Debug|x64.Build.0 = Debug|x64 + {447D58BF-94CD-4469-BB90-549C05D03E00}.Release|x64.ActiveCfg = Release|x64 + {447D58BF-94CD-4469-BB90-549C05D03E00}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3E51386C-43EA-44AC-9F24-AFAFE4D63ADE} + EndGlobalSection +EndGlobal diff --git a/import-chrome/build/win32/import-chrome.vcxproj b/import-chrome/build/win32/import-chrome.vcxproj new file mode 100644 index 00000000..afac50cb --- /dev/null +++ b/import-chrome/build/win32/import-chrome.vcxproj @@ -0,0 +1,170 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {447D58BF-94CD-4469-BB90-549C05D03E00} + import-chrome + 10.0 + + + + Application + true + v142 + MultiByte + + + Application + false + v142 + true + MultiByte + + + Application + true + v142 + MultiByte + + + Application + false + v142 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + true + + + + + Level3 + Disabled + true + true + true + TRACY_NO_STATISTICS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;WIN32_LEAN_AND_MEAN;NOMINMAX;_USE_MATH_DEFINES;%(PreprocessorDefinitions) + AdvancedVectorExtensions2 + stdcpplatest + + + ws2_32.lib;%(AdditionalDependencies) + Console + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + true + TRACY_NO_STATISTICS;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;WIN32_LEAN_AND_MEAN;NOMINMAX;_USE_MATH_DEFINES;%(PreprocessorDefinitions) + AdvancedVectorExtensions2 + stdcpplatest + + + true + true + ws2_32.lib;%(AdditionalDependencies) + Console + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/import-chrome/build/win32/import-chrome.vcxproj.filters b/import-chrome/build/win32/import-chrome.vcxproj.filters new file mode 100644 index 00000000..13967783 --- /dev/null +++ b/import-chrome/build/win32/import-chrome.vcxproj.filters @@ -0,0 +1,114 @@ + + + + + {729c80ee-4d26-4a5e-8f1f-6c075783eb56} + + + {cf23ef7b-7694-4154-830b-00cf053350ea} + + + {e39d3623-47cd-4752-8da9-3ea324f964c1} + + + + + common + + + common + + + common + + + server + + + server + + + src + + + common + + + server + + + server + + + + + common + + + common + + + common + + + common + + + common + + + common + + + common + + + common + + + server + + + server + + + server + + + server + + + server + + + server + + + server + + + server + + + server + + + common + + + common + + + common + + + common + + + server + + + server + + + diff --git a/import-chrome/src/import-chrome.cpp b/import-chrome/src/import-chrome.cpp new file mode 100644 index 00000000..87ffe6bd --- /dev/null +++ b/import-chrome/src/import-chrome.cpp @@ -0,0 +1,122 @@ +#ifdef _WIN32 +# include +#endif + +#include +#include +#include +#include + +#include "../../server/TracyFileRead.hpp" +#include "../../server/TracyFileWrite.hpp" +#include "../../server/TracyVersion.hpp" +#include "../../server/TracyWorker.hpp" + +#ifdef __CYGWIN__ +# define ftello64(x) ftello(x) +#elif defined _WIN32 +# define ftello64(x) _ftelli64(x) +#endif + +void Usage() +{ + printf( "Usage: update [--hc|--extreme] input.tracy output.tracy\n\n" ); + printf( " --hc: enable LZ4HC compression\n" ); + printf( " --extreme: enable extreme LZ4HC compression (very slow)\n" ); + exit( 1 ); +} + +int main( int argc, char** argv ) +{ +#ifdef _WIN32 + if( !AttachConsole( ATTACH_PARENT_PROCESS ) ) + { + AllocConsole(); + SetConsoleMode( GetStdHandle( STD_OUTPUT_HANDLE ), 0x07 ); + } +#endif + + tracy::FileWrite::Compression clev = tracy::FileWrite::Compression::Fast; + + if( argc != 3 && argc != 4 ) Usage(); + if( argc == 4 ) + { + if( strcmp( argv[1], "--hc" ) == 0 ) + { + clev = tracy::FileWrite::Compression::Slow; + } + else if( strcmp( argv[1], "--extreme" ) == 0 ) + { + clev = tracy::FileWrite::Compression::Extreme; + } + else + { + Usage(); + } + argv++; + } + + const char* input = argv[1]; + const char* output = argv[2]; + + printf( "Loading...\r" ); + fflush( stdout ); + auto f = std::unique_ptr( tracy::FileRead::Open( input ) ); + if( !f ) + { + fprintf( stderr, "Cannot open input file!\n" ); + exit( 1 ); + } + + try + { + int inVer; + { + tracy::Worker worker( *f, tracy::EventType::All, false ); + +#ifndef TRACY_NO_STATISTICS + while( !worker.AreSourceLocationZonesReady() ) std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) ); +#endif + + auto w = std::unique_ptr( tracy::FileWrite::Open( output, clev ) ); + if( !w ) + { + fprintf( stderr, "Cannot open output file!\n" ); + exit( 1 ); + } + printf( "Saving... \r" ); + fflush( stdout ); + worker.Write( *w ); + inVer = worker.GetTraceVersion(); + } + + FILE* in = fopen( input, "rb" ); + fseek( in, 0, SEEK_END ); + const auto inSize = ftello64( in ); + fclose( in ); + + FILE* out = fopen( output, "rb" ); + fseek( out, 0, SEEK_END ); + const auto outSize = ftello64( out ); + fclose( out ); + + printf( "%s (%i.%i.%i) {%zu KB} -> %s (%i.%i.%i) {%zu KB} %.2f%% size change\n", input, inVer >> 16, ( inVer >> 8 ) & 0xFF, inVer & 0xFF, size_t( inSize / 1024 ), output, tracy::Version::Major, tracy::Version::Minor, tracy::Version::Patch, size_t( outSize / 1024 ), float( outSize ) / inSize * 100 ); + } + catch( const tracy::UnsupportedVersion& e ) + { + fprintf( stderr, "The file you are trying to open is from the future version.\n" ); + exit( 1 ); + } + catch( const tracy::NotTracyDump& e ) + { + fprintf( stderr, "The file you are trying to open is not a tracy dump.\n" ); + exit( 1 ); + } + catch( const tracy::LegacyVersion& e ) + { + fprintf( stderr, "The file you are trying to open is from a legacy version.\n" ); + exit( 1 ); + } + + return 0; +}