Skip to content

Commit

Permalink
Optimize fast dump:
Browse files Browse the repository at this point in the history
1. Support x86/x86_64 for emulator.
2. Optimize symbol search performance & reliability, support symbol in .gnu_debugdata.
3. Android R fast dump uses another implementation, which is consistent with the lower version.
4. Use c++17 instead of c++11 for make_unique.
5. Workaround for NDK bug: android/ndk#721

Signed-off-by: xueqiushi <xueqiushi@kuaishou.com>
  • Loading branch information
alhah committed Sep 20, 2021
1 parent e6e02bb commit f2c9fe3
Show file tree
Hide file tree
Showing 99 changed files with 27,761 additions and 807 deletions.
78 changes: 54 additions & 24 deletions android-fast-dump/.clang-format
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
Expand All @@ -16,12 +16,12 @@ AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
Expand Down Expand Up @@ -50,54 +50,84 @@ BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 100
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
- Regex: '^<.*\.h>'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
Expand All @@ -111,13 +141,13 @@ SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
Standard: Auto
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
Expand Down
4 changes: 2 additions & 2 deletions android-fast-dump/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ android {

externalNativeBuild {
cmake {
abiFilters 'armeabi-v7a', 'arm64-v8a'
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_STL=c++_shared", "-DCMAKE_VERBOSE_MAKEFILE=ON"
cppFlags '-Wl,--gc-sections -fno-exceptions -fno-rtti -fvisibility=hidden'
cppFlags "-std=c++17", "-Wl,--gc-sections", "-fno-exceptions", "-fno-rtti", "-fvisibility=hidden", "-flto"
}
}

Expand Down
21 changes: 17 additions & 4 deletions android-fast-dump/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ set(TARGET fast-dump)
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)

project(${TARGET} LANGUAGES CXX)
project(${TARGET} CXX)

set(CMAKE_CXX_STANDARD 11)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include/
${CMAKE_SOURCE_DIR}/lzma
)

add_compile_options(-Wall -Wextra -Werror -Wno-unused-command-line-argument)
add_subdirectory(lzma)

set(CURRENT_SOURCES fast_dump.cc kwai_dlfcn.cc elf_reader.cc)
# Workaround for NDK bug: https://github.com/android/ndk/issues/721
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -flto=full")

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
Expand All @@ -22,7 +29,10 @@ add_library( # Sets the name of the library.
SHARED

# Provides a relative path to your source file(s).
fast_dump.cc kwai_dlfcn.cc)
${CURRENT_SOURCES}
)

target_compile_options(${TARGET} PRIVATE -Wall -Wextra -Werror -Wno-unused-command-line-argument)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
Expand All @@ -43,6 +53,9 @@ find_library( # Sets the name of the path variable.

target_link_libraries( # Specifies the target library.
${TARGET}

lzma

# Links the target library to the log library
# included in the NDK.
${log-lib})
Loading

0 comments on commit f2c9fe3

Please sign in to comment.