Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@
xcuserdata
__*

bin/
build/

!CMakeLists.txt

DerivedData
67 changes: 67 additions & 0 deletions MemoryCrawler/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
cmake_minimum_required(VERSION 3.1)

project(MemoryCrawler)

set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17)

# ---------- OPTIONS ----------
option(DEBUG "Debug Version" off)
option(COMMAND_LINE "Command Line Flag" off)

message(STATUS "* DEBUG FLAG: ${DEBUG}")
message(STATUS "* COMMAND LINE FLAG: ${COMMAND_LINE}")

if(COMMAND_LINE)
add_definitions(-DCOMMAND_LINE)
endif(COMMAND_LINE)

if(WIN32 OR MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG /MTd")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG /MTd")
elseif(APPLE)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
else()
if(DEBUG)
add_definitions(-DDEBUG)
endif(DEBUG)
endif()

# ---------- FUNCTIONS ----------
function(get_static_lib_path SUB_FOLDER LIB_NAME DEBUG_OUT RELEASE_OUT)
if (WIN32 OR MSVC)
set(${DEBUG_OUT} "${PROJECT_SOURCE_DIR}/libs/${SUB_FOLDER}/win32/debug/${LIB_NAME}.lib" PARENT_SCOPE)
set(${RELEASE_OUT} "${PROJECT_SOURCE_DIR}/libs/${SUB_FOLDER}/win32/release/${LIB_NAME}.lib" PARENT_SCOPE)
message(STATUS "+ Get static lib debug: ${DEBUG_OUT}")
message(STATUS "+ Get static lib release: ${RELEASE_OUT}")
elseif (APPLE)
set(${DEBUG_OUT} "${PROJECT_SOURCE_DIR}/libs/${SUB_FOLDER}/osx/debug/${LIB_NAME}.a" PARENT_SCOPE)
set(${RELEASE_OUT} "${PROJECT_SOURCE_DIR}/libs/${SUB_FOLDER}/osx/release/${LIB_NAME}.a" PARENT_SCOPE)
message(STATUS "+ Get static lib debug: ${DEBUG_OUT}")
message(STATUS "+ Get static lib release: ${RELEASE_OUT}")
elseif (UNIX)
set(${DEBUG_OUT} "${PROJECT_SOURCE_DIR}/libs/${SUB_FOLDER}/unix/debug/${LIB_NAME}.a" PARENT_SCOPE)
set(${RELEASE_OUT} "${PROJECT_SOURCE_DIR}/libs/${SUB_FOLDER}/unix/release/${LIB_NAME}.a" PARENT_SCOPE)
message(STATUS "+ Get static lib debug: ${DEBUG_OUT}")
message(STATUS "+ Get static lib release: ${RELEASE_OUT}")
endif()
endfunction()

include_directories("${PROJECT_SOURCE_DIR}/MemoryCrawler")
include_directories("${PROJECT_SOURCE_DIR}/MemoryCrawler/libsqlite3")
include_directories("${PROJECT_SOURCE_DIR}/MemoryCrawler/Crawler")
include_directories("${PROJECT_SOURCE_DIR}/MemoryCrawler/md5")
include_directories("${PROJECT_SOURCE_DIR}/UnityProfiler")
include_directories("${PROJECT_SOURCE_DIR}/UnityProfiler/Crawler")

