-
Notifications
You must be signed in to change notification settings - Fork 15.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: dump correct breakpad symbols on macOS #19042
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
51430c2
fix: dump correct symbols on macOS
nornagon 3cd3c23
refactor symbol dumping
nornagon 376254b
.exe/.dll on windows
nornagon 6e238ff
dump .exe.pdb/.dll.pdb; also add path for msdia140.dll
nornagon 63434a4
undo breakpad_symbols.zip rename
nornagon c1a24af
dump_syms.exe doesn't support -i on windows
nornagon 85ed1ea
remove unused windows symbol generation script
nornagon 46f0c9c
win fix 🤞🤞
nornagon fdb2c85
import errno
nornagon a224b96
use out_dir
nornagon e4f8d92
i tender my resignation
nornagon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import("//tools/grit/repack.gni") | |
import("//tools/v8_context_snapshot/v8_context_snapshot.gni") | ||
import("//v8/gni/snapshot_toolchain.gni") | ||
import("build/asar.gni") | ||
import("build/extract_symbols.gni") | ||
import("build/npm.gni") | ||
import("build/templated_file.gni") | ||
import("build/tsc.gni") | ||
|
@@ -639,6 +640,7 @@ if (is_mac) { | |
electron_helper_name = "$electron_product_name Helper" | ||
electron_login_helper_name = "$electron_product_name Login Helper" | ||
electron_framework_version = "A" | ||
electron_version = read_file("ELECTRON_VERSION", "trim string") | ||
|
||
bundle_data("electron_framework_resources") { | ||
public_deps = [ | ||
|
@@ -760,7 +762,6 @@ if (is_mac) { | |
} | ||
info_plist = "shell/common/resources/mac/Info.plist" | ||
|
||
electron_version = read_file("ELECTRON_VERSION", "trim string") | ||
extra_substitutions = [ | ||
"ELECTRON_BUNDLE_ID=$electron_mac_bundle_id.framework", | ||
"ELECTRON_VERSION=$electron_version", | ||
|
@@ -927,7 +928,6 @@ if (is_mac) { | |
deps += [ ":electron_login_helper_app" ] | ||
} | ||
info_plist = "shell/browser/resources/mac/Info.plist" | ||
electron_version = read_file("ELECTRON_VERSION", "trim string") | ||
extra_substitutions = [ | ||
"ELECTRON_BUNDLE_ID=$electron_mac_bundle_id", | ||
"ELECTRON_VERSION=$electron_version", | ||
|
@@ -937,6 +937,76 @@ if (is_mac) { | |
"@executable_path/../Frameworks", | ||
] | ||
} | ||
|
||
if (enable_dsyms) { | ||
extract_symbols("electron_framework_syms") { | ||
binary = "$root_out_dir/$electron_framework_name.framework/Versions/$electron_framework_version/$electron_framework_name" | ||
symbol_dir = "$root_out_dir/breakpad_symbols" | ||
dsym_file = "$root_out_dir/$electron_framework_name.dSYM/Contents/Resources/DWARF/$electron_framework_name" | ||
deps = [ | ||
":electron_framework", | ||
] | ||
} | ||
|
||
extract_symbols("electron_helper_syms") { | ||
binary = "$root_out_dir/$electron_helper_name.app/Contents/MacOS/$electron_helper_name" | ||
symbol_dir = "$root_out_dir/breakpad_symbols" | ||
dsym_file = "$root_out_dir/$electron_helper_name.dSYM/Contents/Resources/DWARF/$electron_helper_name" | ||
deps = [ | ||
":electron_helper_app", | ||
] | ||
} | ||
|
||
extract_symbols("electron_app_syms") { | ||
binary = "$root_out_dir/$electron_product_name.app/Contents/MacOS/$electron_product_name" | ||
symbol_dir = "$root_out_dir/breakpad_symbols" | ||
dsym_file = "$root_out_dir/$electron_product_name.dSYM/Contents/Resources/DWARF/$electron_product_name" | ||
deps = [ | ||
":electron_app", | ||
] | ||
} | ||
|
||
extract_symbols("swiftshader_egl_syms") { | ||
binary = "$root_out_dir/libswiftshader_libEGL.dylib" | ||
symbol_dir = "$root_out_dir/breakpad_symbols" | ||
dsym_file = "$root_out_dir/libswiftshader_libEGL.dylib.dSYM/Contents/Resources/DWARF/libswiftshader_libEGL.dylib" | ||
deps = [ | ||
"//third_party/swiftshader/src/OpenGL/libEGL:swiftshader_libEGL", | ||
] | ||
} | ||
|
||
extract_symbols("swiftshader_gles_syms") { | ||
binary = "$root_out_dir/libswiftshader_libGLESv2.dylib" | ||
symbol_dir = "$root_out_dir/breakpad_symbols" | ||
dsym_file = "$root_out_dir/libswiftshader_libGLESv2.dylib.dSYM/Contents/Resources/DWARF/libswiftshader_libGLESv2.dylib" | ||
deps = [ | ||
"//third_party/swiftshader/src/OpenGL/libGLESv2:swiftshader_libGLESv2", | ||
] | ||
} | ||
|
||
extract_symbols("crashpad_handler_syms") { | ||
binary = "$root_out_dir/crashpad_handler" | ||
symbol_dir = "$root_out_dir/breakpad_symbols" | ||
dsym_file = "$root_out_dir/crashpad_handler.dSYM/Contents/Resources/DWARF/crashpad_handler" | ||
deps = [ | ||
"//third_party/crashpad/crashpad/handler:crashpad_handler", | ||
] | ||
} | ||
|
||
group("electron_symbols") { | ||
deps = [ | ||
":crashpad_handler_syms", | ||
":electron_app_syms", | ||
":electron_framework_syms", | ||
":electron_helper_syms", | ||
":swiftshader_egl_syms", | ||
":swiftshader_gles_syms", | ||
] | ||
} | ||
} else { | ||
group("electron_symbols") { | ||
} | ||
} | ||
} else { | ||
windows_manifest("electron_app_manifest") { | ||
sources = [ | ||
|
@@ -1023,6 +1093,49 @@ if (is_mac) { | |
} | ||
} | ||
} | ||
|
||
if (is_official_build) { | ||
if (is_linux) { | ||
_target_executable_suffix = "" | ||
_target_shared_library_suffix = ".so" | ||
} else if (is_win) { | ||
_target_executable_suffix = ".exe" | ||
_target_shared_library_suffix = ".dll" | ||
} | ||
|
||
extract_symbols("electron_app_symbols") { | ||
binary = "$root_out_dir/$electron_project_name$_target_executable_suffix" | ||
symbol_dir = "$root_out_dir/breakpad_symbols" | ||
deps = [ | ||
":electron_app", | ||
] | ||
} | ||
|
||
extract_symbols("swiftshader_egl_symbols") { | ||
binary = "$root_out_dir/swiftshader/libEGL$_target_shared_library_suffix" | ||
symbol_dir = "$root_out_dir/breakpad_symbols" | ||
deps = [ | ||
"//third_party/swiftshader/src/OpenGL/libEGL:swiftshader_libEGL", | ||
] | ||
} | ||
|
||
extract_symbols("swiftshader_gles_symbols") { | ||
binary = | ||
"$root_out_dir/swiftshader/libGLESv2$_target_shared_library_suffix" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nornagon The symbols for libGLESv2.dll are not present in Sentry even though the other Electron symbols are there. See: https://sentry.io/share/issue/d07971e24b74434f9d3bbfa520b47e0a/ Do you know why that may be? Are we failing to package libGLESv2.dll.pdb on Windows? |
||
symbol_dir = "$root_out_dir/breakpad_symbols" | ||
deps = [ | ||
"//third_party/swiftshader/src/OpenGL/libGLESv2:swiftshader_libGLESv2", | ||
] | ||
} | ||
|
||
group("electron_symbols") { | ||
deps = [ | ||
":electron_app_symbols", | ||
":swiftshader_egl_symbols", | ||
":swiftshader_gles_symbols", | ||
] | ||
} | ||
} | ||
} | ||
|
||
template("dist_zip") { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from __future__ import print_function | ||
|
||
import collections | ||
import os | ||
import subprocess | ||
import sys | ||
import errno | ||
|
||
# The BINARY_INFO tuple describes a binary as dump_syms identifies it. | ||
BINARY_INFO = collections.namedtuple('BINARY_INFO', | ||
['platform', 'arch', 'hash', 'name']) | ||
|
||
def get_module_info(header_info): | ||
# header info is of the form "MODULE $PLATFORM $ARCH $HASH $BINARY" | ||
info_split = header_info.strip().split(' ', 4) | ||
if len(info_split) != 5 or info_split[0] != 'MODULE': | ||
return None | ||
return BINARY_INFO(*info_split[1:]) | ||
|
||
def get_symbol_path(symbol_data): | ||
module_info = get_module_info(symbol_data[:symbol_data.index('\n')]) | ||
if not module_info: | ||
raise Exception("Couldn't get module info for binary '{}'".format(binary)) | ||
return os.path.join(module_info.name, module_info.hash, module_info.name + ".sym") | ||
|
||
def mkdir_p(path): | ||
"""Simulates mkdir -p.""" | ||
try: | ||
os.makedirs(path) | ||
except OSError as e: | ||
if e.errno == errno.EEXIST and os.path.isdir(path): | ||
pass | ||
else: raise | ||
|
||
def main(dump_syms, binary, out_dir, stamp_file, dsym_file=None): | ||
args = [dump_syms] | ||
if dsym_file: | ||
args += ["-g", dsym_file] | ||
args += [binary] | ||
|
||
symbol_data = subprocess.check_output(args) | ||
symbol_path = os.path.join(out_dir, get_symbol_path(symbol_data)) | ||
mkdir_p(os.path.dirname(symbol_path)) | ||
|
||
with open(symbol_path, 'w') as out: | ||
out.write(symbol_data) | ||
|
||
with open(stamp_file, 'w'): | ||
pass | ||
|
||
if __name__ == '__main__': | ||
main(*sys.argv[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import("//build/toolchain/toolchain.gni") | ||
|
||
# Extracts symbols from a binary into a symbol file using dump_syms. | ||
# | ||
# Args: | ||
# binary: Path to the binary containing symbols to extract, e.g.: | ||
# "$root_out_dir/electron" | ||
# symbol_dir: Desired output directory for symbols, e.g.: | ||
# "$root_out_dir/breakpad_symbols" | ||
|
||
if (host_os == "win") { | ||
_host_executable_suffix = ".exe" | ||
} else { | ||
_host_executable_suffix = "" | ||
} | ||
|
||
template("extract_symbols") { | ||
action(target_name) { | ||
forward_variables_from(invoker, | ||
[ | ||
"deps", | ||
"testonly", | ||
]) | ||
assert(defined(invoker.binary), "Need binary to dump") | ||
assert(defined(invoker.symbol_dir), "Need directory for symbol output") | ||
|
||
dump_syms_label = "//third_party/breakpad:dump_syms($host_toolchain)" | ||
dump_syms_binary = get_label_info(dump_syms_label, "root_out_dir") + | ||
"/dump_syms$_host_executable_suffix" | ||
|
||
script = "//electron/build/dump_syms.py" | ||
inputs = [ | ||
invoker.binary, | ||
dump_syms_binary, | ||
] | ||
stamp_file = "${target_gen_dir}/${target_name}.stamp" | ||
outputs = [ | ||
stamp_file, | ||
] | ||
args = [ | ||
"./" + rebase_path(dump_syms_binary, root_build_dir), | ||
rebase_path(invoker.binary, root_build_dir), | ||
rebase_path(invoker.symbol_dir, root_build_dir), | ||
rebase_path(stamp_file, root_build_dir), | ||
] | ||
if (defined(invoker.dsym_file)) { | ||
args += [ rebase_path(invoker.dsym_file, root_build_dir) ] | ||
} | ||
|
||
if (!defined(deps)) { | ||
deps = [] | ||
} | ||
deps += [ dump_syms_label ] | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This never appears to be set? Unless I'm missing a thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's set in Chromium's GN files.