add_subdirectory(MemoryCrawler)
add_subdirectory(MemoryCrawler/Crawler)
add_subdirectory(MemoryCrawler/libsqlite3)
add_subdirectory(MemoryCrawler/md5)
add_subdirectory(UnityProfiler)
add_subdirectory(UnityProfiler/Crawler)
26 changes: 24 additions & 2 deletions MemoryCrawler/MemoryCrawler.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
6BD1B074227F2DAE00E3CBD7 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 6BE8899F225C9FF90029BB09 /* libsqlite3.tbd */; };
6BE889A0225C9FFA0029BB09 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 6BE8899F225C9FF90029BB09 /* libsqlite3.tbd */; };
6BE889A3225CA16B0029BB09 /* cache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE889A2225CA16B0029BB09 /* cache.cpp */; };
E1E73E16259C201C009B643C /* md5c.c in Sources */ = {isa = PBXBuildFile; fileRef = E1E73E15259C201C009B643C /* md5c.c */; };
E1E73E17259C2022009B643C /* md5c.c in Sources */ = {isa = PBXBuildFile; fileRef = E1E73E15259C201C009B643C /* md5c.c */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -90,6 +92,11 @@
6BE8899F225C9FF90029BB09 /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; };
6BE889A1225CA16B0029BB09 /* cache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cache.h; sourceTree = "<group>"; };
6BE889A2225CA16B0029BB09 /* cache.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = cache.cpp; sourceTree = "<group>"; };
E1E73E12259C201C009B643C /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
E1E73E13259C201C009B643C /* global.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = global.h; sourceTree = "<group>"; };
E1E73E14259C201C009B643C /* md5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = md5.h; sourceTree = "<group>"; };
E1E73E15259C201C009B643C /* md5c.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = md5c.c; sourceTree = "<group>"; };
E1E73E18259C2099009B643C /* common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = common.h; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -134,6 +141,8 @@
6B0AC7412252FC5D00B58C69 /* MemoryCrawler */ = {
isa = PBXGroup;
children = (
E1E73E18259C2099009B643C /* common.h */,
E1E73E11259C201C009B643C /* md5 */,
6B51B43B2254735E00E05EAE /* Crawler */,
6B0AC7422252FC5D00B58C69 /* main.cpp */,
6BD1B069227F1DD300E3CBD7 /* utils.cpp */,
Expand Down Expand Up @@ -199,6 +208,17 @@
name = Frameworks;
sourceTree = "<group>";
};
E1E73E11259C201C009B643C /* md5 */ = {
isa = PBXGroup;
children = (
E1E73E12259C201C009B643C /* CMakeLists.txt */,
E1E73E13259C201C009B643C /* global.h */,
E1E73E14259C201C009B643C /* md5.h */,
E1E73E15259C201C009B643C /* md5c.c */,
);
path = md5;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -282,6 +302,7 @@
6B0AC7432252FC5D00B58C69 /* main.cpp in Sources */,
6B5343722255B43F003CDBD0 /* serialize.cpp in Sources */,
6B70A2CB23697310005A8D41 /* fragment.cpp in Sources */,
E1E73E16259C201C009B643C /* md5c.c in Sources */,
6B3498DB2269643400E7E4EC /* stat.cpp in Sources */,
6B7E64C2235FFC120054958C /* rserialize.cpp in Sources */,
6BD1B06B227F1DD300E3CBD7 /* utils.cpp in Sources */,
Expand All @@ -296,6 +317,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
E1E73E17259C2022009B643C /* md5c.c in Sources */,
6B008E50228D643400F18852 /* types.cpp in Sources */,
6BD1B070227F2D7100E3CBD7 /* serialize.cpp in Sources */,
6BD1B06E227F2D1000E3CBD7 /* crawler.cpp in Sources */,
Expand Down Expand Up @@ -465,7 +487,7 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEPLOYMENT_LOCATION = YES;
DEVELOPMENT_TEAM = PRLP6W5S32;
DEVELOPMENT_TEAM = 58TJ64422P;
DSTROOT = /;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand All @@ -476,7 +498,7 @@
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEPLOYMENT_LOCATION = YES;
DEVELOPMENT_TEAM = PRLP6W5S32;
DEVELOPMENT_TEAM = 58TJ64422P;
DSTROOT = /;
GCC_PREPROCESSOR_DEFINITIONS = "PERF_DEBUG=1";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -38,8 +36,8 @@
ReferencedContainer = "container:MemoryCrawler.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
Expand Down Expand Up @@ -71,8 +69,6 @@
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -38,8 +36,8 @@
ReferencedContainer = "container:MemoryCrawler.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
Expand Down Expand Up @@ -67,8 +65,6 @@
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
27 changes: 27 additions & 0 deletions MemoryCrawler/MemoryCrawler/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
aux_source_directory(. SRC_FILES)

file(GLOB PROJ_HEADERS "*.h" "./Crawler/*.h")

source_group("Headers" FILES ${PROJ_HEADERS})

# set output path
set(EXECUTABLE_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/bin")

add_library(
MemoryCrawler_Lib
${SRC_FILES}
${PROJ_HEADERS}
)

add_executable(
MemoryCrawler
${SRC_FILES}
${PROJ_HEADERS}
)

target_link_libraries(
MemoryCrawler
Sqlite3
MemoryCrawler_Crawler
md5
)
11 changes: 11 additions & 0 deletions MemoryCrawler/MemoryCrawler/Crawler/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
aux_source_directory(. SRC_FILES)

file(GLOB PROJ_HEADERS "*.h")

source_group("Headers" FILES ${PROJ_HEADERS})

add_library(
MemoryCrawler_Crawler
${SRC_FILES}
${PROJ_HEADERS}
)
7 changes: 4 additions & 3 deletions MemoryCrawler/MemoryCrawler/Crawler/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// Copyright © 2019 larryhou. All rights reserved.
//

#include "cache.h"
#include <sys/stat.h>
#include <string>
#include "common.h"
#include "cache.h"

SnapshotCrawlerCache::SnapshotCrawlerCache()
{
Expand Down Expand Up @@ -589,7 +589,8 @@ void SnapshotCrawlerCache::save(MemorySnapshotCrawler &crawler)
if (crawler.snapshot->uuid == string()) {return;}

__sampler.begin("SnapshotCrawlerCache::save");
mkdir(__workspace, 0777);

MKDIR(__workspace, 0777);

char filepath[64];
sprintf(filepath, "%s/%s.db", __workspace, crawler.snapshot->uuid.c_str());
Expand Down
2 changes: 1 addition & 1 deletion MemoryCrawler/MemoryCrawler/Crawler/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#define cache_h

#include <stdio.h>
#include <sqlite3.h>
#include <new>
#include "sqlite3.h"
#include "crawler.h"
#include "perf.h"

Expand Down
Loading