diff --git a/BUILD.gn b/BUILD.gn index 0cd96299..071b68d 100644 --- a/BUILD.gn +++ b/BUILD.gn
@@ -269,7 +269,6 @@ "//ppapi/examples/video_encode", "//printing:printing_unittests", "//third_party/cacheinvalidation:cacheinvalidation_unittests", - "//third_party/codesighs", "//third_party/pdfium/samples:pdfium_test", "//third_party/webrtc/tools:frame_analyzer", "//tools/battor_agent", @@ -552,7 +551,6 @@ "//ipc:ipc_perftests", "//media:media_perftests", "//net:dump_cache", - "//third_party/codesighs:maptsvdifftool", "//third_party/libphonenumber:libphonenumber_unittests", "//ui/compositor:compositor_unittests", ] @@ -622,7 +620,6 @@ "//mojo/edk/test:mojo_public_system_perftests", "//services/service_manager/public/cpp", "//testing/gmock:gmock_main", - "//third_party/codesighs:nm2tsv", ] if (!is_android) { @@ -687,7 +684,6 @@ "//sandbox/win:sbox_unittests", "//sandbox/win:sbox_validation_tests", "//testing/gtest:gtest_main", - "//third_party/codesighs:msmap2tsv", "//third_party/pdfium/samples:pdfium_diff", "//tools/win/chromeexts:chromeexts", ]
diff --git a/build/android/adb_android_webview_command_line b/build/android/adb_android_webview_command_line index 9075918..2303392 100755 --- a/build/android/adb_android_webview_command_line +++ b/build/android/adb_android_webview_command_line
@@ -13,5 +13,4 @@ # To remove all content shell flags, pass an empty string for the flags: # adb_android_webview_command_line "" -exec $(dirname $0)/adb_command_line.py --device-path \ - /data/local/tmp/android-webview-command-line "$@" +exec $(dirname $0)/adb_command_line.py --name android-webview-command-line "$@"
diff --git a/build/android/adb_cast_shell_command_line b/build/android/adb_cast_shell_command_line index bcbcbeb..a9ccff2a 100755 --- a/build/android/adb_cast_shell_command_line +++ b/build/android/adb_cast_shell_command_line
@@ -8,7 +8,7 @@ # # Otherwise, the given flags are used to REPLACE (not modify) the cast shell # flags. For example: -# apk_command_line --enable-media-thread-for-media-playback +# adb_cast_shell_command_line --enable-media-thread-for-media-playback # # If multiple devices are connected, use the --device argument to specify the # device ID. You can use @@ -16,7 +16,6 @@ # ... to find the device's ID. # # To remove all content shell flags, pass an empty string for the flags: -# apk_command_line "" +# adb_cast_shell_command_line "" -exec $(dirname $0)/../../build/android/adb_command_line.py -e cast_shell \ - --device-path /data/local/tmp/castshell-command-line "$@" +exec $(dirname $0)/adb_command_line.py --name castshell-command-line "$@"
diff --git a/build/android/adb_chrome_public_command_line b/build/android/adb_chrome_public_command_line index 913c21b..86ece8c 100755 --- a/build/android/adb_chrome_public_command_line +++ b/build/android/adb_chrome_public_command_line
@@ -13,11 +13,4 @@ # To remove all Chrome flags, pass an empty string for the flags: # adb_chrome_public_command_line "" -# The command line arguments file is transitioning from -# /data/local/chrome-command-line to /data/local/tmp/chrome-command-line -# (https://crbug.com/593720). To support both old and new builds of -# Chrome, we currently write the same flags to both places. -$(dirname $0)/adb_command_line.py --device-path \ - /data/local/tmp/chrome-command-line "$@" && -exec $(dirname $0)/adb_command_line.py --device-path \ - /data/local/chrome-command-line "$@" +exec $(dirname $0)/adb_command_line.py --name chrome-command-line "$@"
diff --git a/build/android/adb_command_line.py b/build/android/adb_command_line.py index 948bc89..352c9cc5 100755 --- a/build/android/adb_command_line.py +++ b/build/android/adb_command_line.py
@@ -7,18 +7,19 @@ import argparse import os +import posixpath import sys import devil_chromium from devil.android import device_utils -from devil.android import device_errors +from devil.android import flag_changer from devil.utils import cmd_helper def main(): parser = argparse.ArgumentParser(description=__doc__) - parser.usage = '''%(prog)s --device-path PATH [--device SERIAL] [flags...] + parser.usage = '''%(prog)s --name FILENAME [--device SERIAL] [flags...] No flags: Prints existing command-line file. Empty string: Deletes command-line file. @@ -27,59 +28,58 @@ ''' parser.add_argument('-d', '--device', dest='devices', action='append', default=[], help='Target device serial (repeatable).') - parser.add_argument('--device-path', required=True, - help='Remote path to flags file.') + parser.add_argument('--name', required=True, + help='Name of file where to store flags on the device.') + parser.add_argument('--device-path', help='(deprecated) No longer needed to' + ' supply a device path.') parser.add_argument('-e', '--executable', dest='executable', default='chrome', - help='Name of the executable.') + help='(deprecated) No longer used.') parser.add_argument('--adb-path', type=os.path.abspath, help='Path to the adb binary.') args, remote_args = parser.parse_known_args() - devil_chromium.Initialize(adb_path=args.adb_path) + if args.device_path: + args.name = posixpath.basename(args.device_path) + print ('warning: --device-path option is deprecated,' + ' --name %s is now enough.' + % cmd_helper.SingleQuote(args.name)) - as_root = not args.device_path.startswith('/data/local/tmp/') + devil_chromium.Initialize(adb_path=args.adb_path) devices = device_utils.DeviceUtils.HealthyDevices(device_arg=args.devices, default_retries=0) all_devices = device_utils.DeviceUtils.parallel(devices) - def print_args(): - def read_flags(device): - try: - return device.ReadFile(args.device_path, as_root=as_root).rstrip() - except device_errors.CommandFailedError: - return '' # File might not exist. - - descriptions = all_devices.pMap(lambda d: d.build_description).pGet(None) - flags = all_devices.pMap(read_flags).pGet(None) - for d, desc, flags in zip(devices, descriptions, flags): - print ' %s (%s): %r' % (d, desc, flags) - - # No args == print flags. if not remote_args: - print 'Existing flags (in %s):' % args.device_path - print_args() - return 0 + # No args == do not update, just print flags. + remote_args = None + action = '' + elif len(remote_args) == 1 and not remote_args[0]: + # Single empty string arg == delete flags + remote_args = [] + action = 'Deleted command line file. ' + else: + action = 'Wrote command line file. ' - # Empty string arg == delete flags file. - if len(remote_args) == 1 and not remote_args[0]: - def delete_flags(device): - device.RunShellCommand(['rm', '-f', args.device_path], as_root=as_root) - all_devices.pMap(delete_flags).pGet(None) - print 'Deleted %s' % args.device_path - return 0 + def update_flags(device): + changer = flag_changer.FlagChanger(device, args.name) + if remote_args is not None: + flags = changer.ReplaceFlags(remote_args) + else: + flags = changer.GetCurrentFlags() + return (device, device.build_description, flags) - # Set flags. - quoted_args = ' '.join(cmd_helper.SingleQuote(x) for x in remote_args) - flags_str = ' '.join([args.executable, quoted_args]) + updated_values = all_devices.pMap(update_flags).pGet(None) - def write_flags(device): - device.WriteFile(args.device_path, flags_str, as_root=as_root) - device.RunShellCommand(['chmod', '0664', args.device_path], as_root=as_root) + print '%sCurrent flags (in %s):' % (action, args.name) + for d, desc, flags in updated_values: + if flags: + # Shell-quote flags for easy copy/paste as new args on the terminal. + quoted_flags = ' '.join(cmd_helper.SingleQuote(f) for f in sorted(flags)) + else: + quoted_flags = '( empty )' + print ' %s (%s): %s' % (d, desc, quoted_flags) - all_devices.pMap(write_flags).pGet(None) - print 'Wrote flags to %s' % args.device_path - print_args() return 0
diff --git a/build/android/adb_content_shell_command_line b/build/android/adb_content_shell_command_line index 02ef802..8e1b53ca 100755 --- a/build/android/adb_content_shell_command_line +++ b/build/android/adb_content_shell_command_line
@@ -13,5 +13,4 @@ # To remove all content shell flags, pass an empty string for the flags: # adb_content_shell_command_line "" -exec $(dirname $0)/adb_command_line.py --device-path \ - /data/local/tmp/content-shell-command-line "$@" +exec $(dirname $0)/adb_command_line.py --name content-shell-command-line "$@"
diff --git a/build/android/adb_system_webview_command_line b/build/android/adb_system_webview_command_line index 376b0b3d..a0d270582 100755 --- a/build/android/adb_system_webview_command_line +++ b/build/android/adb_system_webview_command_line
@@ -11,7 +11,6 @@ # adb_system_webview_command_line --enable-webgl # # To remove all content shell flags, pass an empty string for the flags: -# adb_android_webview_command_line "" +# adb_system_webview_command_line "" -exec $(dirname $0)/adb_command_line.py --device-path \ - /data/local/tmp/webview-command-line "$@" +exec $(dirname $0)/adb_command_line.py --name webview-command-line "$@"
diff --git a/chrome/browser/resources/chromeos/login/oobe.js b/chrome/browser/resources/chromeos/login/oobe.js index 6386ed6..6f91530 100644 --- a/chrome/browser/resources/chromeos/login/oobe.js +++ b/chrome/browser/resources/chromeos/login/oobe.js
@@ -333,9 +333,11 @@ if (loadTimeData.getString('newOobeUI') == 'on') { $('oobe').setAttribute('md-mode', 'true'); $('oobe-shield').setAttribute('md-mode', 'true'); + $('popup-overlay').setAttribute('md-mode', 'true'); } else { $('oobe').removeAttribute('md-mode'); $('oobe-shield').removeAttribute('md-mode'); + $('popup-overlay').removeAttribute('md-mode'); } }, };
diff --git a/chrome/browser/resources/chromeos/login/oobe_popup_overlay.css b/chrome/browser/resources/chromeos/login/oobe_popup_overlay.css index d25f0da7..ec2127b 100644 --- a/chrome/browser/resources/chromeos/login/oobe_popup_overlay.css +++ b/chrome/browser/resources/chromeos/login/oobe_popup_overlay.css
@@ -17,6 +17,10 @@ z-index: 5; } +#popup-overlay[md-mode] { + background: rgba(0, 0, 0, .5); +} + .oobe-popup { background: white; border: 1px solid rgb(188, 193, 208);
diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc index 219a2405c..00eadabc 100644 --- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc +++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
@@ -1218,12 +1218,7 @@ popup_model->result().default_match()->destination_url.spec()); } -#if defined(OS_WIN) -#define MAYBE_DeleteItem DISABLED_DeleteItem -#else -#define MAYBE_DeleteItem DeleteItem -#endif -IN_PROC_BROWSER_TEST_F(OmniboxViewTest, MAYBE_DeleteItem) { +IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DeleteItem) { // Disable the search provider, to make sure the popup contains only history // items. TemplateURLService* model =
diff --git a/chrome/browser/ui/views/website_settings/permission_selector_row.cc b/chrome/browser/ui/views/website_settings/permission_selector_row.cc index 00f49fbc..6ba6b2270 100644 --- a/chrome/browser/ui/views/website_settings/permission_selector_row.cc +++ b/chrome/browser/ui/views/website_settings/permission_selector_row.cc
@@ -293,12 +293,7 @@ } void PermissionSelectorRow::ChildPreferredSizeChanged(View* child) { - SizeToPreferredSize(); - // FIXME: The parent is only a plain |View| that is used as a - // container/box/panel. The SizeToPreferredSize method of the parent is - // called here directly in order not to implement a custom |View| class with - // its own implementation of the ChildPreferredSizeChanged method. - parent()->SizeToPreferredSize(); + Layout(); } PermissionSelectorRow::~PermissionSelectorRow() {
diff --git a/chromeos/CHROMEOS_LKGM b/chromeos/CHROMEOS_LKGM index 164fb43d..4aee7f8 100644 --- a/chromeos/CHROMEOS_LKGM +++ b/chromeos/CHROMEOS_LKGM
@@ -1 +1 @@ -9196.0.0 \ No newline at end of file +9201.0.0 \ No newline at end of file
diff --git a/content/browser/loader/async_resource_handler.cc b/content/browser/loader/async_resource_handler.cc index 7503da6..3481fc5 100644 --- a/content/browser/loader/async_resource_handler.cc +++ b/content/browser/loader/async_resource_handler.cc
@@ -73,6 +73,17 @@ GetNumericArg("resource-buffer-max-allocation-size", &kMaxAllocationSize); } +// This enum is used for logging a histogram and should not be reordered. +enum ExpectedContentSizeResult { + EQ_RESPONSE_BODY = 0, + EQ_RESPONSE_BODY_GT_EQ_BUFFER_SIZE = 1, + GT_EQ_BUFFER_SIZE = 2, + LT_RESPONSE_BODY = 3, + GT_RESPONSE_BODY = 4, + UNKNOWN = 5, + EXPECTED_CONTENT_MAX, +}; + } // namespace // Used when kOptimizeLoadingIPCForSmallResources is enabled. @@ -192,14 +203,14 @@ scoped_refptr<ResourceBuffer> backing_; }; -AsyncResourceHandler::AsyncResourceHandler( - net::URLRequest* request, - ResourceDispatcherHostImpl* rdh) +AsyncResourceHandler::AsyncResourceHandler(net::URLRequest* request, + ResourceDispatcherHostImpl* rdh) : ResourceHandler(request), ResourceMessageDelegate(request), rdh_(rdh), pending_data_count_(0), allocation_size_(0), + total_read_body_bytes_(0), did_defer_(false), has_checked_for_sufficient_resources_(false), sent_received_response_msg_(false), @@ -396,6 +407,8 @@ buffer_->ShrinkLastAllocation(bytes_read); + total_read_body_bytes_ += bytes_read; + if (!sent_data_buffer_msg_) { base::SharedMemoryHandle handle = base::SharedMemory::DuplicateHandle( buffer_->GetSharedMemory().handle()); @@ -552,6 +565,34 @@ } inlining_helper_->RecordHistogram(elapsed_time); + + // Record if content size was known in advance. + int64_t expected_content_size = request()->GetExpectedContentSize(); + ExpectedContentSizeResult expected_content_size_result = + ExpectedContentSizeResult::UNKNOWN; + if (expected_content_size >= 0) { + // Compare response body size to expected content size. + if (expected_content_size == total_read_body_bytes_ && + expected_content_size >= kBufferSize) { + expected_content_size_result = + ExpectedContentSizeResult::EQ_RESPONSE_BODY_GT_EQ_BUFFER_SIZE; + } else if (expected_content_size >= kBufferSize) { + expected_content_size_result = + ExpectedContentSizeResult::GT_EQ_BUFFER_SIZE; + } else if (expected_content_size == total_read_body_bytes_) { + expected_content_size_result = + ExpectedContentSizeResult::EQ_RESPONSE_BODY; + } else if (expected_content_size < total_read_body_bytes_) { + expected_content_size_result = + ExpectedContentSizeResult::LT_RESPONSE_BODY; + } else { + expected_content_size_result = + ExpectedContentSizeResult::GT_RESPONSE_BODY; + } + } + UMA_HISTOGRAM_ENUMERATION("Net.ResourceLoader.ExpectedContentSizeResult", + expected_content_size_result, + ExpectedContentSizeResult::EXPECTED_CONTENT_MAX); } void AsyncResourceHandler::SendUploadProgress(
diff --git a/content/browser/loader/async_resource_handler.h b/content/browser/loader/async_resource_handler.h index dbf3b035..a664c3e 100644 --- a/content/browser/loader/async_resource_handler.h +++ b/content/browser/loader/async_resource_handler.h
@@ -79,6 +79,10 @@ int allocation_size_; + // Size of received body. Used for comparison with expected content size, + // which is reported to UMA. + int64_t total_read_body_bytes_; + bool first_chunk_read_ = false; bool did_defer_;
diff --git a/content/renderer/media/media_stream_video_track.cc b/content/renderer/media/media_stream_video_track.cc index dede54fe..e9eece0 100644 --- a/content/renderer/media/media_stream_video_track.cc +++ b/content/renderer/media/media_stream_video_track.cc
@@ -308,6 +308,21 @@ settings.width = format->frame_size.width(); settings.height = format->frame_size.height(); } + switch (source_->device_info().device.video_facing) { + case MEDIA_VIDEO_FACING_NONE: + settings.facingMode = blink::WebMediaStreamTrack::FacingMode::None; + break; + case MEDIA_VIDEO_FACING_USER: + settings.facingMode = blink::WebMediaStreamTrack::FacingMode::User; + break; + case MEDIA_VIDEO_FACING_ENVIRONMENT: + settings.facingMode = + blink::WebMediaStreamTrack::FacingMode::Environment; + break; + default: + settings.facingMode = blink::WebMediaStreamTrack::FacingMode::None; + break; + } } // TODO(hta): Extract the real value. settings.deviceId = blink::WebString("video device ID");
diff --git a/content/renderer/media/media_stream_video_track_unittest.cc b/content/renderer/media/media_stream_video_track_unittest.cc index d95e14c3..f071e08 100644 --- a/content/renderer/media/media_stream_video_track_unittest.cc +++ b/content/renderer/media/media_stream_video_track_unittest.cc
@@ -255,4 +255,17 @@ sink.DisconnectFromTrack(); } +TEST_F(MediaStreamVideoTrackTest, GetSettings) { + blink::WebMediaStreamTrack track = CreateTrack(); + MediaStreamVideoTrack* const native_track = + MediaStreamVideoTrack::GetVideoTrack(track); + blink::WebMediaStreamTrack::Settings settings; + native_track->getSettings(settings); + // These values come straight from the mock video track implementation. + EXPECT_EQ(640, settings.width); + EXPECT_EQ(480, settings.height); + EXPECT_EQ(30.0, settings.frameRate); + EXPECT_EQ(blink::WebMediaStreamTrack::FacingMode::None, settings.facingMode); +} + } // namespace content
diff --git a/content/shell/renderer/layout_test/blink_test_runner.cc b/content/shell/renderer/layout_test/blink_test_runner.cc index adee3a9..2fae9f42 100644 --- a/content/shell/renderer/layout_test/blink_test_runner.cc +++ b/content/shell/renderer/layout_test/blink_test_runner.cc
@@ -218,12 +218,15 @@ ~MockAudioCapturerSource() override {} }; -// Tests in web-platform-tests use absolute path links such as +// Tests in csswg-test use absolute path links such as // <script src="/resources/testharness.js">. // Because we load the tests as local files, such links don't work. // This function fixes this issue by rewriting file: URLs which were produced -// from such links so that they point actual files in wpt/. -WebURL RewriteAbsolutePathInWPT(const std::string& utf8_url) { +// from such links so that they point actual files in LayoutTests/resources/. +// +// Note that this isn't applied to external/wpt because tests in external/wpt +// are accessed via http. +WebURL RewriteAbsolutePathInCsswgTest(const std::string& utf8_url) { const char kFileScheme[] = "file:///"; const int kFileSchemeLen = arraysize(kFileScheme) - 1; if (utf8_url.compare(0, kFileSchemeLen, kFileScheme, kFileSchemeLen) != 0) @@ -242,7 +245,7 @@ base::FilePath new_path = LayoutTestRenderThreadObserver::GetInstance() ->webkit_source_dir() - .Append(FILE_PATH_LITERAL("LayoutTests/external/wpt/")) + .Append(FILE_PATH_LITERAL("LayoutTests/")) .AppendASCII(path); return WebURL(net::FilePathToFileURL(new_path)); } @@ -355,7 +358,7 @@ WebURL BlinkTestRunner::RewriteLayoutTestsURL(const std::string& utf8_url, bool is_wpt_mode) { if (is_wpt_mode) { - WebURL rewritten_url = RewriteAbsolutePathInWPT(utf8_url); + WebURL rewritten_url = RewriteAbsolutePathInCsswgTest(utf8_url); if (!rewritten_url.isEmpty()) return rewritten_url; return WebURL(GURL(utf8_url));
diff --git a/content/test/gpu/gpu_tests/gpu_integration_test_unittest.py b/content/test/gpu/gpu_tests/gpu_integration_test_unittest.py index a8e58cd..4946255 100644 --- a/content/test/gpu/gpu_tests/gpu_integration_test_unittest.py +++ b/content/test/gpu/gpu_tests/gpu_integration_test_unittest.py
@@ -128,6 +128,62 @@ pass +class BrowserCrashAfterStartIntegrationUnittest( + gpu_integration_test.GpuIntegrationTest): + + _num_browser_crashes = 0 + _num_browser_starts = 0 + + @classmethod + def setUpClass(cls): + cls._fake_browser_options = fakes.CreateBrowserFinderOptions( + execute_after_browser_creation=cls.CrashAfterStart) + cls._fake_browser_options.browser_options.platform = \ + fakes.FakeLinuxPlatform() + cls._fake_browser_options.output_formats = ['none'] + cls._fake_browser_options.suppress_gtest_report = True + cls._fake_browser_options.output_dir = None + cls._fake_browser_options .upload_bucket = 'public' + cls._fake_browser_options .upload_results = False + cls._finder_options = cls._fake_browser_options + cls.platform = None + cls.browser = None + cls.SetBrowserOptions(cls._finder_options) + cls.StartBrowser() + + @classmethod + def _CreateExpectations(cls): + return gpu_test_expectations.GpuTestExpectations() + + @classmethod + def CrashAfterStart(cls, browser): + cls._num_browser_starts += 1 + if cls._num_browser_crashes < 2: + cls._num_browser_crashes += 1 + # This simulates the first tab's renderer process crashing upon + # startup. The try/catch forces the GpuIntegrationTest's first + # fetch of this tab to fail. crbug.com/682819 + try: + browser.tabs[0].Navigate('chrome://crash') + except Exception: + pass + + @classmethod + def Name(cls): + return 'browser_crash_after_start_integration_unittest' + + @classmethod + def GenerateGpuTests(cls, options): + # This test causes the browser to try and restart the browser 3 times. + yield ('restart', 'restart.html', ()) + + def RunActualGpuTest(self, file_path, *args): + # The logic of this test is run when the browser starts, it fails twice + # and then succeeds on the third time so we are just testing that this + # is successful based on the parameters. + pass + + class GpuIntegrationTestUnittest(unittest.TestCase): @mock.patch('telemetry.internal.util.binary_manager.InitDependencyManager') def testSimpleIntegrationUnittest(self, mockInitDependencyManager): @@ -153,10 +209,15 @@ self.assertEquals( \ BrowserStartFailureIntegrationUnittest._num_browser_starts, 3) - # TODO(kbr): write a new test utilizing the - # execute_after_browser_creation argument to - # fakes.CreateBrowserFinderOptions once that is available. - # crbug.com/682819 + @mock.patch('telemetry.internal.util.binary_manager.InitDependencyManager') + def testIntegrationUnittestWithBrowserCrashUponStart( + self, mockInitDependencyManager): + self._RunIntegrationTest( + 'browser_crash_after_start_integration_unittest', [], ['restart']) + self.assertEquals( \ + BrowserCrashAfterStartIntegrationUnittest._num_browser_crashes, 2) + self.assertEquals( \ + BrowserCrashAfterStartIntegrationUnittest._num_browser_starts, 3) def _RunIntegrationTest(self, test_name, failures, successes): options = browser_test_runner.TestRunOptions()
diff --git a/ios/web/net/crw_request_tracker_delegate.h b/ios/web/net/crw_request_tracker_delegate.h index 2e8d827..7ac472f 100644 --- a/ios/web/net/crw_request_tracker_delegate.h +++ b/ios/web/net/crw_request_tracker_delegate.h
@@ -24,12 +24,6 @@ // All the methods in this protocol must be sent on the main thread. @protocol CRWRequestTrackerDelegate -// Returns |YES| of all the requests are static file requests and returns |NO| -// if all the requests are network requests. Note it is not allowed for a -// |CRWRequestTrackerDelegate| to send both static file requests and network -// requests. -- (BOOL)isForStaticFileRequests; - // The tracker calls this method every time there is a change in the SSL status // of a page. The info is whatever object was passed to TrimToURL(). - (void)updatedSSLStatus:(const web::SSLStatus&)sslStatus @@ -40,21 +34,6 @@ - (void)handleResponseHeaders:(net::HttpResponseHeaders*)headers requestUrl:(const GURL&)requestUrl; -// This method is called when a network request has an issue with the SSL -// connection to present it to the user. The user will decide if the request -// should continue or not and the callback should be invoked to let the backend -// know. -// If the callback is not called the request will be cancelled on the next call -// to TrimToURL(). -// The callback is safe to call until the requestTracker it originated from -// is deleted. -typedef void (^SSLErrorCallback)(BOOL); -- (void)presentSSLError:(const net::SSLInfo&)info - forSSLStatus:(const web::SSLStatus&)status - onUrl:(const GURL&)url - recoverable:(BOOL)recoverable - callback:(SSLErrorCallback)shouldContinue; - // Update the progress. - (void)updatedProgress:(float)progress;
diff --git a/ios/web/net/request_tracker_impl.h b/ios/web/net/request_tracker_impl.h index 17b9340..c7b4321 100644 --- a/ios/web/net/request_tracker_impl.h +++ b/ios/web/net/request_tracker_impl.h
@@ -162,9 +162,6 @@ static RequestTrackerImpl* GetTrackerForRequestGroupID( NSString* request_group_id); - // Callback from the UI to allow or deny a particular certificate. - void ErrorCallback(CRWSSLCarrier* carrier, bool allow); - // Utility method for clients to post tasks to the IO thread from the UI // thread. void PostIOTask(const base::Closure& task); @@ -305,10 +302,6 @@ // Notifies the delegate of an SSL status update. void NotifyUpdatedSSLStatus(base::scoped_nsobject<CRWSSLCarrier> carrier); - // Calls the delegate method to present an SSL error interstitial. - void NotifyPresentSSLError(base::scoped_nsobject<CRWSSLCarrier> carrier, - bool recoverable); - #pragma mark Internal utilities for task posting // Posts |task| to |thread|. Must not be called from |thread|. If |thread| is // the IO thread, silently returns if |is_closing_| is true. @@ -345,8 +338,6 @@ unsigned int estimate_start_index_; // How many notifications are currently queued, to avoid notifying too often. int notification_depth_; - // The tracker containing the error currently presented to the user. - TrackerCounts* current_ssl_error_; // Set to |YES| if the page has mixed content bool has_mixed_content_; // Set to true if between TrimToURL and StopPageLoad. @@ -357,11 +348,6 @@ #pragma mark Other fields. scoped_refptr<web::CertificatePolicyCache> policy_cache_; - // If |true| all the requests should be static file requests, otherwise all - // the requests should be network requests. This is a constant initialized - // in the constructor and read in IO and UI threads. - const bool is_for_static_file_requests_; - scoped_refptr<net::URLRequestContextGetter> request_context_getter_; // Current page URL, as far as we know. GURL page_url_;
diff --git a/ios/web/net/request_tracker_impl.mm b/ios/web/net/request_tracker_impl.mm index b5a2c52b..b6ac91c 100644 --- a/ios/web/net/request_tracker_impl.mm +++ b/ios/web/net/request_tracker_impl.mm
@@ -222,8 +222,6 @@ - (const web::SSLStatus&)sslStatus; // Returns a SSLInfo with a reference to the certificate and SSL information. - (const net::SSLInfo&)sslInfo; -// Callback method to allow or deny the request from going through. -- (void)errorCallback:(BOOL)flag; // Internal method used to build the SSLStatus object. Called from the // initializer to make sure it is invoked on the network thread. - (void)buildSSLStatus; @@ -255,13 +253,6 @@ return status_; } -- (void)errorCallback:(BOOL)flag { - base::scoped_nsobject<CRWSSLCarrier> scoped(self); - web::WebThread::PostTask(web::WebThread::IO, FROM_HERE, - base::Bind(&web::RequestTrackerImpl::ErrorCallback, - tracker_, scoped, flag)); -} - - (void)buildSSLStatus { DCHECK_CURRENTLY_ON(web::WebThread::IO); if (!sslInfo_.is_valid()) @@ -475,7 +466,7 @@ void RequestTrackerImpl::StartRequest(net::URLRequest* request) { DCHECK_CURRENTLY_ON(web::WebThread::IO); DCHECK(!counts_by_request_.count(request)); - DCHECK_EQ(is_for_static_file_requests_, request->url().SchemeIsFile()); + DCHECK(!request->url().SchemeIsFile()); if (new_estimate_round_) { // Starting a new estimate round. Ignore the previous requests for the @@ -619,19 +610,6 @@ } } -void RequestTrackerImpl::ErrorCallback(CRWSSLCarrier* carrier, bool allow) { - DCHECK_CURRENTLY_ON(web::WebThread::IO); - DCHECK(policy_cache_); - - if (allow) { - policy_cache_->AllowCertForHost([carrier sslInfo].cert.get(), - [carrier url].host(), - [carrier sslInfo].cert_status); - ReevaluateCallbacksForAllCounts(); - } - current_ssl_error_ = NULL; -} - #pragma mark Client utility methods. void RequestTrackerImpl::PostUITaskIfOpen(const base::Closure& task) { @@ -668,11 +646,9 @@ previous_estimate_(0.0f), // Not active by default. estimate_start_index_(0), notification_depth_(0), - current_ssl_error_(NULL), has_mixed_content_(false), is_loading_(false), new_estimate_round_(true), - is_for_static_file_requests_([delegate isForStaticFileRequests]), request_context_getter_(context_getter), identifier_(++g_next_request_tracker_id), request_group_id_([request_group_id copy]), @@ -828,19 +804,6 @@ userInfo:user_info_]; } -void RequestTrackerImpl::NotifyPresentSSLError( - base::scoped_nsobject<CRWSSLCarrier> carrier, - bool recoverable) { - DCHECK_CURRENTLY_ON(web::WebThread::UI); - [delegate_ presentSSLError:[carrier sslInfo] - forSSLStatus:[carrier sslStatus] - onUrl:[carrier url] - recoverable:recoverable - callback:^(BOOL flag) { - [carrier errorCallback:flag && recoverable]; - }]; -} - void RequestTrackerImpl::EvaluateSSLCallbackForCounts(TrackerCounts* counts) { DCHECK_CURRENTLY_ON(web::WebThread::IO); DCHECK(policy_cache_); @@ -921,28 +884,6 @@ // Check if the value hasn't changed via a user action. if (tracker_count->ssl_judgment == CertPolicy::UNKNOWN) EvaluateSSLCallbackForCounts(tracker_count.get()); - - CertPolicy::Judgment judgment = tracker_count->ssl_judgment; - if (judgment == CertPolicy::ALLOWED) - continue; - - // SSL errors on subrequests are simply ignored. The call to - // EvaluateSSLCallbackForCounts() cancelled the request and nothing will - // restart it. - if (tracker_count->is_subrequest) - continue; - - if (!current_ssl_error_) { - // For the UNKNOWN and DENIED state the information should be pushed to - // the delegate. But only one at a time. - current_ssl_error_ = tracker_count.get(); - base::scoped_nsobject<CRWSSLCarrier> carrier([[CRWSSLCarrier alloc] - initWithTracker:this counts:current_ssl_error_]); - web::WebThread::PostTask( - web::WebThread::UI, FROM_HERE, - base::Bind(&RequestTrackerImpl::NotifyPresentSSLError, this, carrier, - judgment == CertPolicy::UNKNOWN)); - } } }
diff --git a/ios/web/net/request_tracker_impl_unittest.mm b/ios/web/net/request_tracker_impl_unittest.mm index 0875087..61592aa 100644 --- a/ios/web/net/request_tracker_impl_unittest.mm +++ b/ios/web/net/request_tracker_impl_unittest.mm
@@ -62,10 +62,6 @@ return self; } -- (BOOL)isForStaticFileRequests { - return NO; -} - - (void)updatedProgress:(float)progress { if (progress > 0.0f) { if (progress < value_) { @@ -101,14 +97,6 @@ // Nothing. yet. } -- (void)presentSSLError:(const net::SSLInfo&)info - forSSLStatus:(const web::SSLStatus&)status - onUrl:(const GURL&)url - recoverable:(BOOL)recoverable - callback:(SSLErrorCallback)shouldContinue { - // Nothing, yet. -} - - (void)certificateUsed:(net::X509Certificate*)certificate forHost:(const std::string&)host status:(net::CertStatus)status {
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm index ea28c26..5dddb69 100644 --- a/ios/web/web_state/ui/crw_web_controller.mm +++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -3500,10 +3500,6 @@ #pragma mark - #pragma mark CRWRequestTrackerDelegate -- (BOOL)isForStaticFileRequests { - return NO; -} - - (void)updatedSSLStatus:(const web::SSLStatus&)sslStatus forPageUrl:(const GURL&)url userInfo:(id)userInfo { @@ -3539,15 +3535,6 @@ _webStateImpl->OnHttpResponseHeadersReceived(headers, requestUrl); } -- (void)presentSSLError:(const net::SSLInfo&)info - forSSLStatus:(const web::SSLStatus&)status - onUrl:(const GURL&)url - recoverable:(BOOL)recoverable - callback:(SSLErrorCallback)shouldContinue { - // This is a UIWebView callback, which is no longer called. - NOTREACHED(); -} - - (void)updatedProgress:(float)progress { // This is a UIWebView callback, which is no longer called. NOTREACHED();
diff --git a/third_party/WebKit/LayoutTests/PRESUBMIT.py b/third_party/WebKit/LayoutTests/PRESUBMIT.py index 62199d4..87d981c1 100644 --- a/third_party/WebKit/LayoutTests/PRESUBMIT.py +++ b/third_party/WebKit/LayoutTests/PRESUBMIT.py
@@ -64,14 +64,9 @@ """ dirty_files = set(input_api.LocalPaths()) - # TODO(tkent): Remove vendor-prefix.js, testharnessreport.js, and - # WebIDLParser.js from |groups| after enabling WPTServe. groups = [ - ('external/wpt/common/vendor-prefix.js', 'resources/vendor-prefix.js'), ('external/wpt/resources/idlharness.js', 'resources/idlharness.js'), ('external/wpt/resources/testharness.js', 'resources/testharness.js'), - ('external/wpt/resources/testharnessreport.js', 'resources/testharnessreport.js'), - ('external/wpt/resources/WebIDLParser.js', 'resources/WebIDLParser.js'), ] def _absolute_path(s):
diff --git a/third_party/WebKit/LayoutTests/W3CImportExpectations b/third_party/WebKit/LayoutTests/W3CImportExpectations index 30235da..0abd160 100644 --- a/third_party/WebKit/LayoutTests/W3CImportExpectations +++ b/third_party/WebKit/LayoutTests/W3CImportExpectations
@@ -364,6 +364,11 @@ # (if it's a blink/test tooling issue) or an upstream bug reference # (if the test itself is buggy). +# wpt.config.json overrides the following files with LayoutTests/resources +# files. Having unused files would be confusing. +imported/wpt/resources/testharnessreport.js [ Skip ] +imported/wpt/common/vendor-prefix.js [ Skip ] + # crbug.com/490694: Needs to support *.headers. external/wpt/html/dom/documents/resource-metadata-management/document-lastModified.html [ Skip ] external/wpt/html/syntax/parsing-html-fragments/the-input-byte-stream-001.html [ Skip ]
diff --git a/third_party/WebKit/LayoutTests/WPTServeExpectations b/third_party/WebKit/LayoutTests/WPTServeExpectations deleted file mode 100644 index af4f3396..0000000 --- a/third_party/WebKit/LayoutTests/WPTServeExpectations +++ /dev/null
@@ -1,3 +0,0 @@ -# Overriden expectations for imported tests when run with --enable-wptserve - -# This file is now obsolete and will be removed. See https://crbug.com/666111
diff --git a/third_party/WebKit/LayoutTests/external/wpt/common/vendor-prefix.js b/third_party/WebKit/LayoutTests/external/wpt/common/vendor-prefix.js deleted file mode 100644 index 0365f2ea..0000000 --- a/third_party/WebKit/LayoutTests/external/wpt/common/vendor-prefix.js +++ /dev/null
@@ -1,100 +0,0 @@ -/* - * Distributed under both the W3C Test Suite License [1] and the W3C - * 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the - * policies and contribution forms [3]. - * - * [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license - * [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license - * [3] http://www.w3.org/2004/10/27-testcases - * */ - -/* Source: https://github.com/w3c/web-platform-tests/blob/master/common/vendor-prefix.js - * The file has been modified to always be on (i.e. does not require usePrefixes=1 to - * start replacing prefixes). */ - -/* Use this script when you want to test APIs that use vendor prefixes - and define which objects need to be checked for prefixed versions, à la - <script src="vendor-prefix.js" - data-prefixed-objects='[{"ancestors":["navigator"], "name":"getUserMedia"}]' - data-prefixed-prototypes='[{"ancestors":["HTMLMediaElement"],"name":"srcObject"}]'></script> - data-prefixed-objects lets prefix objects in the global space - data-prefixed-prototypes adds prefixes to interfaces, for objects that - get created during the tests - - NB: vendor prefixes are expected to go away in favor of putting - new features behind flag, so hopefully there will be only limited - need to use this -*/ - -(function () { - var aliases = {}; - var documentingPrefixUsage = document.createElement('div'); - var vendorPrefixes = ["moz", "ms", "o", "webkit", "Moz", "MS", "O", "WebKit", "op"]; - - function getParentObject(ancestors) { - var parent = window; - var currentName = ""; - ancestors.forEach(function (p) { - currentName = currentName ? currentName + "." + p : p; - if (parent[p] === undefined) { - throw currentName + " is undefined, cannot set prefix alias on child object"; - } - parent = parent[p]; - }); - return parent; - } - - function prependPrefix(prefix, name) { - var newName = name[0].toUpperCase() + name.substr(1, name.length); - return prefix + newName; - } - - function setPrototypeAlias(obj) { - var parent = getParentObject(obj.ancestors); - if (!parent.prototype.hasOwnProperty(obj.name)) { - vendorPrefixes.forEach(function (prefix) { - if (parent.prototype.hasOwnProperty(prependPrefix(prefix, obj.name))) { - Object.defineProperty(parent.prototype, obj.name, - {get: function() {return this[prependPrefix(prefix, obj.name)];}, - set: function(v) {this[prependPrefix(prefix, obj.name)] = v;} - }); - aliases[obj.ancestors.join(".") + ".prototype." + obj.name] = obj.ancestors.join(".") + ".prototype." + prependPrefix(prefix, obj.name); - return; - } - }); - } - } - - function setAlias(obj) { - var parent = getParentObject(obj.ancestors); - if (parent[obj.name] === undefined) { - vendorPrefixes.forEach(function (prefix) { - if (parent[prependPrefix(prefix, obj.name)] !== undefined) { - parent[obj.name] = parent[prependPrefix(prefix, obj.name)]; - aliases[obj.ancestors.join(".") + "." + obj.name] = obj.ancestors.join(".") + "." + prependPrefix(prefix, obj.name); - return; - } - }); - } - } - - // For this version of vendor-prefixes.js, always replace the prefixes. - if (document.querySelector("script[data-prefixed-objects]")) { - var prefixObjectsData = document.querySelector("script[data-prefixed-objects]").dataset["prefixedObjects"]; - try { - var prefixedObjects = JSON.parse(prefixObjectsData); - } catch (e) { - throw "couldn't parse data-prefixed-objects as JSON:" + e; - } - prefixedObjects.forEach(setAlias); - } - if (document.querySelector("script[data-prefixed-prototypes]")) { - var prefixProtoData = document.querySelector("script[data-prefixed-prototypes]").dataset["prefixedPrototypes"]; - try { - var prefixedPrototypes = JSON.parse(prefixProtoData); - } catch (e) { - throw "couldn't parse data-prefixed-prototypes as JSON:" + e; - } - prefixedPrototypes.forEach(setPrototypeAlias); - } -})();
diff --git a/third_party/WebKit/LayoutTests/external/wpt/resources/WebIDLParser.js b/third_party/WebKit/LayoutTests/external/wpt/resources/WebIDLParser.js deleted file mode 100644 index 71030cf..0000000 --- a/third_party/WebKit/LayoutTests/external/wpt/resources/WebIDLParser.js +++ /dev/null
@@ -1,1012 +0,0 @@ - - -(function () { - var tokenise = function (str) { - var tokens = [] - , re = { - "float": /^-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][-+]?[0-9]+)?|[0-9]+[Ee][-+]?[0-9]+)/ - , "integer": /^-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)/ - , "identifier": /^[A-Z_a-z][0-9A-Z_a-z]*/ - , "string": /^"[^"]*"/ - , "whitespace": /^(?:[\t\n\r ]+|[\t\n\r ]*((\/\/.*|\/\*(.|\n|\r)*?\*\/)[\t\n\r ]*))+/ - , "other": /^[^\t\n\r 0-9A-Z_a-z]/ - } - , types = [] - ; - for (var k in re) types.push(k); - while (str.length > 0) { - var matched = false; - for (var i = 0, n = types.length; i < n; i++) { - var type = types[i]; - str = str.replace(re[type], function (tok) { - tokens.push({ type: type, value: tok }); - matched = true; - return ""; - }); - if (matched) break; - } - if (matched) continue; - throw new Error("Token stream not progressing"); - } - return tokens; - }; - - var parse = function (tokens, opt) { - var line = 1; - tokens = tokens.slice(); - - var FLOAT = "float" - , INT = "integer" - , ID = "identifier" - , STR = "string" - , OTHER = "other" - ; - - var WebIDLParseError = function (str, line, input, tokens) { - this.message = str; - this.line = line; - this.input = input; - this.tokens = tokens; - }; - WebIDLParseError.prototype.toString = function () { - return this.message + ", line " + this.line + " (tokens: '" + this.input + "')\n" + - JSON.stringify(this.tokens, null, 4); - }; - - var error = function (str) { - var tok = "", numTokens = 0, maxTokens = 5; - while (numTokens < maxTokens && tokens.length > numTokens) { - tok += tokens[numTokens].value; - numTokens++; - } - throw new WebIDLParseError(str, line, tok, tokens.slice(0, 5)); - }; - - var last_token = null; - - var consume = function (type, value) { - if (!tokens.length || tokens[0].type !== type) return; - if (typeof value === "undefined" || tokens[0].value === value) { - last_token = tokens.shift(); - if (type === ID) last_token.value = last_token.value.replace(/^_/, ""); - return last_token; - } - }; - - var ws = function () { - if (!tokens.length) return; - if (tokens[0].type === "whitespace") { - var t = tokens.shift(); - t.value.replace(/\n/g, function (m) { line++; return m; }); - return t; - } - }; - - var all_ws = function (store, pea) { // pea == post extended attribute, tpea = same for types - var t = { type: "whitespace", value: "" }; - while (true) { - var w = ws(); - if (!w) break; - t.value += w.value; - } - if (t.value.length > 0) { - if (store) { - var w = t.value - , re = { - "ws": /^([\t\n\r ]+)/ - , "line-comment": /^\/\/(.*)\n?/m - , "multiline-comment": /^\/\*((?:.|\n|\r)*?)\*\// - } - , wsTypes = [] - ; - for (var k in re) wsTypes.push(k); - while (w.length) { - var matched = false; - for (var i = 0, n = wsTypes.length; i < n; i++) { - var type = wsTypes[i]; - w = w.replace(re[type], function (tok, m1) { - store.push({ type: type + (pea ? ("-" + pea) : ""), value: m1 }); - matched = true; - return ""; - }); - if (matched) break; - } - if (matched) continue; - throw new Error("Surprising white space construct."); // this shouldn't happen - } - } - return t; - } - }; - - var integer_type = function () { - var ret = ""; - all_ws(); - if (consume(ID, "unsigned")) ret = "unsigned "; - all_ws(); - if (consume(ID, "short")) return ret + "short"; - if (consume(ID, "long")) { - ret += "long"; - all_ws(); - if (consume(ID, "long")) return ret + " long"; - return ret; - } - if (ret) error("Failed to parse integer type"); - }; - - var float_type = function () { - var ret = ""; - all_ws(); - if (consume(ID, "unrestricted")) ret = "unrestricted "; - all_ws(); - if (consume(ID, "float")) return ret + "float"; - if (consume(ID, "double")) return ret + "double"; - if (ret) error("Failed to parse float type"); - }; - - var primitive_type = function () { - var num_type = integer_type() || float_type(); - if (num_type) return num_type; - all_ws(); - if (consume(ID, "boolean")) return "boolean"; - if (consume(ID, "byte")) return "byte"; - if (consume(ID, "octet")) return "octet"; - }; - - var const_value = function () { - if (consume(ID, "true")) return { type: "boolean", value: true }; - if (consume(ID, "false")) return { type: "boolean", value: false }; - if (consume(ID, "null")) return { type: "null" }; - if (consume(ID, "Infinity")) return { type: "Infinity", negative: false }; - if (consume(ID, "NaN")) return { type: "NaN" }; - var ret = consume(FLOAT) || consume(INT); - if (ret) return { type: "number", value: 1 * ret.value }; - var tok = consume(OTHER, "-"); - if (tok) { - if (consume(ID, "Infinity")) return { type: "Infinity", negative: true }; - else tokens.unshift(tok); - } - }; - - var type_suffix = function (obj) { - while (true) { - all_ws(); - if (consume(OTHER, "?")) { - if (obj.nullable) error("Can't nullable more than once"); - obj.nullable = true; - } - else if (consume(OTHER, "[")) { - all_ws(); - consume(OTHER, "]") || error("Unterminated array type"); - if (!obj.array) { - obj.array = 1; - obj.nullableArray = [obj.nullable]; - } - else { - obj.array++; - obj.nullableArray.push(obj.nullable); - } - obj.nullable = false; - } - else return; - } - }; - - var single_type = function () { - var prim = primitive_type() - , ret = { sequence: false, generic: null, nullable: false, array: false, union: false } - , name - , value - ; - if (prim) { - ret.idlType = prim; - } - else if (name = consume(ID)) { - value = name.value; - all_ws(); - // Generic types - if (consume(OTHER, "<")) { - // backwards compat - if (value === "sequence") { - ret.sequence = true; - } - ret.generic = value; - ret.idlType = type() || error("Error parsing generic type " + value); - all_ws(); - if (!consume(OTHER, ">")) error("Unterminated generic type " + value); - type_suffix(ret); - return ret; - } - else { - ret.idlType = value; - } - } - else { - return; - } - type_suffix(ret); - if (ret.nullable && !ret.array && ret.idlType === "any") error("Type any cannot be made nullable"); - return ret; - }; - - var union_type = function () { - all_ws(); - if (!consume(OTHER, "(")) return; - var ret = { sequence: false, generic: null, nullable: false, array: false, union: true, idlType: [] }; - var fst = type() || error("Union type with no content"); - ret.idlType.push(fst); - while (true) { - all_ws(); - if (!consume(ID, "or")) break; - var typ = type() || error("No type after 'or' in union type"); - ret.idlType.push(typ); - } - if (!consume(OTHER, ")")) error("Unterminated union type"); - type_suffix(ret); - return ret; - }; - - var type = function () { - return single_type() || union_type(); - }; - - var argument = function (store) { - var ret = { optional: false, variadic: false }; - ret.extAttrs = extended_attrs(store); - all_ws(store, "pea"); - var opt_token = consume(ID, "optional"); - if (opt_token) { - ret.optional = true; - all_ws(); - } - ret.idlType = type(); - if (!ret.idlType) { - if (opt_token) tokens.unshift(opt_token); - return; - } - var type_token = last_token; - if (!ret.optional) { - all_ws(); - if (tokens.length >= 3 && - tokens[0].type === "other" && tokens[0].value === "." && - tokens[1].type === "other" && tokens[1].value === "." && - tokens[2].type === "other" && tokens[2].value === "." - ) { - tokens.shift(); - tokens.shift(); - tokens.shift(); - ret.variadic = true; - } - } - all_ws(); - var name = consume(ID); - if (!name) { - if (opt_token) tokens.unshift(opt_token); - tokens.unshift(type_token); - return; - } - ret.name = name.value; - if (ret.optional) { - all_ws(); - ret["default"] = default_(); - } - return ret; - }; - - var argument_list = function (store) { - var ret = [] - , arg = argument(store ? ret : null) - ; - if (!arg) return; - ret.push(arg); - while (true) { - all_ws(store ? ret : null); - if (!consume(OTHER, ",")) return ret; - var nxt = argument(store ? ret : null) || error("Trailing comma in arguments list"); - ret.push(nxt); - } - }; - - var type_pair = function () { - all_ws(); - var k = type(); - if (!k) return; - all_ws() - if (!consume(OTHER, ",")) return; - all_ws(); - var v = type(); - if (!v) return; - return [k, v]; - }; - - var simple_extended_attr = function (store) { - all_ws(); - var name = consume(ID); - if (!name) return; - var ret = { - name: name.value - , "arguments": null - }; - all_ws(); - var eq = consume(OTHER, "="); - if (eq) { - var rhs; - all_ws(); - if (rhs = consume(ID)) { - ret.rhs = rhs - } - else if (consume(OTHER, "(")) { - // [Exposed=(Window,Worker)] - rhs = []; - var id = consume(ID); - if (id) { - rhs = [id.value]; - } - identifiers(rhs); - consume(OTHER, ")") || error("Unexpected token in extended attribute argument list or type pair"); - ret.rhs = { - type: "identifier-list", - value: rhs - }; - } - if (!ret.rhs) return error("No right hand side to extended attribute assignment"); - } - all_ws(); - if (consume(OTHER, "(")) { - var args, pair; - // [Constructor(DOMString str)] - if (args = argument_list(store)) { - ret["arguments"] = args; - } - // [MapClass(DOMString, DOMString)] - else if (pair = type_pair()) { - ret.typePair = pair; - } - // [Constructor()] - else { - ret["arguments"] = []; - } - all_ws(); - consume(OTHER, ")") || error("Unexpected token in extended attribute argument list or type pair"); - } - return ret; - }; - - // Note: we parse something simpler than the official syntax. It's all that ever - // seems to be used - var extended_attrs = function (store) { - var eas = []; - all_ws(store); - if (!consume(OTHER, "[")) return eas; - eas[0] = simple_extended_attr(store) || error("Extended attribute with not content"); - all_ws(); - while (consume(OTHER, ",")) { - eas.push(simple_extended_attr(store) || error("Trailing comma in extended attribute")); - all_ws(); - } - consume(OTHER, "]") || error("No end of extended attribute"); - return eas; - }; - - var default_ = function () { - all_ws(); - if (consume(OTHER, "=")) { - all_ws(); - var def = const_value(); - if (def) { - return def; - } - else if (consume(OTHER, "[")) { - if (!consume(OTHER, "]")) error("Default sequence value must be empty"); - return { type: "sequence", value: [] }; - } - else { - var str = consume(STR) || error("No value for default"); - str.value = str.value.replace(/^"/, "").replace(/"$/, ""); - return str; - } - } - }; - - var const_ = function (store) { - all_ws(store, "pea"); - if (!consume(ID, "const")) return; - var ret = { type: "const", nullable: false }; - all_ws(); - var typ = primitive_type(); - if (!typ) { - typ = consume(ID) || error("No type for const"); - typ = typ.value; - } - ret.idlType = typ; - all_ws(); - if (consume(OTHER, "?")) { - ret.nullable = true; - all_ws(); - } - var name = consume(ID) || error("No name for const"); - ret.name = name.value; - all_ws(); - consume(OTHER, "=") || error("No value assignment for const"); - all_ws(); - var cnt = const_value(); - if (cnt) ret.value = cnt; - else error("No value for const"); - all_ws(); - consume(OTHER, ";") || error("Unterminated const"); - return ret; - }; - - var inheritance = function () { - all_ws(); - if (consume(OTHER, ":")) { - all_ws(); - var inh = consume(ID) || error ("No type in inheritance"); - return inh.value; - } - }; - - var operation_rest = function (ret, store) { - all_ws(); - if (!ret) ret = {}; - var name = consume(ID); - ret.name = name ? name.value : null; - all_ws(); - consume(OTHER, "(") || error("Invalid operation"); - ret["arguments"] = argument_list(store) || []; - all_ws(); - consume(OTHER, ")") || error("Unterminated operation"); - all_ws(); - consume(OTHER, ";") || error("Unterminated operation"); - return ret; - }; - - var callback = function (store) { - all_ws(store, "pea"); - var ret; - if (!consume(ID, "callback")) return; - all_ws(); - var tok = consume(ID, "interface"); - if (tok) { - tokens.unshift(tok); - ret = interface_(); - ret.type = "callback interface"; - return ret; - } - var name = consume(ID) || error("No name for callback"); - ret = { type: "callback", name: name.value }; - all_ws(); - consume(OTHER, "=") || error("No assignment in callback"); - all_ws(); - ret.idlType = return_type(); - all_ws(); - consume(OTHER, "(") || error("No arguments in callback"); - ret["arguments"] = argument_list(store) || []; - all_ws(); - consume(OTHER, ")") || error("Unterminated callback"); - all_ws(); - consume(OTHER, ";") || error("Unterminated callback"); - return ret; - }; - - var attribute = function (store) { - all_ws(store, "pea"); - var grabbed = [] - , ret = { - type: "attribute" - , "static": false - , stringifier: false - , inherit: false - , readonly: false - }; - if (consume(ID, "static")) { - ret["static"] = true; - grabbed.push(last_token); - } - else if (consume(ID, "stringifier")) { - ret.stringifier = true; - grabbed.push(last_token); - } - var w = all_ws(); - if (w) grabbed.push(w); - if (consume(ID, "inherit")) { - if (ret["static"] || ret.stringifier) error("Cannot have a static or stringifier inherit"); - ret.inherit = true; - grabbed.push(last_token); - var w = all_ws(); - if (w) grabbed.push(w); - } - if (consume(ID, "readonly")) { - ret.readonly = true; - grabbed.push(last_token); - var w = all_ws(); - if (w) grabbed.push(w); - } - if (!consume(ID, "attribute")) { - tokens = grabbed.concat(tokens); - return; - } - all_ws(); - ret.idlType = type() || error("No type in attribute"); - if (ret.idlType.sequence) error("Attributes cannot accept sequence types"); - all_ws(); - var name = consume(ID) || error("No name in attribute"); - ret.name = name.value; - all_ws(); - consume(OTHER, ";") || error("Unterminated attribute"); - return ret; - }; - - var return_type = function () { - var typ = type(); - if (!typ) { - if (consume(ID, "void")) { - return "void"; - } - else error("No return type"); - } - return typ; - }; - - var operation = function (store) { - all_ws(store, "pea"); - var ret = { - type: "operation" - , getter: false - , setter: false - , creator: false - , deleter: false - , legacycaller: false - , "static": false - , stringifier: false - }; - while (true) { - all_ws(); - if (consume(ID, "getter")) ret.getter = true; - else if (consume(ID, "setter")) ret.setter = true; - else if (consume(ID, "creator")) ret.creator = true; - else if (consume(ID, "deleter")) ret.deleter = true; - else if (consume(ID, "legacycaller")) ret.legacycaller = true; - else break; - } - if (ret.getter || ret.setter || ret.creator || ret.deleter || ret.legacycaller) { - all_ws(); - ret.idlType = return_type(); - operation_rest(ret, store); - return ret; - } - if (consume(ID, "static")) { - ret["static"] = true; - ret.idlType = return_type(); - operation_rest(ret, store); - return ret; - } - else if (consume(ID, "stringifier")) { - ret.stringifier = true;- - all_ws(); - if (consume(OTHER, ";")) return ret; - ret.idlType = return_type(); - operation_rest(ret, store); - return ret; - } - ret.idlType = return_type(); - all_ws(); - if (consume(ID, "iterator")) { - all_ws(); - ret.type = "iterator"; - if (consume(ID, "object")) { - ret.iteratorObject = "object"; - } - else if (consume(OTHER, "=")) { - all_ws(); - var name = consume(ID) || error("No right hand side in iterator"); - ret.iteratorObject = name.value; - } - all_ws(); - consume(OTHER, ";") || error("Unterminated iterator"); - return ret; - } - else { - operation_rest(ret, store); - return ret; - } - }; - - var identifiers = function (arr) { - while (true) { - all_ws(); - if (consume(OTHER, ",")) { - all_ws(); - var name = consume(ID) || error("Trailing comma in identifiers list"); - arr.push(name.value); - } - else break; - } - }; - - var serialiser = function (store) { - all_ws(store, "pea"); - if (!consume(ID, "serializer")) return; - var ret = { type: "serializer" }; - all_ws(); - if (consume(OTHER, "=")) { - all_ws(); - if (consume(OTHER, "{")) { - ret.patternMap = true; - all_ws(); - var id = consume(ID); - if (id && id.value === "getter") { - ret.names = ["getter"]; - } - else if (id && id.value === "inherit") { - ret.names = ["inherit"]; - identifiers(ret.names); - } - else if (id) { - ret.names = [id.value]; - identifiers(ret.names); - } - else { - ret.names = []; - } - all_ws(); - consume(OTHER, "}") || error("Unterminated serializer pattern map"); - } - else if (consume(OTHER, "[")) { - ret.patternList = true; - all_ws(); - var id = consume(ID); - if (id && id.value === "getter") { - ret.names = ["getter"]; - } - else if (id) { - ret.names = [id.value]; - identifiers(ret.names); - } - else { - ret.names = []; - } - all_ws(); - consume(OTHER, "]") || error("Unterminated serializer pattern list"); - } - else { - var name = consume(ID) || error("Invalid serializer"); - ret.name = name.value; - } - all_ws(); - consume(OTHER, ";") || error("Unterminated serializer"); - return ret; - } - else if (consume(OTHER, ";")) { - // noop, just parsing - } - else { - ret.idlType = return_type(); - all_ws(); - ret.operation = operation_rest(null, store); - } - return ret; - }; - - var iterable_type = function() { - if (consume(ID, "iterable")) return "iterable"; - else if (consume(ID, "legacyiterable")) return "legacyiterable"; - else if (consume(ID, "maplike")) return "maplike"; - else if (consume(ID, "setlike")) return "setlike"; - else return; - } - - var readonly_iterable_type = function() { - if (consume(ID, "maplike")) return "maplike"; - else if (consume(ID, "setlike")) return "setlike"; - else return; - } - - var iterable = function (store) { - all_ws(store, "pea"); - var grabbed = [], - ret = {type: null, idlType: null, readonly: false}; - if (consume(ID, "readonly")) { - ret.readonly = true; - grabbed.push(last_token); - var w = all_ws(); - if (w) grabbed.push(w); - } - var consumeItType = ret.readonly ? readonly_iterable_type : iterable_type; - - var ittype = consumeItType(); - if (!ittype) { - tokens = grabbed.concat(tokens); - return; - } - - var secondTypeRequired = ittype === "maplike"; - var secondTypeAllowed = secondTypeRequired || ittype === "iterable"; - ret.type = ittype; - if (ret.type !== 'maplike' && ret.type !== 'setlike') - delete ret.readonly; - all_ws(); - if (consume(OTHER, "<")) { - ret.idlType = type() || error("Error parsing " + ittype + " declaration"); - all_ws(); - if (secondTypeAllowed) { - var type2 = null; - if (consume(OTHER, ",")) { - all_ws(); - type2 = type(); - all_ws(); - } - if (type2) - ret.idlType = [ret.idlType, type2]; - else if (secondTypeRequired) - error("Missing second type argument in " + ittype + " declaration"); - } - if (!consume(OTHER, ">")) error("Unterminated " + ittype + " declaration"); - all_ws(); - if (!consume(OTHER, ";")) error("Missing semicolon after " + ittype + " declaration"); - } - else - error("Error parsing " + ittype + " declaration"); - - return ret; - } - - var interface_ = function (isPartial, store) { - all_ws(isPartial ? null : store, "pea"); - if (!consume(ID, "interface")) return; - all_ws(); - var name = consume(ID) || error("No name for interface"); - var mems = [] - , ret = { - type: "interface" - , name: name.value - , partial: false - , members: mems - }; - if (!isPartial) ret.inheritance = inheritance() || null; - all_ws(); - consume(OTHER, "{") || error("Bodyless interface"); - while (true) { - all_ws(store ? mems : null); - if (consume(OTHER, "}")) { - all_ws(); - consume(OTHER, ";") || error("Missing semicolon after interface"); - return ret; - } - var ea = extended_attrs(store ? mems : null); - all_ws(); - var cnt = const_(store ? mems : null); - if (cnt) { - cnt.extAttrs = ea; - ret.members.push(cnt); - continue; - } - var mem = (opt.allowNestedTypedefs && typedef(store ? mems : null)) || - iterable(store ? mems : null) || - serialiser(store ? mems : null) || - attribute(store ? mems : null) || - operation(store ? mems : null) || - error("Unknown member"); - mem.extAttrs = ea; - ret.members.push(mem); - } - }; - - var partial = function (store) { - all_ws(store, "pea"); - if (!consume(ID, "partial")) return; - var thing = dictionary(true, store) || - interface_(true, store) || - error("Partial doesn't apply to anything"); - thing.partial = true; - return thing; - }; - - var dictionary = function (isPartial, store) { - all_ws(isPartial ? null : store, "pea"); - if (!consume(ID, "dictionary")) return; - all_ws(); - var name = consume(ID) || error("No name for dictionary"); - var mems = [] - , ret = { - type: "dictionary" - , name: name.value - , partial: false - , members: mems - }; - if (!isPartial) ret.inheritance = inheritance() || null; - all_ws(); - consume(OTHER, "{") || error("Bodyless dictionary"); - while (true) { - all_ws(store ? mems : null); - if (consume(OTHER, "}")) { - all_ws(); - consume(OTHER, ";") || error("Missing semicolon after dictionary"); - return ret; - } - var ea = extended_attrs(store ? mems : null); - all_ws(store ? mems : null, "pea"); - var required = consume(ID, "required"); - var typ = type() || error("No type for dictionary member"); - all_ws(); - var name = consume(ID) || error("No name for dictionary member"); - var dflt = default_(); - if (required && dflt) error("Required member must not have a default"); - ret.members.push({ - type: "field" - , name: name.value - , required: !!required - , idlType: typ - , extAttrs: ea - , "default": dflt - }); - all_ws(); - consume(OTHER, ";") || error("Unterminated dictionary member"); - } - }; - - var exception = function (store) { - all_ws(store, "pea"); - if (!consume(ID, "exception")) return; - all_ws(); - var name = consume(ID) || error("No name for exception"); - var mems = [] - , ret = { - type: "exception" - , name: name.value - , members: mems - }; - ret.inheritance = inheritance() || null; - all_ws(); - consume(OTHER, "{") || error("Bodyless exception"); - while (true) { - all_ws(store ? mems : null); - if (consume(OTHER, "}")) { - all_ws(); - consume(OTHER, ";") || error("Missing semicolon after exception"); - return ret; - } - var ea = extended_attrs(store ? mems : null); - all_ws(store ? mems : null, "pea"); - var cnt = const_(); - if (cnt) { - cnt.extAttrs = ea; - ret.members.push(cnt); - } - else { - var typ = type(); - all_ws(); - var name = consume(ID); - all_ws(); - if (!typ || !name || !consume(OTHER, ";")) error("Unknown member in exception body"); - ret.members.push({ - type: "field" - , name: name.value - , idlType: typ - , extAttrs: ea - }); - } - } - }; - - var enum_ = function (store) { - all_ws(store, "pea"); - if (!consume(ID, "enum")) return; - all_ws(); - var name = consume(ID) || error("No name for enum"); - var vals = [] - , ret = { - type: "enum" - , name: name.value - , values: vals - }; - all_ws(); - consume(OTHER, "{") || error("No curly for enum"); - var saw_comma = false; - while (true) { - all_ws(store ? vals : null); - if (consume(OTHER, "}")) { - all_ws(); - consume(OTHER, ";") || error("No semicolon after enum"); - return ret; - } - var val = consume(STR) || error("Unexpected value in enum"); - ret.values.push(val.value.replace(/"/g, "")); - all_ws(store ? vals : null); - if (consume(OTHER, ",")) { - if (store) vals.push({ type: "," }); - all_ws(store ? vals : null); - saw_comma = true; - } - else { - saw_comma = false; - } - } - }; - - var typedef = function (store) { - all_ws(store, "pea"); - if (!consume(ID, "typedef")) return; - var ret = { - type: "typedef" - }; - all_ws(); - ret.typeExtAttrs = extended_attrs(); - all_ws(store, "tpea"); - ret.idlType = type() || error("No type in typedef"); - all_ws(); - var name = consume(ID) || error("No name in typedef"); - ret.name = name.value; - all_ws(); - consume(OTHER, ";") || error("Unterminated typedef"); - return ret; - }; - - var implements_ = function (store) { - all_ws(store, "pea"); - var target = consume(ID); - if (!target) return; - var w = all_ws(); - if (consume(ID, "implements")) { - var ret = { - type: "implements" - , target: target.value - }; - all_ws(); - var imp = consume(ID) || error("Incomplete implements statement"); - ret["implements"] = imp.value; - all_ws(); - consume(OTHER, ";") || error("No terminating ; for implements statement"); - return ret; - } - else { - // rollback - tokens.unshift(w); - tokens.unshift(target); - } - }; - - var definition = function (store) { - return callback(store) || - interface_(false, store) || - partial(store) || - dictionary(false, store) || - exception(store) || - enum_(store) || - typedef(store) || - implements_(store) - ; - }; - - var definitions = function (store) { - if (!tokens.length) return []; - var defs = []; - while (true) { - var ea = extended_attrs(store ? defs : null) - , def = definition(store ? defs : null); - if (!def) { - if (ea.length) error("Stray extended attributes"); - break; - } - def.extAttrs = ea; - defs.push(def); - } - return defs; - }; - var res = definitions(opt.ws); - if (tokens.length) error("Unrecognised tokens"); - return res; - }; - - var inNode = typeof module !== "undefined" && module.exports - , obj = { - parse: function (str, opt) { - if (!opt) opt = {}; - var tokens = tokenise(str); - return parse(tokens, opt); - } - }; - - if (inNode) module.exports = obj; - else self.WebIDL2 = obj; -}());
diff --git a/third_party/WebKit/LayoutTests/external/wpt/resources/testharnessreport.js b/third_party/WebKit/LayoutTests/external/wpt/resources/testharnessreport.js deleted file mode 100644 index 8086a62..0000000 --- a/third_party/WebKit/LayoutTests/external/wpt/resources/testharnessreport.js +++ /dev/null
@@ -1,249 +0,0 @@ -/* - * THIS FILE INTENTIONALLY LEFT BLANK - * - * More specifically, this file is intended for vendors to implement - * code needed to integrate testharness.js tests with their own test systems. - * - * Typically such integration will attach callbacks when each test is - * has run, using add_result_callback(callback(test)), or when the whole test file has - * completed, using add_completion_callback(callback(tests, harness_status)). - * - * For more documentation about the callback functions and the - * parameters they are called with see testharness.js - */ - -(function() { - - var output_document = document; - - // Setup for WebKit JavaScript tests - if (self.testRunner) { - testRunner.dumpAsText(); - testRunner.waitUntilDone(); - testRunner.setCanOpenWindows(); - testRunner.setCloseRemainingWindowsWhenComplete(true); - testRunner.setDumpJavaScriptDialogs(false); - } - - // Disable the default output of testharness.js. The default output formats - // test results into an HTML table. When that table is dumped as text, no - // spacing between cells is preserved, and it is therefore not readable. By - // setting output to false, the HTML table will not be created. - // Also, disable timeout (except for explicit timeout), since the Blink - // layout test runner has its own timeout mechanism. - // See: https://github.com/w3c/testharness.js/blob/master/docs/api.md#setup - setup({ - "output": false, - "explicit_timeout": true - }); - - // Function used to convert the test status code into the corresponding - // string - function convertResult(resultStatus) { - switch (resultStatus) { - case 0: - return "PASS"; - case 1: - return "FAIL"; - case 2: - return "TIMEOUT"; - default: - return "NOTRUN"; - } - } - - var localPathRegExp; - if (document.URL.startsWith("file:///")) { - var index = document.URL.indexOf("/external/wpt"); - if (index >= 0) { - var localPath = document.URL.substring("file:///".length, index + "/external/wpt".length); - localPathRegExp = new RegExp(localPath.replace(/(\W)/g, "\\$1"), "g"); - } - } - - // Sanitizes the given text for display in test results. - function sanitize(text) { - if (!text) { - return ""; - } - // Escape null characters, otherwise diff will think the file is binary. - text = text.replace(/\0/g, "\\0"); - // Escape carriage returns as they break rietveld's difftools. - text = text.replace(/\r/g, "\\r"); - // Replace machine-dependent path with "...". - if (localPathRegExp) - text = text.replace(localPathRegExp, "..."); - return text; - } - - function isWPTManualTest() { - var path = location.pathname; - if (location.hostname == 'web-platform.test' && path.endsWith('-manual.html')) - return true; - return /\/imported\/wpt\/.*-manual\.html$/.test(path); - } - - // Returns a directory part relative to WPT root and a basename part of the - // current test. e.g. - // Current test: file:///.../LayoutTests/external/wpt/pointerevents/foobar.html - // Output: "/pointerevents/foobar" - function pathAndBaseNameInWPT() { - var path = location.pathname; - if (location.hostname == 'web-platform.test') { - var matches = path.match(/^(\/.*)\.html$/); - return matches ? matches[1] : null; - } - var matches = path.match(/imported\/wpt(\/.*)\.html$/); - return matches ? matches[1] : null; - } - - function loadAutomationScript() { - var pathAndBase = pathAndBaseNameInWPT(); - if (!pathAndBase) - return; - var automationPath = location.pathname.replace(/\/imported\/wpt\/.*$/, '/external/wpt_automation'); - if (location.hostname == 'web-platform.test') - automationPath = '/wpt_automation'; - - // Export importAutomationScript for use by the automation scripts. - window.importAutomationScript = function(relativePath) { - var script = document.createElement('script'); - script.src = automationPath + relativePath; - document.head.appendChild(script); - } - - var src; - if (pathAndBase.startsWith('/fullscreen/')) { - // Fullscreen tests all use the same automation script. - src = automationPath + '/fullscreen/auto-click.js'; - } else if (pathAndBase.startsWith('/pointerevents/') - || pathAndBase.startsWith('/uievents/')) { - // Per-test automation scripts. - src = automationPath + pathAndBase + '-automation.js'; - } else { - return; - } - var script = document.createElement('script'); - script.src = src; - document.head.appendChild(script); - } - - var didDispatchLoadEvent = false; - window.addEventListener('load', function() { - didDispatchLoadEvent = true; - if (isWPTManualTest()) { - setTimeout(loadAutomationScript, 0); - } - }, { once: true }); - - add_start_callback(function(properties) { - if (properties.output_document) - output_document = properties.output_document; - }); - - // Using a callback function, test results will be added to the page in a - // manner that allows dumpAsText to produce readable test results. - add_completion_callback(function (tests, harness_status) { - - // Create element to hold results. - var results = output_document.createElement("pre"); - - // Declare result string. - var resultStr = "This is a testharness.js-based test.\n"; - - // Check harness_status. If it is not 0, tests did not execute - // correctly, output the error code and message. - if (harness_status.status != 0) { - resultStr += "Harness Error. harness_status.status = " + - harness_status.status + - " , harness_status.message = " + - harness_status.message + - "\n"; - } - // reflection tests contain huge number of tests, and Chromium code - // review tool has the 1MB diff size limit. We merge PASS lines. - if (output_document.URL.indexOf("/html/dom/reflection") >= 0) { - for (var i = 0; i < tests.length; ++i) { - if (tests[i].status == 0) { - var colon = tests[i].name.indexOf(':'); - if (colon > 0) { - var prefix = tests[i].name.substring(0, colon + 1); - var j = i + 1; - for (; j < tests.length; ++j) { - if (!tests[j].name.startsWith(prefix) || tests[j].status != 0) - break; - } - if ((j - i) > 1) { - resultStr += convertResult(tests[i].status) + - " " + sanitize(prefix) + " " + (j - i) + " tests\n" - i = j - 1; - continue; - } - } - } - resultStr += convertResult(tests[i].status) + " " + - sanitize(tests[i].name) + " " + - sanitize(tests[i].message) + "\n"; - } - } else { - // Iterate through tests array and build string that contains - // results for all tests. - for (var i = 0; i < tests.length; ++i) { - resultStr += convertResult(tests[i].status) + " " + - sanitize(tests[i].name) + " " + - sanitize(tests[i].message) + "\n"; - } - } - - resultStr += "Harness: the test ran to completion.\n"; - - // Set results element's textContent to the results string. - results.textContent = resultStr; - - function done() { - // A temporary workaround since |window.self| property lookup starts - // failing if the frame is detached. |output_document| may be an - // ancestor of |self| so clearing |textContent| may detach |self|. - // To get around this, cache window.self now and use the cached - // value. - // TODO(dcheng): Remove this hack after fixing window/self/frames - // lookup in https://crbug.com/618672 - var cachedSelf = window.self; - if (cachedSelf.testRunner) { - // The following DOM operations may show console messages. We - // suppress them because they are not related to the running - // test. - testRunner.setDumpConsoleMessages(false); - - // Anything isn't material to the testrunner output, so should - // be hidden from the text dump. - if (output_document.body && output_document.body.tagName == 'BODY') - output_document.body.textContent = ''; - } - - // Add results element to output_document. - if (!output_document.body || output_document.body.tagName != 'BODY') { - if (!output_document.documentElement) - output_document.appendChild(output_document.createElement('html')); - else if (output_document.body) // output_document.body is <frameset>. - output_document.body.remove(); - output_document.documentElement.appendChild(output_document.createElement("body")); - } - output_document.body.appendChild(results); - - if (cachedSelf.testRunner) - testRunner.notifyDone(); - } - - if (didDispatchLoadEvent || output_document.readyState != 'loading') { - // This function might not be the last 'completion callback', and - // another completion callback might generate more results. So, we - // don't dump the results immediately. - setTimeout(done, 0); - } else { - // Parsing the test HTML isn't finished yet. - window.addEventListener('load', done); - } - }); - -})();
diff --git a/third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-getSettings.html b/third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-getSettings.html index 424cd3c..39da4ac8 100644 --- a/third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-getSettings.html +++ b/third_party/WebKit/LayoutTests/fast/mediastream/MediaStreamTrack-getSettings.html
@@ -33,4 +33,33 @@ }); }, 'A video track returns frame rate'); +promise_test(function() { + return navigator.mediaDevices.getUserMedia( + {video: {facingMode: {exact: "user"}}}) + .then(function(s) { + assert_unreached(); + }) + .catch(function(e) { + assert_equals(e.name, 'Error'); + }); +}, 'With no fake device, asking for user-facing device rejects'); + +promise_test(function() { + return internals.addFakeDevice({kind: "video"}, + {facingMode: {exact: "user"}}) + .then(function() { + navigator.mediaDevices.getUserMedia({video: {facingMode: {exact: "user"}}}) + }) + .then(function(s) { + settings = s.getVideoTracks()[0].getSettings(); + assert_equals(settings.facingMode, "user"); + }) + .catch(function(e) { + console.log('Fake devices are not functional yet.'); + // TODO(hta): Finish creation of fake devices. Until then, accept failure. + // crbug.com/678561 + assert_equals(e.name, 'TypeError', "Check crbug.com/678561"); + }); +}, 'With a fake user-facing device, facing mode is matched') + </script>
diff --git a/third_party/WebKit/Source/core/css/BUILD.gn b/third_party/WebKit/Source/core/css/BUILD.gn index 1c560ff..c969d46 100644 --- a/third_party/WebKit/Source/core/css/BUILD.gn +++ b/third_party/WebKit/Source/core/css/BUILD.gn
@@ -388,6 +388,7 @@ "properties/CSSPropertyAPIWebkitLineClamp.cpp", "properties/CSSPropertyAPIWebkitPadding.cpp", "properties/CSSPropertyAPIWebkitTextEmphasisStyle.cpp", + "properties/CSSPropertyAPIWebkitTextStrokeWidth.cpp", "properties/CSSPropertyAPIWebkitTransformOriginZ.cpp", "properties/CSSPropertyAPIWillChange.cpp", "properties/CSSPropertyAPIZIndex.cpp",
diff --git a/third_party/WebKit/Source/core/css/CSSProperties.in b/third_party/WebKit/Source/core/css/CSSProperties.in index 16ff08e..9e3fd92 100644 --- a/third_party/WebKit/Source/core/css/CSSProperties.in +++ b/third_party/WebKit/Source/core/css/CSSProperties.in
@@ -463,7 +463,7 @@ -webkit-text-fill-color inherited, custom_all -webkit-text-security inherited -webkit-text-stroke-color interpolable, inherited, custom_all --webkit-text-stroke-width inherited, converter=convertTextStrokeWidth +-webkit-text-stroke-width inherited, converter=convertTextStrokeWidth, api_class -webkit-transform-origin-x interpolable, converter=convertLength -webkit-transform-origin-y interpolable, converter=convertLength -webkit-transform-origin-z interpolable, converter=convertComputedLength<float>, api_class
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp index 2810248..d3053b32 100644 --- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp +++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
@@ -1124,26 +1124,12 @@ return true; } -static CSSValue* consumeLineWidth(CSSParserTokenRange& range, - CSSParserMode cssParserMode, - UnitlessQuirk unitless) { - CSSValueID id = range.peek().id(); - if (id == CSSValueThin || id == CSSValueMedium || id == CSSValueThick) - return consumeIdent(range); - return consumeLength(range, cssParserMode, ValueRangeNonNegative, unitless); -} - static CSSValue* consumeBorderWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless) { return consumeLineWidth(range, cssParserMode, unitless); } -static CSSValue* consumeTextStrokeWidth(CSSParserTokenRange& range, - CSSParserMode cssParserMode) { - return consumeLineWidth(range, cssParserMode, UnitlessQuirk::Forbid); -} - static CSSValue* consumeColumnRuleWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode) { return consumeLineWidth(range, cssParserMode, UnitlessQuirk::Forbid); @@ -2411,8 +2397,6 @@ case CSSPropertyOrphans: case CSSPropertyWidows: return consumePositiveInteger(m_range); - case CSSPropertyWebkitTextStrokeWidth: - return consumeTextStrokeWidth(m_range, m_context->mode()); case CSSPropertyWebkitTextFillColor: case CSSPropertyWebkitTapHighlightColor: case CSSPropertyWebkitTextEmphasisColor:
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp index 54474fc6..c4c2011 100644 --- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp +++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp
@@ -543,6 +543,15 @@ return CSSColorValue::create(color); } +CSSValue* consumeLineWidth(CSSParserTokenRange& range, + CSSParserMode cssParserMode, + UnitlessQuirk unitless) { + CSSValueID id = range.peek().id(); + if (id == CSSValueThin || id == CSSValueMedium || id == CSSValueThick) + return consumeIdent(range); + return consumeLength(range, cssParserMode, ValueRangeNonNegative, unitless); +} + static CSSValue* consumePositionComponent(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless,
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.h b/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.h index 20b67ee..544b797 100644 --- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.h +++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.h
@@ -74,6 +74,8 @@ CSSParserMode, bool acceptQuirkyColors = false); +CSSValue* consumeLineWidth(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk); + CSSValuePair* consumePosition(CSSParserTokenRange&, CSSParserMode, UnitlessQuirk);
diff --git a/third_party/WebKit/Source/core/css/properties/CSSPropertyAPIWebkitTextStrokeWidth.cpp b/third_party/WebKit/Source/core/css/properties/CSSPropertyAPIWebkitTextStrokeWidth.cpp new file mode 100644 index 0000000..d4f95a3 --- /dev/null +++ b/third_party/WebKit/Source/core/css/properties/CSSPropertyAPIWebkitTextStrokeWidth.cpp
@@ -0,0 +1,19 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "core/css/properties/CSSPropertyAPIWebkitTextStrokeWidth.h" + +#include "core/css/parser/CSSParserContext.h" +#include "core/css/parser/CSSPropertyParserHelpers.h" + +namespace blink { + +const CSSValue* CSSPropertyAPIWebkitTextStrokeWidth::parseSingleValue( + CSSParserTokenRange& range, + const CSSParserContext* context) { + return CSSPropertyParserHelpers::consumeLineWidth( + range, context->mode(), CSSPropertyParserHelpers::UnitlessQuirk::Forbid); +} + +} // namespace blink
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp index 49cb3d2..12d4d9c 100644 --- a/third_party/WebKit/Source/core/dom/Document.cpp +++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -5557,20 +5557,6 @@ return true; } -bool Document::allowExecutingScripts(Node* node) { - // FIXME: Eventually we'd like to evaluate scripts which are inserted into a - // viewless document but this'll do for now. - // See http://bugs.webkit.org/show_bug.cgi?id=5727 - LocalFrame* frame = executingFrame(); - if (!frame) - return false; - if (!node->document().executingFrame()) - return false; - if (!frame->script().canExecuteScripts(AboutToExecuteScript)) - return false; - return true; -} - void Document::enforceSandboxFlags(SandboxFlags mask) { RefPtr<SecurityOrigin> standInOrigin = getSecurityOrigin(); applySandboxFlags(mask);
diff --git a/third_party/WebKit/Source/core/dom/Document.h b/third_party/WebKit/Source/core/dom/Document.h index 6e97fee..6743b71 100644 --- a/third_party/WebKit/Source/core/dom/Document.h +++ b/third_party/WebKit/Source/core/dom/Document.h
@@ -1028,7 +1028,6 @@ EventListener*, const String& contextURL, const WTF::OrdinalNumber& contextLine); - bool allowExecutingScripts(Node*); void enforceSandboxFlags(SandboxFlags mask) override;
diff --git a/third_party/WebKit/Source/core/dom/DocumentTest.cpp b/third_party/WebKit/Source/core/dom/DocumentTest.cpp index d9e2f2f..df59289 100644 --- a/third_party/WebKit/Source/core/dom/DocumentTest.cpp +++ b/third_party/WebKit/Source/core/dom/DocumentTest.cpp
@@ -123,6 +123,10 @@ return m_contextDestroyedCalledCounter; } + const HeapVector<Member<const Element>>& attributeChangedElements() const { + return m_attributeChangedElements; + } + const HeapVector<Member<const ContainerNode>>& childrenChangedNodes() const { return m_childrenChangedNodes; } @@ -158,6 +162,7 @@ private: // Implement |SynchronousMutationObserver| member functions. void contextDestroyed(Document*) final; + void didChangeAttribute(const Element&) final; void didChangeChildren(const ContainerNode&) final; void didMergeTextNodes(const Text&, const NodeWithIndex&, unsigned) final; void didMoveTreeToNewDocument(const Node& root) final; @@ -170,6 +175,7 @@ void nodeWillBeRemoved(Node&) final; int m_contextDestroyedCalledCounter = 0; + HeapVector<Member<const Element>> m_attributeChangedElements; HeapVector<Member<const ContainerNode>> m_childrenChangedNodes; HeapVector<Member<MergeTextNodesRecord>> m_mergeTextNodesRecords; HeapVector<Member<const Node>> m_moveTreeToNewDocumentNodes; @@ -190,6 +196,11 @@ ++m_contextDestroyedCalledCounter; } +void TestSynchronousMutationObserver::didChangeAttribute( + const Element& element) { + m_attributeChangedElements.push_back(&element); +} + void TestSynchronousMutationObserver::didChangeChildren( const ContainerNode& container) { m_childrenChangedNodes.push_back(&container); @@ -231,6 +242,7 @@ } DEFINE_TRACE(TestSynchronousMutationObserver) { + visitor->trace(m_attributeChangedElements); visitor->trace(m_childrenChangedNodes); visitor->trace(m_mergeTextNodesRecords); visitor->trace(m_moveTreeToNewDocumentNodes); @@ -505,6 +517,24 @@ EXPECT_EQ(1, observer.countContextDestroyedCalled()); } +TEST_F(DocumentTest, SynchronousMutationNotifierChangeAttribute) { + auto& observer = *new TestSynchronousMutationObserver(document()); + Element* divNode = document().createElement("div"); + document().body()->appendChild(divNode); + divNode->setAttribute(HTMLNames::classAttr, "foo"); + + ASSERT_EQ(1u, observer.attributeChangedElements().size()); + EXPECT_EQ(divNode, observer.attributeChangedElements()[0]); + + divNode->setAttribute(HTMLNames::classAttr, "bar"); + ASSERT_EQ(2u, observer.attributeChangedElements().size()); + EXPECT_EQ(divNode, observer.attributeChangedElements()[1]); + + divNode->removeAttribute(HTMLNames::classAttr); + ASSERT_EQ(3u, observer.attributeChangedElements().size()); + EXPECT_EQ(divNode, observer.attributeChangedElements()[2]); +} + TEST_F(DocumentTest, SynchronousMutationNotifieAppendChild) { auto& observer = *new TestSynchronousMutationObserver(document()); document().body()->appendChild(document().createTextNode("a123456789"));
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp index 8e2e171..c927d55 100644 --- a/third_party/WebKit/Source/core/dom/Element.cpp +++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -1297,6 +1297,7 @@ parseAttribute(params); document().incDOMTreeVersion(); + document().notifyChangeAttribute(*this); if (name == HTMLNames::idAttr) { AtomicString oldId = elementData()->idForStyleResolution();
diff --git a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp index f4470c8..af576ea7 100644 --- a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp +++ b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
@@ -236,14 +236,28 @@ m_alreadyStarted = true; + // FIXME: Eventually we'd like to evaluate scripts which are inserted into a + // viewless document but this'll do for now. + // See http://bugs.webkit.org/show_bug.cgi?id=5727 // FIXME: If script is parser inserted, verify it's still in the original // document. Document& elementDocument = m_element->document(); - Document* contextDocument = elementDocument.contextDocument(); - - if (!contextDocument || !contextDocument->allowExecutingScripts(m_element)) + // TODO(kouhei): Remove the following check which doesn't make any sense. + if (!elementDocument.executingFrame()) return false; + Document* contextDocument = elementDocument.contextDocument(); + if (!contextDocument) + return false; + + LocalFrame* contextFrame = contextDocument->executingFrame(); + if (!contextFrame) + return false; + if (!contextFrame->script().canExecuteScripts(AboutToExecuteScript)) + return false; + + LocalFrame* elementFrame = elementDocument.frame(); + if (!isScriptForEventSupported()) return false; @@ -296,13 +310,16 @@ } else if (client->hasSourceAttribute()) { m_pendingScript = PendingScript::create(m_element, m_resource.get()); m_asyncExecType = ScriptRunner::Async; - LocalFrame* frame = m_element->document().frame(); - if (frame) { - ScriptState* scriptState = ScriptState::forMainWorld(frame); - if (scriptState) + if (elementFrame) { + // TODO(kouhei): I'm not sure below is correct. I think we should use + // contextFrame rather than elementFrame. + ScriptState* scriptState = ScriptState::forMainWorld(elementFrame); + if (scriptState) { ScriptStreamer::startStreaming( - m_pendingScript.get(), ScriptStreamer::Async, frame->settings(), - scriptState, frame->frameScheduler()->loadingTaskRunner()); + m_pendingScript.get(), ScriptStreamer::Async, + elementFrame->settings(), scriptState, + elementFrame->frameScheduler()->loadingTaskRunner()); + } } contextDocument->scriptRunner()->queueScriptForExecution(this, m_asyncExecType);
diff --git a/third_party/WebKit/Source/core/dom/SynchronousMutationNotifier.cpp b/third_party/WebKit/Source/core/dom/SynchronousMutationNotifier.cpp index 506cdb9..59474ec 100644 --- a/third_party/WebKit/Source/core/dom/SynchronousMutationNotifier.cpp +++ b/third_party/WebKit/Source/core/dom/SynchronousMutationNotifier.cpp
@@ -11,6 +11,12 @@ SynchronousMutationNotifier::SynchronousMutationNotifier() = default; +void SynchronousMutationNotifier::notifyChangeAttribute( + const Element& element) { + for (SynchronousMutationObserver* observer : m_observers) + observer->didChangeAttribute(element); +} + void SynchronousMutationNotifier::notifyChangeChildren( const ContainerNode& container) { for (SynchronousMutationObserver* observer : m_observers)
diff --git a/third_party/WebKit/Source/core/dom/SynchronousMutationNotifier.h b/third_party/WebKit/Source/core/dom/SynchronousMutationNotifier.h index 813f209..2c1f4b2 100644 --- a/third_party/WebKit/Source/core/dom/SynchronousMutationNotifier.h +++ b/third_party/WebKit/Source/core/dom/SynchronousMutationNotifier.h
@@ -14,6 +14,7 @@ class CharacterData; class ContainerNode; class Document; +class Element; class Node; class NodeWithIndex; class SynchronousMutationObserver; @@ -22,8 +23,7 @@ class CORE_EXPORT SynchronousMutationNotifier : public LifecycleNotifier<Document, SynchronousMutationObserver> { public: - // TODO(yosin): We will have |notifyXXX()| functions defined in - // |SynchronousMutationObserver|. + void notifyChangeAttribute(const Element&); void notifyChangeChildren(const ContainerNode&); void notifyMergeTextNodes(const Text& mergedNode, const NodeWithIndex& nodeToBeRemovedWithIndex,
diff --git a/third_party/WebKit/Source/core/dom/SynchronousMutationObserver.cpp b/third_party/WebKit/Source/core/dom/SynchronousMutationObserver.cpp index 1840e8b..2ceae32 100644 --- a/third_party/WebKit/Source/core/dom/SynchronousMutationObserver.cpp +++ b/third_party/WebKit/Source/core/dom/SynchronousMutationObserver.cpp
@@ -12,6 +12,7 @@ SynchronousMutationObserver::SynchronousMutationObserver() : LifecycleObserver(nullptr) {} +void SynchronousMutationObserver::didChangeAttribute(const Element&) {} void SynchronousMutationObserver::didChangeChildren(const ContainerNode&) {} void SynchronousMutationObserver::didMergeTextNodes(const Text&, const NodeWithIndex&,
diff --git a/third_party/WebKit/Source/core/dom/SynchronousMutationObserver.h b/third_party/WebKit/Source/core/dom/SynchronousMutationObserver.h index ad0311ca..8d4d17f 100644 --- a/third_party/WebKit/Source/core/dom/SynchronousMutationObserver.h +++ b/third_party/WebKit/Source/core/dom/SynchronousMutationObserver.h
@@ -14,6 +14,7 @@ class CharacterData; class ContainerNode; class Document; +class Element; class NodeWithIndex; class Text; @@ -40,6 +41,9 @@ // - didInsertText(Node*, unsigned offset, unsigned length); // - didRemoveText(Node*, unsigned offset, unsigned length); + // Called just after attribute is changed. + virtual void didChangeAttribute(const Element&); + // Called after child nodes changed. virtual void didChangeChildren(const ContainerNode&);
diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp index cee6af42..d5e4f34 100644 --- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp +++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
@@ -930,8 +930,7 @@ } bool nodeIsUserSelectAll(const Node* node) { - return RuntimeEnabledFeatures::userSelectAllEnabled() && node && - node->layoutObject() && + return node && node->layoutObject() && node->layoutObject()->style()->userSelect() == SELECT_ALL; }
diff --git a/third_party/WebKit/Source/core/editing/FrameCaret.cpp b/third_party/WebKit/Source/core/editing/FrameCaret.cpp index b74c2fc..b8b958e 100644 --- a/third_party/WebKit/Source/core/editing/FrameCaret.cpp +++ b/third_party/WebKit/Source/core/editing/FrameCaret.cpp
@@ -66,6 +66,11 @@ visitor->trace(m_frame); visitor->trace(m_previousCaretNode); visitor->trace(m_previousCaretAnchorNode); + SynchronousMutationObserver::trace(visitor); +} + +void FrameCaret::documentAttached(Document* document) { + setContext(document); } const PositionWithAffinity FrameCaret::caretPosition() const { @@ -302,7 +307,7 @@ m_previousCaretVisibility = CaretVisibility::Hidden; } -void FrameCaret::documentDetached() { +void FrameCaret::contextDestroyed(Document*) { m_caretBlinkTimer.stop(); m_previousCaretNode.clear(); m_previousCaretAnchorNode.clear();
diff --git a/third_party/WebKit/Source/core/editing/FrameCaret.h b/third_party/WebKit/Source/core/editing/FrameCaret.h index b50e898..6fc7474 100644 --- a/third_party/WebKit/Source/core/editing/FrameCaret.h +++ b/third_party/WebKit/Source/core/editing/FrameCaret.h
@@ -27,6 +27,7 @@ #define FrameCaret_h #include "core/CoreExport.h" +#include "core/dom/SynchronousMutationObserver.h" #include "core/editing/PositionWithAffinity.h" #include "platform/Timer.h" #include "platform/geometry/LayoutRect.h" @@ -48,7 +49,10 @@ enum class CaretVisibility { Visible, Hidden }; class CORE_EXPORT FrameCaret final - : public GarbageCollectedFinalized<FrameCaret> { + : public GarbageCollectedFinalized<FrameCaret>, + public SynchronousMutationObserver { + USING_GARBAGE_COLLECTED_MIXIN(FrameCaret); + public: FrameCaret(LocalFrame&, const SelectionEditor&); ~FrameCaret(); @@ -56,6 +60,7 @@ const DisplayItemClient& displayItemClient() const; bool isActive() const { return caretPosition().isNotNull(); } + void documentAttached(Document*); void updateAppearance(); // Used to suspend caret blinking while the mouse is down. @@ -79,9 +84,6 @@ void paintCaret(GraphicsContext&, const LayoutPoint&); void dataWillChange(const CharacterData&); - void nodeWillBeRemoved(Node&); - - void documentDetached(); // For unittests bool shouldPaintCaretForTesting() const { return m_shouldPaintCaret; } @@ -98,6 +100,10 @@ void caretBlinkTimerFired(TimerBase*); bool caretPositionIsValidForDocument(const Document&) const; + // Implementation of |SynchronousMutationObserver| member functions. + void contextDestroyed(Document*) final; + void nodeWillBeRemoved(Node&) final; + const Member<const SelectionEditor> m_selectionEditor; const Member<LocalFrame> m_frame; const std::unique_ptr<CaretBase> m_caretBase;
diff --git a/third_party/WebKit/Source/core/editing/FrameSelection.cpp b/third_party/WebKit/Source/core/editing/FrameSelection.cpp index 0238e0b1..464ca35 100644 --- a/third_party/WebKit/Source/core/editing/FrameSelection.cpp +++ b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
@@ -403,8 +403,6 @@ removingNodeRemovesPosition(node, selection().extent()), removingNodeRemovesPosition(node, selection().start()), removingNodeRemovesPosition(node, selection().end())); - - m_frameCaret->nodeWillBeRemoved(node); } static SelectionState selectionStateOf(const Node& node) { @@ -711,6 +709,7 @@ m_document = document; m_useSecureKeyboardEntryWhenActive = false; m_selectionEditor->documentAttached(document); + m_frameCaret->documentAttached(document); } void FrameSelection::documentDetached(const Document& document) { @@ -724,7 +723,6 @@ clearTypingStyle(); m_selectionEditor->documentDetached(document); - m_frameCaret->documentDetached(); } LayoutBlock* FrameSelection::caretLayoutObject() const {
diff --git a/third_party/WebKit/Source/core/editing/SelectionController.cpp b/third_party/WebKit/Source/core/editing/SelectionController.cpp index 774596b..1362a2c 100644 --- a/third_party/WebKit/Source/core/editing/SelectionController.cpp +++ b/third_party/WebKit/Source/core/editing/SelectionController.cpp
@@ -323,59 +323,56 @@ newSelection = createVisibleSelection(builder.build()); } - if (RuntimeEnabledFeatures::userSelectAllEnabled()) { - // TODO(yosin) Should we use |Strategy::rootUserSelectAllForNode()|? - Node* const rootUserSelectAllForMousePressNode = - EditingInFlatTreeStrategy::rootUserSelectAllForNode(mousePressNode); - Node* const rootUserSelectAllForTarget = - EditingInFlatTreeStrategy::rootUserSelectAllForNode(target); - if (rootUserSelectAllForMousePressNode && - rootUserSelectAllForMousePressNode == rootUserSelectAllForTarget) { - newSelection.setBase(mostBackwardCaretPosition( - PositionInFlatTree::beforeNode(rootUserSelectAllForMousePressNode), + // TODO(yosin) Should we use |Strategy::rootUserSelectAllForNode()|? + Node* const rootUserSelectAllForMousePressNode = + EditingInFlatTreeStrategy::rootUserSelectAllForNode(mousePressNode); + Node* const rootUserSelectAllForTarget = + EditingInFlatTreeStrategy::rootUserSelectAllForNode(target); + if (rootUserSelectAllForMousePressNode && + rootUserSelectAllForMousePressNode == rootUserSelectAllForTarget) { + newSelection.setBase(mostBackwardCaretPosition( + PositionInFlatTree::beforeNode(rootUserSelectAllForMousePressNode), + CanCrossEditingBoundary)); + newSelection.setExtent(mostForwardCaretPosition( + PositionInFlatTree::afterNode(rootUserSelectAllForMousePressNode), + CanCrossEditingBoundary)); + } else { + // Reset base for user select all when base is inside user-select-all area + // and extent < base. + if (rootUserSelectAllForMousePressNode) { + PositionInFlatTree eventPosition = toPositionInFlatTree( + target->layoutObject() + ->positionForPoint(hitTestResult.localPoint()) + .position()); + PositionInFlatTree dragStartPosition = + toPositionInFlatTree(mousePressNode->layoutObject() + ->positionForPoint(dragStartPos) + .position()); + if (eventPosition.compareTo(dragStartPosition) < 0) { + newSelection.setBase(mostForwardCaretPosition( + PositionInFlatTree::afterNode(rootUserSelectAllForMousePressNode), + CanCrossEditingBoundary)); + } + } + + if (rootUserSelectAllForTarget && mousePressNode->layoutObject() && + toPositionInFlatTree(target->layoutObject() + ->positionForPoint(hitTestResult.localPoint()) + .position()) + .compareTo( + toPositionInFlatTree(mousePressNode->layoutObject() + ->positionForPoint(dragStartPos) + .position())) < 0) { + newSelection.setExtent(mostBackwardCaretPosition( + PositionInFlatTree::beforeNode(rootUserSelectAllForTarget), CanCrossEditingBoundary)); + } else if (rootUserSelectAllForTarget && mousePressNode->layoutObject()) { newSelection.setExtent(mostForwardCaretPosition( - PositionInFlatTree::afterNode(rootUserSelectAllForMousePressNode), + PositionInFlatTree::afterNode(rootUserSelectAllForTarget), CanCrossEditingBoundary)); } else { - // Reset base for user select all when base is inside user-select-all area - // and extent < base. - if (rootUserSelectAllForMousePressNode) { - PositionInFlatTree eventPosition = toPositionInFlatTree( - target->layoutObject() - ->positionForPoint(hitTestResult.localPoint()) - .position()); - PositionInFlatTree dragStartPosition = - toPositionInFlatTree(mousePressNode->layoutObject() - ->positionForPoint(dragStartPos) - .position()); - if (eventPosition.compareTo(dragStartPosition) < 0) - newSelection.setBase(mostForwardCaretPosition( - PositionInFlatTree::afterNode(rootUserSelectAllForMousePressNode), - CanCrossEditingBoundary)); - } - - if (rootUserSelectAllForTarget && mousePressNode->layoutObject() && - toPositionInFlatTree( - target->layoutObject() - ->positionForPoint(hitTestResult.localPoint()) - .position()) - .compareTo( - toPositionInFlatTree(mousePressNode->layoutObject() - ->positionForPoint(dragStartPos) - .position())) < 0) - newSelection.setExtent(mostBackwardCaretPosition( - PositionInFlatTree::beforeNode(rootUserSelectAllForTarget), - CanCrossEditingBoundary)); - else if (rootUserSelectAllForTarget && mousePressNode->layoutObject()) - newSelection.setExtent(mostForwardCaretPosition( - PositionInFlatTree::afterNode(rootUserSelectAllForTarget), - CanCrossEditingBoundary)); - else - newSelection.setExtent(targetPosition); + newSelection.setExtent(targetPosition); } - } else { - newSelection.setExtent(targetPosition); } // TODO(yosin): We should have |newBase| and |newExtent| instead of
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp index 7551fa9..6c84cce7 100644 --- a/third_party/WebKit/Source/core/editing/VisibleUnits.cpp +++ b/third_party/WebKit/Source/core/editing/VisibleUnits.cpp
@@ -2559,15 +2559,31 @@ LayoutRect localSelectionRectOfPositionTemplate( const PositionWithAffinityTemplate<Strategy>& position, LayoutObject*& layoutObject) { - LayoutRect rect = localCaretRectOfPositionTemplate(position, layoutObject); - - if (rect.isEmpty()) - return rect; + if (position.isNull()) { + layoutObject = nullptr; + return LayoutRect(); + } + Node* node = position.anchorNode(); + layoutObject = node->layoutObject(); + if (!layoutObject) + return LayoutRect(); InlineBoxPosition boxPosition = computeInlineBoxPosition(position.position(), position.affinity()); - InlineTextBox* box = toInlineTextBox(boxPosition.inlineBox); + if (!boxPosition.inlineBox) + return LayoutRect(); + + layoutObject = LineLayoutAPIShim::layoutObjectFrom( + boxPosition.inlineBox->getLineLayoutItem()); + + LayoutRect rect = layoutObject->localCaretRect(boxPosition.inlineBox, + boxPosition.offsetInBox); + + if (rect.isEmpty()) + return rect; + + InlineBox* const box = boxPosition.inlineBox; if (layoutObject->style()->isHorizontalWritingMode()) { rect.setY(box->root().selectionTop()); rect.setHeight(box->root().selectionHeight());
diff --git a/third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp b/third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp index 3d71e54..ee051fb 100644 --- a/third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp +++ b/third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp
@@ -1997,4 +1997,14 @@ EXPECT_TRUE(endsOfNodeAreVisuallyDistinctPositions(button)); } +// Repro case of crbug.com/680428 +TEST_F(VisibleUnitsTest, localSelectionRectOfPositionTemplateNotCrash) { + setBodyContent("<div>foo<img></div>"); + + Node* node = document().querySelector("img"); + IntRect rect = absoluteSelectionBoundsOf(VisiblePosition::create( + PositionWithAffinity(Position(node, PositionAnchorType::AfterChildren)))); + EXPECT_FALSE(rect.isEmpty()); +} + } // namespace blink
diff --git a/third_party/WebKit/Source/core/layout/FloatingObjects.cpp b/third_party/WebKit/Source/core/layout/FloatingObjects.cpp index fa37c00..27b7106 100644 --- a/third_party/WebKit/Source/core/layout/FloatingObjects.cpp +++ b/third_party/WebKit/Source/core/layout/FloatingObjects.cpp
@@ -55,7 +55,7 @@ m_isDescendant(false), m_isPlaced(false), m_isLowestNonOverhangingFloatInChild(false) -#if ENABLE(ASSERT) +#if DCHECK_IS_ON() , m_isInPlacedTree(false) #endif @@ -81,7 +81,7 @@ m_isDescendant(isDescendant), m_isPlaced(true), m_isLowestNonOverhangingFloatInChild(isLowestNonOverhangingFloatInChild) -#if ENABLE(ASSERT) +#if DCHECK_IS_ON() , m_isInPlacedTree(false) #endif
diff --git a/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp b/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp index 82c367b..2b1121c 100644 --- a/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp +++ b/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp
@@ -170,7 +170,13 @@ CRASH(); } -void NEVER_INLINE crashWithXHR() { +void NEVER_INLINE crashWithSyncXHR() { + const char* name = __func__; + WTF::debug::alias(&name); + CRASH(); +} + +void NEVER_INLINE crashWithAsyncXHR() { const char* name = __func__; WTF::debug::alias(&name); CRASH(); @@ -510,7 +516,10 @@ crashWithWorkerScriptLoader(); break; case ClientSpec::kXHR: - crashWithXHR(); + if (m_async) + crashWithAsyncXHR(); + else + crashWithSyncXHR(); break; case ClientSpec::kTesting: crashWithTesting();
diff --git a/third_party/WebKit/Source/core/loader/ImageLoader.cpp b/third_party/WebKit/Source/core/loader/ImageLoader.cpp index 548243f..3dd9552 100644 --- a/third_party/WebKit/Source/core/loader/ImageLoader.cpp +++ b/third_party/WebKit/Source/core/loader/ImageLoader.cpp
@@ -30,7 +30,6 @@ #include "core/dom/Document.h" #include "core/dom/Element.h" #include "core/dom/IncrementLoadEventDelayCount.h" -#include "core/dom/TaskRunnerHelper.h" #include "core/events/Event.h" #include "core/events/EventSender.h" #include "core/fetch/FetchRequest.h" @@ -156,10 +155,7 @@ ImageLoader::ImageLoader(Element* element) : m_element(element), - m_derefElementTimer(TaskRunnerHelper::get(TaskType::Networking, - element->document().frame()), - this, - &ImageLoader::timerFired), + m_derefElementTimer(this, &ImageLoader::timerFired), m_hasPendingLoadEvent(false), m_hasPendingErrorEvent(false), m_imageComplete(true),
diff --git a/third_party/WebKit/Source/core/loader/ImageLoader.h b/third_party/WebKit/Source/core/loader/ImageLoader.h index 0f61c2e..2672727 100644 --- a/third_party/WebKit/Source/core/loader/ImageLoader.h +++ b/third_party/WebKit/Source/core/loader/ImageLoader.h
@@ -159,7 +159,7 @@ GC_PLUGIN_IGNORE("http://crbug.com/383741") Persistent<Element> m_keepAlive; - TaskRunnerTimer<ImageLoader> m_derefElementTimer; + Timer<ImageLoader> m_derefElementTimer; AtomicString m_failedLoadURL; WeakPtr<Task> m_pendingTask; // owned by Microtask std::unique_ptr<IncrementLoadEventDelayCount> m_loadDelayCounter;
diff --git a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp index 9793325f..e766eef 100644 --- a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp +++ b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
@@ -1104,6 +1104,13 @@ m_state = kUnsent; } +void XMLHttpRequest::dispose() { + if (m_loader) { + m_error = true; + m_loader->cancel(); + } +} + void XMLHttpRequest::clearVariablesForLoading() { if (m_blobLoader) { m_blobLoader->cancel();
diff --git a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.h b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.h index 516d17d..0ee3744 100644 --- a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.h +++ b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.h
@@ -73,6 +73,12 @@ DEFINE_WRAPPERTYPEINFO(); USING_GARBAGE_COLLECTED_MIXIN(XMLHttpRequest); + // In some cases hasPendingActivity doesn't work correctly, i.e., + // doesn't keep |this| alive. We need to cancel the loader in such cases, + // which is why we need this pre-finalizer. + // TODO(yhirano): Remove this pre-finalizer when the bug is fixed. + USING_PRE_FINALIZER(XMLHttpRequest, dispose); + public: static XMLHttpRequest* create(ScriptState*); static XMLHttpRequest* create(ExecutionContext*); @@ -130,6 +136,7 @@ const ArrayBufferOrArrayBufferViewOrBlobOrDocumentOrStringOrFormData&, ExceptionState&); void abort(); + void dispose(); void setRequestHeader(const AtomicString& name, const AtomicString& value, ExceptionState&);
diff --git a/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp index ea42449..2b5595fd 100644 --- a/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp +++ b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp
@@ -229,6 +229,25 @@ settings.setHeight(platformSettings.height); } settings.setDeviceId(platformSettings.deviceId); + if (platformSettings.hasFacingMode()) { + switch (platformSettings.facingMode) { + case WebMediaStreamTrack::FacingMode::User: + settings.setFacingMode("user"); + break; + case WebMediaStreamTrack::FacingMode::Environment: + settings.setFacingMode("environment"); + break; + case WebMediaStreamTrack::FacingMode::Left: + settings.setFacingMode("left"); + break; + case WebMediaStreamTrack::FacingMode::Right: + settings.setFacingMode("right"); + break; + default: + // None, or unknown facing mode. Ignore. + break; + } + } } bool MediaStreamTrack::ended() const {
diff --git a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in index 1ceee62..7f02163 100644 --- a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in +++ b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in
@@ -252,7 +252,6 @@ TraceWrappables status=stable TrueColorRendering status=experimental TrustedEventsDefaultAction status=stable -UserSelectAll status=stable WebAnimationsAPI status=experimental WebAnimationsSVG status=experimental WebAssemblySerialization status=test
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py index 7f38a66..3ef668d 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py
@@ -360,7 +360,7 @@ tests_to_skip, num_workers, retry_attempt) def _start_servers(self, tests_to_run): - if self._port.is_wptserve_enabled() and any(self._port.is_wptserve_test(test) for test in tests_to_run): + if any(self._port.is_wptserve_test(test) for test in tests_to_run): self._printer.write_update('Starting WPTServe ...') self._port.start_wptserve() self._wptserve_started = True
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py index f52c30fa..ef62e80 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py
@@ -169,7 +169,6 @@ self._http_server = None self._websocket_server = None - self._is_wptserve_enabled = getattr(options, 'enable_wptserve', False) self._wpt_server = None self._image_differ = None self.server_process_constructor = server_process.ServerProcess # overridable for testing @@ -1147,17 +1146,13 @@ server.start() self._websocket_server = server - def is_wptserve_enabled(self): - """Used as feature flag for WPT Serve feature.""" - return self._is_wptserve_enabled - @staticmethod def is_wptserve_test(test): """Whether wptserve should be used for a given test if enabled.""" return test.startswith("external/wpt/") def should_use_wptserve(self, test): - return self.is_wptserve_enabled() and self.is_wptserve_test(test) + return self.is_wptserve_test(test) def start_wptserve(self): """Start a WPT web server. Raise an error if it can't start or is already running. @@ -1165,7 +1160,6 @@ Ports can stub this out if they don't need a WPT web server to be running. """ assert not self._wpt_server, 'Already running an http server.' - assert self.is_wptserve_enabled(), 'Cannot start server if WPT is not enabled.' # We currently don't support any output mechanism for the WPT server. server = wptserve.WPTServe(self, self.results_directory()) @@ -1321,8 +1315,6 @@ self._filesystem.join(self.layout_tests_dir(), 'StaleTestExpectations'), self._filesystem.join(self.layout_tests_dir(), 'SlowTests'), ] - if self.is_wptserve_enabled(): - paths.append(self._filesystem.join(self.layout_tests_dir(), 'WPTServeExpectations')) paths.extend(self._flag_specific_expectations_files()) return paths
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py index 48061c8..d51c1205 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py
@@ -262,16 +262,6 @@ port.host.filesystem.join(port.layout_tests_dir(), 'SlowTests'), ]) - def test_expectations_files_wptserve_enabled(self): - port = self.make_port(options=optparse.Values(dict(enable_wptserve=True))) - self.assertEqual(port.expectations_files(), [ - port.path_to_generic_test_expectations_file(), - port.host.filesystem.join(port.layout_tests_dir(), 'NeverFixTests'), - port.host.filesystem.join(port.layout_tests_dir(), 'StaleTestExpectations'), - port.host.filesystem.join(port.layout_tests_dir(), 'SlowTests'), - port.host.filesystem.join(port.layout_tests_dir(), 'WPTServeExpectations'), - ]) - def test_check_sys_deps(self): port = self.make_port() port._executive = MockExecutive(exit_code=0) # pylint: disable=protected-access
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py index a041526..fde33712 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests.py
@@ -264,13 +264,6 @@ optparse.make_option( "--child-processes", help="Number of drivers to run in parallel."), - # TODO(tkent): Remove --enable-wptserve. - optparse.make_option( - "--enable-wptserve", - dest="enable_wptserve", - action="store_true", - default=True, - help="Enable running web-platform-tests using WPTserve instead of Apache."), optparse.make_option( "--disable-breakpad", action="store_true",
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/servers/apache_http.py b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/servers/apache_http.py index 238c3f9e..ad41719 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/servers/apache_http.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/servers/apache_http.py
@@ -75,9 +75,9 @@ '-C', 'ServerRoot "%s"' % server_root, '-C', 'DocumentRoot "%s"' % document_root, '-c', 'AliasMatch /(.*/)?js-test-resources/(.+) "%s/$1resources/$2"' % test_dir, - '-c', 'AliasMatch ^/resources/testharness([r.].*) "%s/testharness$1"' % imported_resources_dir, + '-c', 'AliasMatch ^/resources/testharness([r.].*) "%s/resources/testharness$1"' % test_dir, '-c', 'Alias /w3c/resources/WebIDLParser.js "%s/webidl2/lib/webidl2.js"' % imported_resources_dir, - '-c', 'Alias /w3c/resources "%s"' % imported_resources_dir, + '-c', 'Alias /w3c/resources "%s/resources"' % test_dir, '-c', 'Alias /forms-test-resources "%s"' % forms_test_resources_dir, '-c', 'Alias /media-resources "%s"' % media_resources_dir, '-c', 'TypesConfig "%s"' % mime_types_path,
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/deps_updater.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/deps_updater.py index 0f39593b..c17d189 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/deps_updater.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/deps_updater.py
@@ -124,38 +124,18 @@ return True def _copy_resources(self): - """Copies resources from LayoutTests/resources to wpt and vice versa. + """Copies resources from wpt to LayoutTests/resources. - There are resources from our repository that we use instead of the - upstream versions. Conversely, there are also some resources that - are copied in the other direction. - - Specifically: - - testharnessreport.js contains code needed to integrate our testing - with testharness.js; we also want our code to be used for tests - in wpt. - - TODO(qyearsley, jsbell): Document why other other files are copied, - or stop copying them if it's unnecessary. + We copy idlharness.js and testharness.js in wpt to LayoutTests/resources + in order to use them in non-imported tests. If this method is changed, the lists of files expected to be identical in LayoutTests/PRESUBMIT.py should also be changed. """ - # TODO(tkent): resources_to_copy_to_wpt is unnecessary after enabling - # WPTServe. - resources_to_copy_to_wpt = [ - ('testharnessreport.js', 'resources'), - ('WebIDLParser.js', 'resources'), - ('vendor-prefix.js', 'common'), - ] resources_to_copy_from_wpt = [ ('idlharness.js', 'resources'), ('testharness.js', 'resources'), ] - for filename, wpt_subdir in resources_to_copy_to_wpt: - source = self.path_from_webkit_base('LayoutTests', 'resources', filename) - destination = self.path_from_webkit_base('LayoutTests', 'external', WPT_DEST_NAME, wpt_subdir, filename) - self.copyfile(source, destination) - self.run(['git', 'add', destination]) for filename, wpt_subdir in resources_to_copy_from_wpt: source = self.path_from_webkit_base('LayoutTests', 'external', WPT_DEST_NAME, wpt_subdir, filename) destination = self.path_from_webkit_base('LayoutTests', 'resources', filename)
diff --git a/third_party/WebKit/public/platform/WebMediaStreamTrack.h b/third_party/WebKit/public/platform/WebMediaStreamTrack.h index 419bc359..14b69e2b 100644 --- a/third_party/WebKit/public/platform/WebMediaStreamTrack.h +++ b/third_party/WebKit/public/platform/WebMediaStreamTrack.h
@@ -41,16 +41,20 @@ class WebMediaStreamTrack { public: + enum class FacingMode { None, User, Environment, Left, Right }; + struct Settings { bool hasFrameRate() { return frameRate >= 0.0; } bool hasWidth() { return width >= 0; } bool hasHeight() { return height >= 0; } + bool hasFacingMode() { return facingMode != FacingMode::None; } // The variables are read from // MediaStreamTrack::GetSettings only. double frameRate = -1.0; long width = -1; long height = -1; WebString deviceId; + FacingMode facingMode = FacingMode::None; }; class TrackData {
diff --git a/third_party/codesighs/BUILD.gn b/third_party/codesighs/BUILD.gn deleted file mode 100644 index 4d21da3fe..0000000 --- a/third_party/codesighs/BUILD.gn +++ /dev/null
@@ -1,78 +0,0 @@ -# Copyright 2014 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//build/config/features.gni") - -executable("codesighs") { - sources = [ - "codesighs.c", - ] - - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - - deps = [ - "//build/config/sanitizers:deps", - "//build/win:default_exe_manifest", - ] -} - -executable("maptsvdifftool") { - sources = [ - "maptsvdifftool.c", - ] - - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - - deps = [ - "//build/config/sanitizers:deps", - "//build/win:default_exe_manifest", - ] -} - -if (is_win) { - executable("msmap2tsv") { - sources = [ - "msmap2tsv.c", - ] - - libs = [ "dbghelp.lib" ] - - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - - deps = [ - "//build/config/sanitizers:deps", - "//build/win:default_exe_manifest", - ] - } - - executable("msdump2symdb") { - sources = [ - "msdump2symdb.c", - ] - - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - - deps = [ - "//build/config/sanitizers:deps", - "//build/win:default_exe_manifest", - ] - } -} else { - executable("nm2tsv") { - sources = [ - "nm2tsv.c", - ] - - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - - deps = [ - "//build/config/sanitizers:deps", - ] - } -}
diff --git a/third_party/codesighs/LICENSE b/third_party/codesighs/LICENSE deleted file mode 100644 index bc8f037..0000000 --- a/third_party/codesighs/LICENSE +++ /dev/null
@@ -1,567 +0,0 @@ - MOZILLA PUBLIC LICENSE - Version 1.1 - - --------------- - -1. Definitions. - - 1.0.1. "Commercial Use" means distribution or otherwise making the - Covered Code available to a third party. - - 1.1. "Contributor" means each entity that creates or contributes to - the creation of Modifications. - - 1.2. "Contributor Version" means the combination of the Original - Code, prior Modifications used by a Contributor, and the Modifications - made by that particular Contributor. - - 1.3. "Covered Code" means the Original Code or Modifications or the - combination of the Original Code and Modifications, in each case - including portions thereof. - - 1.4. "Electronic Distribution Mechanism" means a mechanism generally - accepted in the software development community for the electronic - transfer of data. - - 1.5. "Executable" means Covered Code in any form other than Source - Code. - - 1.6. "Initial Developer" means the individual or entity identified - as the Initial Developer in the Source Code notice required by Exhibit - A. - - 1.7. "Larger Work" means a work which combines Covered Code or - portions thereof with code not governed by the terms of this License. - - 1.8. "License" means this document. - - 1.8.1. "Licensable" means having the right to grant, to the maximum - extent possible, whether at the time of the initial grant or - subsequently acquired, any and all of the rights conveyed herein. - - 1.9. "Modifications" means any addition to or deletion from the - substance or structure of either the Original Code or any previous - Modifications. When Covered Code is released as a series of files, a - Modification is: - A. Any addition to or deletion from the contents of a file - containing Original Code or previous Modifications. - - B. Any new file that contains any part of the Original Code or - previous Modifications. - - 1.10. "Original Code" means Source Code of computer software code - which is described in the Source Code notice required by Exhibit A as - Original Code, and which, at the time of its release under this - License is not already Covered Code governed by this License. - - 1.10.1. "Patent Claims" means any patent claim(s), now owned or - hereafter acquired, including without limitation, method, process, - and apparatus claims, in any patent Licensable by grantor. - - 1.11. "Source Code" means the preferred form of the Covered Code for - making modifications to it, including all modules it contains, plus - any associated interface definition files, scripts used to control - compilation and installation of an Executable, or source code - differential comparisons against either the Original Code or another - well known, available Covered Code of the Contributor's choice. The - Source Code can be in a compressed or archival form, provided the - appropriate decompression or de-archiving software is widely available - for no charge. - - 1.12. "You" (or "Your") means an individual or a legal entity - exercising rights under, and complying with all of the terms of, this - License or a future version of this License issued under Section 6.1. - For legal entities, "You" includes any entity which controls, is - controlled by, or is under common control with You. For purposes of - this definition, "control" means (a) the power, direct or indirect, - to cause the direction or management of such entity, whether by - contract or otherwise, or (b) ownership of more than fifty percent - (50%) of the outstanding shares or beneficial ownership of such - entity. - -2. Source Code License. - - 2.1. The Initial Developer Grant. - The Initial Developer hereby grants You a world-wide, royalty-free, - non-exclusive license, subject to third party intellectual property - claims: - (a) under intellectual property rights (other than patent or - trademark) Licensable by Initial Developer to use, reproduce, - modify, display, perform, sublicense and distribute the Original - Code (or portions thereof) with or without Modifications, and/or - as part of a Larger Work; and - - (b) under Patents Claims infringed by the making, using or - selling of Original Code, to make, have made, use, practice, - sell, and offer for sale, and/or otherwise dispose of the - Original Code (or portions thereof). - - (c) the licenses granted in this Section 2.1(a) and (b) are - effective on the date Initial Developer first distributes - Original Code under the terms of this License. - - (d) Notwithstanding Section 2.1(b) above, no patent license is - granted: 1) for code that You delete from the Original Code; 2) - separate from the Original Code; or 3) for infringements caused - by: i) the modification of the Original Code or ii) the - combination of the Original Code with other software or devices. - - 2.2. Contributor Grant. - Subject to third party intellectual property claims, each Contributor - hereby grants You a world-wide, royalty-free, non-exclusive license - - (a) under intellectual property rights (other than patent or - trademark) Licensable by Contributor, to use, reproduce, modify, - display, perform, sublicense and distribute the Modifications - created by such Contributor (or portions thereof) either on an - unmodified basis, with other Modifications, as Covered Code - and/or as part of a Larger Work; and - - (b) under Patent Claims infringed by the making, using, or - selling of Modifications made by that Contributor either alone - and/or in combination with its Contributor Version (or portions - of such combination), to make, use, sell, offer for sale, have - made, and/or otherwise dispose of: 1) Modifications made by that - Contributor (or portions thereof); and 2) the combination of - Modifications made by that Contributor with its Contributor - Version (or portions of such combination). - - (c) the licenses granted in Sections 2.2(a) and 2.2(b) are - effective on the date Contributor first makes Commercial Use of - the Covered Code. - - (d) Notwithstanding Section 2.2(b) above, no patent license is - granted: 1) for any code that Contributor has deleted from the - Contributor Version; 2) separate from the Contributor Version; - 3) for infringements caused by: i) third party modifications of - Contributor Version or ii) the combination of Modifications made - by that Contributor with other software (except as part of the - Contributor Version) or other devices; or 4) under Patent Claims - infringed by Covered Code in the absence of Modifications made by - that Contributor. - -3. Distribution Obligations. - - 3.1. Application of License. - The Modifications which You create or to which You contribute are - governed by the terms of this License, including without limitation - Section 2.2. The Source Code version of Covered Code may be - distributed only under the terms of this License or a future version - of this License released under Section 6.1, and You must include a - copy of this License with every copy of the Source Code You - distribute. You may not offer or impose any terms on any Source Code - version that alters or restricts the applicable version of this - License or the recipients' rights hereunder. However, You may include - an additional document offering the additional rights described in - Section 3.5. - - 3.2. Availability of Source Code. - Any Modification which You create or to which You contribute must be - made available in Source Code form under the terms of this License - either on the same media as an Executable version or via an accepted - Electronic Distribution Mechanism to anyone to whom you made an - Executable version available; and if made available via Electronic - Distribution Mechanism, must remain available for at least twelve (12) - months after the date it initially became available, or at least six - (6) months after a subsequent version of that particular Modification - has been made available to such recipients. You are responsible for - ensuring that the Source Code version remains available even if the - Electronic Distribution Mechanism is maintained by a third party. - - 3.3. Description of Modifications. - You must cause all Covered Code to which You contribute to contain a - file documenting the changes You made to create that Covered Code and - the date of any change. You must include a prominent statement that - the Modification is derived, directly or indirectly, from Original - Code provided by the Initial Developer and including the name of the - Initial Developer in (a) the Source Code, and (b) in any notice in an - Executable version or related documentation in which You describe the - origin or ownership of the Covered Code. - - 3.4. Intellectual Property Matters - (a) Third Party Claims. - If Contributor has knowledge that a license under a third party's - intellectual property rights is required to exercise the rights - granted by such Contributor under Sections 2.1 or 2.2, - Contributor must include a text file with the Source Code - distribution titled "LEGAL" which describes the claim and the - party making the claim in sufficient detail that a recipient will - know whom to contact. If Contributor obtains such knowledge after - the Modification is made available as described in Section 3.2, - Contributor shall promptly modify the LEGAL file in all copies - Contributor makes available thereafter and shall take other steps - (such as notifying appropriate mailing lists or newsgroups) - reasonably calculated to inform those who received the Covered - Code that new knowledge has been obtained. - - (b) Contributor APIs. - If Contributor's Modifications include an application programming - interface and Contributor has knowledge of patent licenses which - are reasonably necessary to implement that API, Contributor must - also include this information in the LEGAL file. - - (c) Representations. - Contributor represents that, except as disclosed pursuant to - Section 3.4(a) above, Contributor believes that Contributor's - Modifications are Contributor's original creation(s) and/or - Contributor has sufficient rights to grant the rights conveyed by - this License. - - 3.5. Required Notices. - You must duplicate the notice in Exhibit A in each file of the Source - Code. If it is not possible to put such notice in a particular Source - Code file due to its structure, then You must include such notice in a - location (such as a relevant directory) where a user would be likely - to look for such a notice. If You created one or more Modification(s) - You may add your name as a Contributor to the notice described in - Exhibit A. You must also duplicate this License in any documentation - for the Source Code where You describe recipients' rights or ownership - rights relating to Covered Code. You may choose to offer, and to - charge a fee for, warranty, support, indemnity or liability - obligations to one or more recipients of Covered Code. However, You - may do so only on Your own behalf, and not on behalf of the Initial - Developer or any Contributor. You must make it absolutely clear than - any such warranty, support, indemnity or liability obligation is - offered by You alone, and You hereby agree to indemnify the Initial - Developer and every Contributor for any liability incurred by the - Initial Developer or such Contributor as a result of warranty, - support, indemnity or liability terms You offer. - - 3.6. Distribution of Executable Versions. - You may distribute Covered Code in Executable form only if the - requirements of Section 3.1-3.5 have been met for that Covered Code, - and if You include a notice stating that the Source Code version of - the Covered Code is available under the terms of this License, - including a description of how and where You have fulfilled the - obligations of Section 3.2. The notice must be conspicuously included - in any notice in an Executable version, related documentation or - collateral in which You describe recipients' rights relating to the - Covered Code. You may distribute the Executable version of Covered - Code or ownership rights under a license of Your choice, which may - contain terms different from this License, provided that You are in - compliance with the terms of this License and that the license for the - Executable version does not attempt to limit or alter the recipient's - rights in the Source Code version from the rights set forth in this - License. If You distribute the Executable version under a different - license You must make it absolutely clear that any terms which differ - from this License are offered by You alone, not by the Initial - Developer or any Contributor. You hereby agree to indemnify the - Initial Developer and every Contributor for any liability incurred by - the Initial Developer or such Contributor as a result of any such - terms You offer. - - 3.7. Larger Works. - You may create a Larger Work by combining Covered Code with other code - not governed by the terms of this License and distribute the Larger - Work as a single product. In such a case, You must make sure the - requirements of this License are fulfilled for the Covered Code. - -4. Inability to Comply Due to Statute or Regulation. - - If it is impossible for You to comply with any of the terms of this - License with respect to some or all of the Covered Code due to - statute, judicial order, or regulation then You must: (a) comply with - the terms of this License to the maximum extent possible; and (b) - describe the limitations and the code they affect. Such description - must be included in the LEGAL file described in Section 3.4 and must - be included with all distributions of the Source Code. Except to the - extent prohibited by statute or regulation, such description must be - sufficiently detailed for a recipient of ordinary skill to be able to - understand it. - -5. Application of this License. - - This License applies to code to which the Initial Developer has - attached the notice in Exhibit A and to related Covered Code. - -6. Versions of the License. - - 6.1. New Versions. - Netscape Communications Corporation ("Netscape") may publish revised - and/or new versions of the License from time to time. Each version - will be given a distinguishing version number. - - 6.2. Effect of New Versions. - Once Covered Code has been published under a particular version of the - License, You may always continue to use it under the terms of that - version. You may also choose to use such Covered Code under the terms - of any subsequent version of the License published by Netscape. No one - other than Netscape has the right to modify the terms applicable to - Covered Code created under this License. - - 6.3. Derivative Works. - If You create or use a modified version of this License (which you may - only do in order to apply it to code which is not already Covered Code - governed by this License), You must (a) rename Your license so that - the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", - "MPL", "NPL" or any confusingly similar phrase do not appear in your - license (except to note that your license differs from this License) - and (b) otherwise make it clear that Your version of the license - contains terms which differ from the Mozilla Public License and - Netscape Public License. (Filling in the name of the Initial - Developer, Original Code or Contributor in the notice described in - Exhibit A shall not of themselves be deemed to be modifications of - this License.) - -7. DISCLAIMER OF WARRANTY. - - COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, - WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF - DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. - THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE - IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, - YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE - COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER - OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF - ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. - -8. TERMINATION. - - 8.1. This License and the rights granted hereunder will terminate - automatically if You fail to comply with terms herein and fail to cure - such breach within 30 days of becoming aware of the breach. All - sublicenses to the Covered Code which are properly granted shall - survive any termination of this License. Provisions which, by their - nature, must remain in effect beyond the termination of this License - shall survive. - - 8.2. If You initiate litigation by asserting a patent infringement - claim (excluding declatory judgment actions) against Initial Developer - or a Contributor (the Initial Developer or Contributor against whom - You file such action is referred to as "Participant") alleging that: - - (a) such Participant's Contributor Version directly or indirectly - infringes any patent, then any and all rights granted by such - Participant to You under Sections 2.1 and/or 2.2 of this License - shall, upon 60 days notice from Participant terminate prospectively, - unless if within 60 days after receipt of notice You either: (i) - agree in writing to pay Participant a mutually agreeable reasonable - royalty for Your past and future use of Modifications made by such - Participant, or (ii) withdraw Your litigation claim with respect to - the Contributor Version against such Participant. If within 60 days - of notice, a reasonable royalty and payment arrangement are not - mutually agreed upon in writing by the parties or the litigation claim - is not withdrawn, the rights granted by Participant to You under - Sections 2.1 and/or 2.2 automatically terminate at the expiration of - the 60 day notice period specified above. - - (b) any software, hardware, or device, other than such Participant's - Contributor Version, directly or indirectly infringes any patent, then - any rights granted to You by such Participant under Sections 2.1(b) - and 2.2(b) are revoked effective as of the date You first made, used, - sold, distributed, or had made, Modifications made by that - Participant. - - 8.3. If You assert a patent infringement claim against Participant - alleging that such Participant's Contributor Version directly or - indirectly infringes any patent where such claim is resolved (such as - by license or settlement) prior to the initiation of patent - infringement litigation, then the reasonable value of the licenses - granted by such Participant under Sections 2.1 or 2.2 shall be taken - into account in determining the amount or value of any payment or - license. - - 8.4. In the event of termination under Sections 8.1 or 8.2 above, - all end user license agreements (excluding distributors and resellers) - which have been validly granted by You or any distributor hereunder - prior to termination shall survive termination. - -9. LIMITATION OF LIABILITY. - - UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT - (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL - DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, - OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR - ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY - CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, - WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER - COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN - INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF - LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY - RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW - PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE - EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO - THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. - -10. U.S. GOVERNMENT END USERS. - - The Covered Code is a "commercial item," as that term is defined in - 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer - software" and "commercial computer software documentation," as such - terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 - C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), - all U.S. Government End Users acquire Covered Code with only those - rights set forth herein. - -11. MISCELLANEOUS. - - This License represents the complete agreement concerning subject - matter hereof. If any provision of this License is held to be - unenforceable, such provision shall be reformed only to the extent - necessary to make it enforceable. This License shall be governed by - California law provisions (except to the extent applicable law, if - any, provides otherwise), excluding its conflict-of-law provisions. - With respect to disputes in which at least one party is a citizen of, - or an entity chartered or registered to do business in the United - States of America, any litigation relating to this License shall be - subject to the jurisdiction of the Federal Courts of the Northern - District of California, with venue lying in Santa Clara County, - California, with the losing party responsible for costs, including - without limitation, court costs and reasonable attorneys' fees and - expenses. The application of the United Nations Convention on - Contracts for the International Sale of Goods is expressly excluded. - Any law or regulation which provides that the language of a contract - shall be construed against the drafter shall not apply to this - License. - -12. RESPONSIBILITY FOR CLAIMS. - - As between Initial Developer and the Contributors, each party is - responsible for claims and damages arising, directly or indirectly, - out of its utilization of rights under this License and You agree to - work with Initial Developer and Contributors to distribute such - responsibility on an equitable basis. Nothing herein is intended or - shall be deemed to constitute any admission of liability. - -13. MULTIPLE-LICENSED CODE. - - Initial Developer may designate portions of the Covered Code as - "Multiple-Licensed". "Multiple-Licensed" means that the Initial - Developer permits you to utilize portions of the Covered Code under - Your choice of the NPL or the alternative licenses, if any, specified - by the Initial Developer in the file described in Exhibit A. - -EXHIBIT A -Mozilla Public License. - - ``The contents of this file are subject to the Mozilla Public License - Version 1.1 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the - License for the specific language governing rights and limitations - under the License. - - The Original Code is ______________________________________. - - The Initial Developer of the Original Code is ________________________. - Portions created by ______________________ are Copyright (C) ______ - _______________________. All Rights Reserved. - - Contributor(s): ______________________________________. - - Alternatively, the contents of this file may be used under the terms - of the _____ license (the "[___] License"), in which case the - provisions of [______] License are applicable instead of those - above. If you wish to allow use of your version of this file only - under the terms of the [____] License and not to allow others to use - your version of this file under the MPL, indicate your decision by - deleting the provisions above and replace them with the notice and - other provisions required by the [___] License. If you do not delete - the provisions above, a recipient may use your version of this file - under either the MPL or the [___] License." - - [NOTE: The text of this Exhibit A may differ slightly from the text of - the notices in the Source Code files of the Original Code. You should - use the text of this Exhibit A rather than the text found in the - Original Code Source Code for Your Modifications.] - - ---------------------------------------------------------------------- - - AMENDMENTS - - The Netscape Public License Version 1.1 ("NPL") consists of the - Mozilla Public License Version 1.1 with the following Amendments, - including Exhibit A-Netscape Public License. Files identified with - "Exhibit A-Netscape Public License" are governed by the Netscape - Public License Version 1.1. - - Additional Terms applicable to the Netscape Public License. - I. Effect. - These additional terms described in this Netscape Public - License -- Amendments shall apply to the Mozilla Communicator - client code and to all Covered Code under this License. - - II. "Netscape's Branded Code" means Covered Code that Netscape - distributes and/or permits others to distribute under one or more - trademark(s) which are controlled by Netscape but which are not - licensed for use under this License. - - III. Netscape and logo. - This License does not grant any rights to use the trademarks - "Netscape", the "Netscape N and horizon" logo or the "Netscape - lighthouse" logo, "Netcenter", "Gecko", "Java" or "JavaScript", - "Smart Browsing" even if such marks are included in the Original - Code or Modifications. - - IV. Inability to Comply Due to Contractual Obligation. - Prior to licensing the Original Code under this License, Netscape - has licensed third party code for use in Netscape's Branded Code. - To the extent that Netscape is limited contractually from making - such third party code available under this License, Netscape may - choose to reintegrate such code into Covered Code without being - required to distribute such code in Source Code form, even if - such code would otherwise be considered "Modifications" under - this License. - - V. Use of Modifications and Covered Code by Initial Developer. - V.1. In General. - The obligations of Section 3 apply to Netscape, except to - the extent specified in this Amendment, Section V.2 and V.3. - - V.2. Other Products. - Netscape may include Covered Code in products other than the - Netscape's Branded Code which are released by Netscape - during the two (2) years following the release date of the - Original Code, without such additional products becoming - subject to the terms of this License, and may license such - additional products on different terms from those contained - in this License. - - V.3. Alternative Licensing. - Netscape may license the Source Code of Netscape's Branded - Code, including Modifications incorporated therein, without - such Netscape Branded Code becoming subject to the terms of - this License, and may license such Netscape Branded Code on - different terms from those contained in this License. - - VI. Litigation. - Notwithstanding the limitations of Section 11 above, the - provisions regarding litigation in Section 11(a), (b) and (c) of - the License shall apply to all disputes relating to this License. - - EXHIBIT A-Netscape Public License. - - "The contents of this file are subject to the Netscape Public - License Version 1.1 (the "License"); you may not use this file - except in compliance with the License. You may obtain a copy of - the License at http://www.mozilla.org/NPL/ - - Software distributed under the License is distributed on an "AS - IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - implied. See the License for the specific language governing - rights and limitations under the License. - - The Original Code is Mozilla Communicator client code, released - March 31, 1998. - - The Initial Developer of the Original Code is Netscape - Communications Corporation. Portions created by Netscape are - Copyright (C) 1998-1999 Netscape Communications Corporation. All - Rights Reserved. - - Contributor(s): ______________________________________. - - Alternatively, the contents of this file may be used under the - terms of the _____ license (the "[___] License"), in which case - the provisions of [______] License are applicable instead of - those above. If you wish to allow use of your version of this - file only under the terms of the [____] License and not to allow - others to use your version of this file under the NPL, indicate - your decision by deleting the provisions above and replace them - with the notice and other provisions required by the [___] - License. If you do not delete the provisions above, a recipient - may use your version of this file under either the NPL or the - [___] License."
diff --git a/third_party/codesighs/Makefile.in b/third_party/codesighs/Makefile.in deleted file mode 100644 index e243f2d..0000000 --- a/third_party/codesighs/Makefile.in +++ /dev/null
@@ -1,75 +0,0 @@ -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is mozilla.org code. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 1998 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Garrett Arch Blythe -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -REQUIRES = $(NULL) - -CSRCS += \ - codesighs.c \ - maptsvdifftool.c \ - $(NULL) - -ifeq ($(OS_ARCH),WINNT) -CSRCS += \ - msmap2tsv.c \ - msdump2symdb.c \ - $(NULL) -else -CSRCS += \ - nm2tsv.c \ - $(NULL) -endif - -SIMPLE_PROGRAMS = $(CSRCS:.c=$(BIN_SUFFIX)) - -include $(topsrcdir)/config/config.mk - -ifeq ($(OS_ARCH),WINNT) -OS_LIBS += \ - imagehlp.lib \ - $(NULL) -endif - - -include $(topsrcdir)/config/rules.mk
diff --git a/third_party/codesighs/README.chromium b/third_party/codesighs/README.chromium deleted file mode 100644 index 7abdc81..0000000 --- a/third_party/codesighs/README.chromium +++ /dev/null
@@ -1,19 +0,0 @@ -Name: codesighs -URL: http://hg.mozilla.org/mozilla-central/tools/codesighs -Version: unknown -License: MPL 1.1/GPL 2.0/LGPL 2.1 -License File: NOT_SHIPPED -Security Critical: no - -Description: -This is Chromium's copy of the Mozilla codesighs tool. - -Originally obtained from Mozilla's Mercurial repository -on 17 April 2009. - -The LICENSE from http://hg.mozilla.org/mozilla-central has been copied -here. - -There are no local changes to the code itself. - -A codesighs.gyp file has been added for building with Chromium.
diff --git a/third_party/codesighs/autosummary.unix.bash b/third_party/codesighs/autosummary.unix.bash deleted file mode 100755 index a35f92a..0000000 --- a/third_party/codesighs/autosummary.unix.bash +++ /dev/null
@@ -1,250 +0,0 @@ -#!/bin/bash -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is autosummary.linx.bash code, released -# Oct 10, 2002. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 2002 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Garrett Arch Blythe, 10-October-2002 -# Simon Fraser <sfraser@netscape.com> -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -# -# Check for optional objdir -# -if [ "$1" = "-o" ]; then -OBJROOT="$2" -shift -shift -else -OBJROOT="./mozilla" -fi - -if [ "$1" = "-s" ]; then -SRCROOT="$2" -shift -shift -else -SRCROOT="./mozilla" -fi - -# -# A little help for my friends. -# -if [ "-h" == "$1" ];then - SHOWHELP="1" -fi -if [ "--help" == "$1" ];then - SHOWHELP="1" -fi -if [ "" == "$1" ]; then - SHOWHELP="1" -fi -if [ "" == "$2" ]; then - SHOWHELP="1" -fi -if [ "" == "$3" ]; then - SHOWHELP="1" -fi - - -# -# Show the help if required. -# -if [ $SHOWHELP ]; then - echo "usage: $0 <save_results> <old_results> <summary>" - echo " <save_results> is a file that will receive the results of this run." - echo " This file can be used in a future run as the old results." - echo " <old_results> is a results file from a previous run." - echo " It is used to diff with current results and come up with a summary" - echo " of changes." - echo " It is OK if the file does not exist, just supply the argument." - echo " <summary> is a file which will contain a human readable report." - echo " This file is most useful by providing more information than the" - echo " normally single digit output of this script." - echo "" - echo "Run this command from the parent directory of the mozilla tree." - echo "" - echo "This command will output two numbers to stdout that will represent" - echo " the total size of all code and data, and a delta from the prior." - echo " the old results." - echo "For much more detail on size drifts refer to the summary report." - echo "" - echo "This tool reports on all executables in the directory tree." - exit -fi - -# -# Stash our arguments away. -# -COPYSORTTSV="$1" -OLDTSVFILE="$2" -SUMMARYFILE="$3" - -OSTYPE=`uname -s` - -# -# On Mac OS X, use the --zerodrift option to maptsvdifftool -# -if [ $OSTYPE == "Darwin" ]; then -ZERODRIFT="--zerodrift" -else -ZERODRIFT="" -fi - -# -# Create our temporary directory. -# mktemp on Darwin doesn't support -d (suckage) -# -if [ $OSTYPE == "Darwin" ]; then -ZERODRIFT="--zerodrift" -MYTMPDIR=`mktemp ./codesighs.tmp.XXXXXXXX` -rm $MYTMPDIR -mkdir $MYTMPDIR -else -MYTMPDIR=`mktemp -d ./codesighs.tmp.XXXXXXXX` -fi - -# -# Find all relevant files. -# -ALLFILES="$MYTMPDIR/allfiles.list" - -if [ $OSTYPE == "Darwin" ] || [ $OSTYPE == "SunOS" ]; then -find $OBJROOT/dist/bin ! -type d > $ALLFILES -else -find $OBJROOT/dist/bin -not -type d > $ALLFILES -fi - -# Check whether we have 'eu-readelf' or 'readelf' available. -# If we do, it will give more accurate symbol sizes than nm. - -if [ $OSTYPE == "Darwin" ]; then - USE_READELF= -else -READELF_PROG=`which eu-readelf 2>/dev/null | grep /eu-readelf$` -if test "$READELF_PROG"; then - USE_READELF=1 -else - READELF_PROG=`which readelf 2>/dev/null | grep /readelf$` - if test "$READELF_PROG"; then - # Check whether we need -W - if readelf --help | grep "\--wide" >&/dev/null; then - READELF_PROG="readelf -W" - else - READELF_PROG="readelf" - fi - USE_READELF=1 - else - USE_READELF= - fi -fi -fi - -RAWTSVFILE="$MYTMPDIR/raw.tsv" -if test "$USE_READELF"; then -export READELF_PROG -xargs -n 1 $SRCROOT/tools/codesighs/readelf_wrap.pl < $ALLFILES > $RAWTSVFILE 2> /dev/null -else - -# -# Produce the cumulative nm output. -# We are very particular on what switches to use. -# nm --format=bsd --size-sort --print-file-name --demangle -# -# Darwin (Mac OS X) has a lame nm that we have to wrap in a perl -# script to get decent output. -# -NMRESULTS="$MYTMPDIR/nm.txt" -if [ $OSTYPE == "Darwin" ]; then -xargs -n 1 $SRCROOT/tools/codesighs/nm_wrap_osx.pl < $ALLFILES > $NMRESULTS 2> /dev/null -else -xargs -n 1 nm --format=bsd --size-sort --print-file-name --demangle < $ALLFILES > $NMRESULTS 2> /dev/null -fi - - -# -# Produce the TSV output. -# - -$OBJROOT/dist/bin/nm2tsv --input $NMRESULTS > $RAWTSVFILE - -fi # USE_READELF - -# -# Sort the TSV output for useful diffing and eyeballing in general. -# -sort -r $RAWTSVFILE > $COPYSORTTSV - - -# -# If a historical file was specified, diff it with our sorted tsv values. -# Run it through a tool to summaries the diffs to the module -# level report. -# Otherwise, generate the module level report from our new data. -# - -rm -f $SUMMARYFILE -DIFFFILE="$MYTMPDIR/diff.txt" -if [ -e $OLDTSVFILE ]; then - diff $OLDTSVFILE $COPYSORTTSV > $DIFFFILE - $OBJROOT/dist/bin/maptsvdifftool $ZERODRIFT --input $DIFFFILE >> $SUMMARYFILE -else - $OBJROOT/dist/bin/codesighs --modules --input $COPYSORTTSV >> $SUMMARYFILE -fi - - -# -# Output our numbers, that will let tinderbox specify everything all -# at once. -# First number is in fact the total size of all code and data in the map -# files parsed. -# Second number, if present, is growth/shrinkage. -# - -if [ $TINDERBOX_OUTPUT ]; then - echo -n "__codesize:" -fi -$OBJROOT/dist/bin/codesighs --totalonly --input $COPYSORTTSV - -if [ -e $DIFFFILE ]; then -if [ $TINDERBOX_OUTPUT ]; then - echo -n "__codesizeDiff:" -fi - $OBJROOT/dist/bin/maptsvdifftool $ZERODRIFT --summary --input $DIFFFILE -fi - -# -# Remove our temporary directory. -# -rm -rf $MYTMPDIR
diff --git a/third_party/codesighs/autosummary.win.bash b/third_party/codesighs/autosummary.win.bash deleted file mode 100755 index d501625..0000000 --- a/third_party/codesighs/autosummary.win.bash +++ /dev/null
@@ -1,211 +0,0 @@ -#!/bin/bash -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is autosummary.win.bash code, released -# Oct 3, 2002. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 2002 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Garrett Arch Blythe, 03-October-2002 -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -# -# Check for optional objdir -# -if [ "$1" = "-o" ]; then -OBJROOT="$2" -shift -shift -else -OBJROOT="./mozilla" -fi - -if [ "$1" = "-s" ]; then -SRCROOT="$2" -shift -shift -else -SRCROOT="./mozilla" -fi - -# -# A little help for my friends. -# -if [ "-h" == "$1" ];then - SHOWHELP="1" -fi -if [ "--help" == "$1" ];then - SHOWHELP="1" -fi -if [ "" == "$1" ]; then - SHOWHELP="1" -fi -if [ "" == "$2" ]; then - SHOWHELP="1" -fi -if [ "" == "$3" ]; then - SHOWHELP="1" -fi - - -# -# Show the help if required. -# -if [ $SHOWHELP ]; then - echo "usage: $0 <save_results> <old_results> <summary>" - echo " <save_results> is a file that will receive the results of this run." - echo " This file can be used in a future run as the old results." - echo " <old_results> is a results file from a previous run." - echo " It is used to diff with current results and come up with a summary" - echo " of changes." - echo " It is OK if the file does not exist, just supply the argument." - echo " <summary> is a file which will contain a human readable report." - echo " This file is most useful by providing more information than the" - echo " normally single digit output of this script." - echo "" - echo "Run this command from the parent directory of the mozilla tree." - echo "" - echo "This command will output two numbers to stdout that will represent" - echo " the total size of all code and data, and a delta from the prior." - echo " the old results." - echo "For much more detail on size drifts refer to the summary report." - echo "" - echo "This tool reports on all executables in the directory tree." - exit -fi - - -# -# Stash our arguments away. -# -COPYSORTTSV="$1" -OLDTSVFILE="$2" -SUMMARYFILE="$3" - - -# -# Create our temporary directory. -# -MYTMPDIR=`mktemp -d ./codesighs.tmp.XXXXXXXX` - - -# -# Find the types of files we are interested in. -# -ONEFINDPASS="$MYTMPDIR/onefind.list" -/usr/bin/find $OBJROOT -type f -name "*.obj" -or -name "*.map" | while read FNAME; do - cygpath -m $FNAME >> $ONEFINDPASS -done - - -# -# Find all object files. -# -ALLOBJSFILE="$MYTMPDIR/allobjs.list" -grep -i "\.obj$" < $ONEFINDPASS > $ALLOBJSFILE - - -# -# Get a dump of the symbols in every object file. -# -ALLOBJSYMSFILE="$MYTMPDIR/allobjsyms.list" -xargs -n 1 dumpbin.exe /symbols < $ALLOBJSFILE > $ALLOBJSYMSFILE 2> /dev/null - - -# -# Produce the symdb for the symbols in all object files. -# -SYMDBFILE="$MYTMPDIR/symdb.tsv" -$OBJROOT/dist/bin/msdump2symdb --input $ALLOBJSYMSFILE | /usr/bin/sort > $SYMDBFILE 2> /dev/null - - -# -# Find all map files. -# -ALLMAPSFILE="$MYTMPDIR/allmaps.list" -grep -i "\.map$" < $ONEFINDPASS > $ALLMAPSFILE - - -# -# Produce the TSV output. -# -RAWTSVFILE="$MYTMPDIR/raw.tsv" -$OBJROOT/dist/bin/msmap2tsv --symdb $SYMDBFILE --batch < $ALLMAPSFILE > $RAWTSVFILE 2> /dev/null - - -# -# Sort the TSV output for useful diffing and eyeballing in general. -# -/usr/bin/sort -r $RAWTSVFILE > $COPYSORTTSV - - -# -# If a historical file was specified, diff it with our sorted tsv values. -# Run it through a tool to summaries the diffs to the module -# level report. -# Otherwise, generate the module level report from our new data. -# -rm -f $SUMMARYFILE -DIFFFILE="$MYTMPDIR/diff.txt" -if [ -e $OLDTSVFILE ]; then - diff $OLDTSVFILE $COPYSORTTSV > $DIFFFILE - $OBJROOT/dist/bin/maptsvdifftool --negation --input $DIFFFILE | dos2unix >> $SUMMARYFILE -else - $OBJROOT/dist/bin/codesighs --modules --input $COPYSORTTSV | dos2unix >> $SUMMARYFILE -fi - - -# -# Output our numbers, that will let tinderbox specify everything all -# at once. -# First number is in fact the total size of all code and data in the map -# files parsed. -# Second number, if present, is growth/shrinkage. -# - -if [ $TINDERBOX_OUTPUT ]; then - echo -n "__codesize:" -fi -$OBJROOT/dist/bin/codesighs --totalonly --input $COPYSORTTSV | dos2unix - - -if [ -e $DIFFFILE ]; then -if [ $TINDERBOX_OUTPUT ]; then - echo -n "__codesizeDiff:" -fi - $OBJROOT/dist/bin/maptsvdifftool --negation --summary --input $DIFFFILE | dos2unix -fi - -# -# Remove our temporary directory. -# -rm -rf $MYTMPDIR
diff --git a/third_party/codesighs/basesummary.unix.bash b/third_party/codesighs/basesummary.unix.bash deleted file mode 100755 index 34cd298..0000000 --- a/third_party/codesighs/basesummary.unix.bash +++ /dev/null
@@ -1,254 +0,0 @@ -#!/bin/bash -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is basesummary.linx.bash code, released -# Nov 15, 2002. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 2002 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Garrett Arch Blythe, 15-November-2002 -# Simon Fraser <sfraser@netscape.com> -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -# -# Check for optional objdir -# -if [ "$1" = "-o" ]; then -OBJROOT="$2" -shift -shift -else -OBJROOT="./mozilla" -fi - -if [ "$1" = "-s" ]; then -SRCROOT="$2" -shift -shift -else -SRCROOT="./mozilla" -fi - -OSTYPE=`uname -s` - -if [ $OSTYPE == "Darwin" ]; then -MANIFEST="$SRCROOT/embedding/config/basebrowser-mac-macho" -else -MANIFEST="$SRCROOT/embedding/config/basebrowser-unix" -fi - -# -# A little help for my friends. -# -if [ "-h" == "$1" ];then - SHOWHELP="1" -fi -if [ "--help" == "$1" ];then - SHOWHELP="1" -fi -if [ "" == "$1" ]; then - SHOWHELP="1" -fi -if [ "" == "$2" ]; then - SHOWHELP="1" -fi -if [ "" == "$3" ]; then - SHOWHELP="1" -fi - - -# -# Show the help if required. -# -if [ $SHOWHELP ]; then - echo "usage: $0 <save_results> <old_results> <summary>" - echo " <save_results> is a file that will receive the results of this run." - echo " This file can be used in a future run as the old results." - echo " <old_results> is a results file from a previous run." - echo " It is used to diff with current results and come up with a summary" - echo " of changes." - echo " It is OK if the file does not exist, just supply the argument." - echo " <summary> is a file which will contain a human readable report." - echo " This file is most useful by providing more information than the" - echo " normally single digit output of this script." - echo "" - echo "Run this command from the parent directory of the mozilla tree." - echo "" - echo "This command will output two numbers to stdout that will represent" - echo " the total size of all code and data, and a delta from the prior." - echo " the old results." - echo "For much more detail on size drifts refer to the summary report." - echo "" - echo "This tool reports on executables listed in the following file:" - echo "$MANIFEST" - exit -fi - - -# -# Stash our arguments away. -# -COPYSORTTSV="$1" -OLDTSVFILE="$2" -SUMMARYFILE="$3" - - -# -# On Mac OS X, use the --zerodrift option to maptsvdifftool -# -if [ $OSTYPE == "Darwin" ]; then -ZERODRIFT="--zerodrift" -else -ZERODRIFT="" -fi - - -# -# Create our temporary directory. -# mktemp on Darwin doesn't support -d (suckage) -# -if [ $OSTYPE == "Darwin" ]; then -MYTMPDIR=`mktemp ./codesighs.tmp.XXXXXXXX` -rm $MYTMPDIR -mkdir $MYTMPDIR -else -MYTMPDIR=`mktemp -d ./codesighs.tmp.XXXXXXXX` -fi - - -# Check whether we have 'eu-readelf' or 'readelf' available. -# If we do, it will give more accurate symbol sizes than nm. - -if [ $OSTYPE == "Darwin" ]; then - USE_READELF= -else -READELF_PROG=`which eu-readelf 2>/dev/null | grep /eu-readelf$` -if test "$READELF_PROG"; then - USE_READELF=1 -else - READELF_PROG=`which readelf 2>/dev/null | grep /readelf$` - if test "$READELF_PROG"; then - # Check whether we need -W - if readelf --help | grep "\--wide" >&/dev/null; then - READELF_PROG="readelf -W" - else - READELF_PROG="readelf" - fi - USE_READELF=1 - else - USE_READELF= - fi -fi -fi - -# -# Find all relevant files. -# -ALLFILES="$MYTMPDIR/allfiles.list" -grep -v '[\;\[]' < $MANIFEST | grep -v '^$' | sed "s|^|${OBJROOT}/dist/bin/|" > $ALLFILES - - -RAWTSVFILE="$MYTMPDIR/raw.tsv" - -if test "$USE_READELF"; then -export READELF_PROG -xargs -n 1 $SRCROOT/tools/codesighs/readelf_wrap.pl < $ALLFILES > $RAWTSVFILE -else - -# -# Produce the cumulative nm output. -# We are very particular on what switches to use. -# nm --format=bsd --size-sort --print-file-name --demangle -# -# Darwin (Mac OS X) has a lame nm that we have to wrap in a perl -# script to get decent output. -# -NMRESULTS="$MYTMPDIR/nm.txt" -if [ $OSTYPE == "Darwin" ]; then -xargs -n 1 $SRCROOT/tools/codesighs/nm_wrap_osx.pl < $ALLFILES > $NMRESULTS 2> /dev/null -else -xargs -n 1 nm --format=bsd --size-sort --print-file-name --demangle < $ALLFILES > $NMRESULTS 2> /dev/null -fi - -# -# Produce the TSV output. -# -$OBJROOT/dist/bin/nm2tsv --input $NMRESULTS > $RAWTSVFILE - -fi # USE_READELF - -# -# Sort the TSV output for useful diffing and eyeballing in general. -# -sort -r $RAWTSVFILE > $COPYSORTTSV - - -# -# If a historical file was specified, diff it with our sorted tsv values. -# Run it through a tool to summaries the diffs to the module -# level report. -# Otherwise, generate the module level report from our new data. -# -rm -f $SUMMARYFILE -DIFFFILE="$MYTMPDIR/diff.txt" -if [ -e $OLDTSVFILE ]; then - diff $OLDTSVFILE $COPYSORTTSV > $DIFFFILE - $OBJROOT/dist/bin/maptsvdifftool $ZERODRIFT --input $DIFFFILE >> $SUMMARYFILE -else - $OBJROOT/dist/bin/codesighs --modules --input $COPYSORTTSV >> $SUMMARYFILE -fi - - -# -# Output our numbers, that will let tinderbox specify everything all -# at once. -# First number is in fact the total size of all code and data in the map -# files parsed. -# Second number, if present, is growth/shrinkage. -# - -if [ $TINDERBOX_OUTPUT ]; then - echo -n "__codesize:" -fi -$OBJROOT/dist/bin/codesighs --totalonly --input $COPYSORTTSV - -if [ -e $DIFFFILE ]; then -if [ $TINDERBOX_OUTPUT ]; then - echo -n "__codesizeDiff:" -fi - $OBJROOT/dist/bin/maptsvdifftool $ZERODRIFT --summary --input $DIFFFILE -fi - -# -# Remove our temporary directory. -# -rm -rf $MYTMPDIR
diff --git a/third_party/codesighs/basesummary.win.bash b/third_party/codesighs/basesummary.win.bash deleted file mode 100755 index 1e058590..0000000 --- a/third_party/codesighs/basesummary.win.bash +++ /dev/null
@@ -1,224 +0,0 @@ -#!/bin/bash -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is basesummary.win.bash code, released -# Nov 15, 2002. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 2002 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Garrett Arch Blythe, 15-November-2002 -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - - -# -# Check for optional objdir -# -if [ "$1" = "-o" ]; then -OBJROOT="$2" -shift -shift -else -OBJROOT="./mozilla" -fi - -if [ "$1" = "-s" ]; then -SRCROOT="$2" -shift -shift -else -SRCROOT="./mozilla" -fi - -MANIFEST="$SRCROOT/embedding/config/basebrowser-win" - -# -# A little help for my friends. -# -if [ "-h" == "$1" ];then - SHOWHELP="1" -fi -if [ "--help" == "$1" ];then - SHOWHELP="1" -fi -if [ "" == "$1" ]; then - SHOWHELP="1" -fi -if [ "" == "$2" ]; then - SHOWHELP="1" -fi -if [ "" == "$3" ]; then - SHOWHELP="1" -fi - - -# -# Show the help if required. -# -if [ $SHOWHELP ]; then - echo "usage: $0 <save_results> <old_results> <summary>" - echo " <save_results> is a file that will receive the results of this run." - echo " This file can be used in a future run as the old results." - echo " <old_results> is a results file from a previous run." - echo " It is used to diff with current results and come up with a summary" - echo " of changes." - echo " It is OK if the file does not exist, just supply the argument." - echo " <summary> is a file which will contain a human readable report." - echo " This file is most useful by providing more information than the" - echo " normally single digit output of this script." - echo "" - echo "Run this command from the parent directory of the mozilla tree." - echo "" - echo "This command will output two numbers to stdout that will represent" - echo " the total size of all code and data, and a delta from the prior." - echo " the old results." - echo "For much more detail on size drifts refer to the summary report." - echo "" - echo "This tool reports on executables listed in the following file:" - echo "$MANIFEST" - exit -fi - - -# -# Stash our arguments away. -# -COPYSORTTSV="$1" -OLDTSVFILE="$2" -SUMMARYFILE="$3" - - -# -# Create our temporary directory. -# -MYTMPDIR=`mktemp -d ./codesighs.tmp.XXXXXXXX` - - -# -# Find the types of files we are interested in. -# -ONEFINDPASS="$MYTMPDIR/onefind.list" -/usr/bin/find $OBJROOT -type f -name "*.obj" -or -name "*.map" | while read FNAME; do - cygpath -m $FNAME >> $ONEFINDPASS -done - - -# -# Find all object files. -# -ALLOBJSFILE="$MYTMPDIR/allobjs.list" -grep -i "\.obj$" < $ONEFINDPASS > $ALLOBJSFILE - - -# -# Get a dump of the symbols in every object file. -# -ALLOBJSYMSFILE="$MYTMPDIR/allobjsyms.list" -xargs -n 1 dumpbin.exe /symbols < $ALLOBJSFILE > $ALLOBJSYMSFILE 2> /dev/null - - -# -# Produce the symdb for the symbols in all object files. -# -SYMDBFILE="$MYTMPDIR/symdb.tsv" -$OBJROOT/dist/bin/msdump2symdb --input $ALLOBJSYMSFILE | /usr/bin/sort > $SYMDBFILE 2> /dev/null - - -# -# Find all map files. -# -ALLMAPSFILE="$MYTMPDIR/allmaps.list" -grep -i "\.map$" < $ONEFINDPASS > $ALLMAPSFILE - - -# -# Figure out which modules in specific we care about. -# The relevant set meaning that the map file name prefix must be found -# in the file mozilla/embedding/config/basebrowser-win. -# -RELEVANTSETFILE="$MYTMPDIR/relevant.set" -grep -v '\;' < $MANIFEST | sed 's/.*\\//' | grep '\.[eEdD][xXlL][eElL]' | sed 's/\.[eEdD][xXlL][eElL]//' > $RELEVANTSETFILE -RELEVANTARG=`xargs -n 1 echo --match-module < $RELEVANTSETFILE` - - -# -# Produce the TSV output. -# -RAWTSVFILE="$MYTMPDIR/raw.tsv" -$OBJROOT/dist/bin/msmap2tsv --symdb $SYMDBFILE --batch $RELEVANTARG < $ALLMAPSFILE > $RAWTSVFILE 2> /dev/null - - -# -# Sort the TSV output for useful diffing and eyeballing in general. -# -/usr/bin/sort -r $RAWTSVFILE > $COPYSORTTSV - - -# -# If a historical file was specified, diff it with our sorted tsv values. -# Run it through a tool to summaries the diffs to the module -# level report. -# Otherwise, generate the module level report from our new data. -# -rm -f $SUMMARYFILE -DIFFFILE="$MYTMPDIR/diff.txt" -if [ -e $OLDTSVFILE ]; then - diff $OLDTSVFILE $COPYSORTTSV > $DIFFFILE - $OBJROOT/dist/bin/maptsvdifftool --negation --input $DIFFFILE | dos2unix >> $SUMMARYFILE -else - $OBJROOT/dist/bin/codesighs --modules --input $COPYSORTTSV | dos2unix >> $SUMMARYFILE -fi - - -# -# Output our numbers, that will let tinderbox specify everything all -# at once. -# First number is in fact the total size of all code and data in the map -# files parsed. -# Second number, if present, is growth/shrinkage. -# - -if [ $TINDERBOX_OUTPUT ]; then - echo -n "__codesize:" -fi -$OBJROOT/dist/bin/codesighs --totalonly --input $COPYSORTTSV | dos2unix - -if [ -e $DIFFFILE ]; then -if [ $TINDERBOX_OUTPUT ]; then - echo -n "__codesizeDiff:" -fi - $OBJROOT/dist/bin/maptsvdifftool --negation --summary --input $DIFFFILE | dos2unix -fi - -# -# Remove our temporary directory. -# -rm -rf $MYTMPDIR
diff --git a/third_party/codesighs/codesighs.c b/third_party/codesighs/codesighs.c deleted file mode 100644 index f20fbb1..0000000 --- a/third_party/codesighs/codesighs.c +++ /dev/null
@@ -1,1075 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is codesighs.c code, released - * Oct 3, 2002. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Garrett Arch Blythe, 03-October-2002 - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <ctype.h> -#include <errno.h> - -#define ERROR_REPORT(num, val, msg) fprintf(stderr, "error(%d):\t\"%s\"\t%s\n", (num), (val), (msg)); -#define CLEANUP(ptr) do { if(NULL != ptr) { free(ptr); ptr = NULL; } } while(0) - - -typedef struct __struct_Options -/* -** Options to control how we perform. -** -** mProgramName Used in help text. -** mInput File to read for input. -** Default is stdin. -** mInputName Name of the file. -** mOutput Output file, append. -** Default is stdout. -** mOutputName Name of the file. -** mHelp Whether or not help should be shown. -** mModules Output module by module information. -** mTotalOnly Only output one number, the total. -** mMinSize Ignore lines below this size. -** mMaxSize Ignore lines above this size. -** mMatchScopes For a line to be processed, it should match. -** mMachClasses For a line to be processed, it should match. -** mMatchModules For a line to be processed, it should match. -** mMatchSections For a line to be processed, it should match. -** mMatchObjects For a line to be processed, it should match. -** mMatchSymbols For a line to be processed, it should match. -*/ -{ - const char* mProgramName; - FILE* mInput; - char* mInputName; - FILE* mOutput; - char* mOutputName; - int mHelp; - int mModules; - int mTotalOnly; - unsigned long mMinSize; - unsigned long mMaxSize; - char** mMatchScopes; - unsigned mMatchScopeCount; - char** mMatchClasses; - unsigned mMatchClassCount; - char** mMatchModules; - unsigned mMatchModuleCount; - char** mMatchSections; - unsigned mMatchSectionCount; - char** mMatchObjects; - unsigned mMatchObjectCount; - char** mMatchSymbols; - unsigned mMatchSymbolCount; -} -Options; - - -typedef struct __struct_Switch -/* -** Command line options. -*/ -{ - const char* mLongName; - const char* mShortName; - int mHasValue; - const char* mValue; - const char* mDescription; -} -Switch; - -#define DESC_NEWLINE "\n\t\t" - -static Switch gInputSwitch = {"--input", "-i", 1, NULL, "Specify input file." DESC_NEWLINE "stdin is default."}; -static Switch gOutputSwitch = {"--output", "-o", 1, NULL, "Specify output file." DESC_NEWLINE "Appends if file exists." DESC_NEWLINE "stdout is default."}; -static Switch gHelpSwitch = {"--help", "-h", 0, NULL, "Information on usage."}; -static Switch gModuleSwitch = {"--modules", "-m", 0, NULL, "Output individual module numbers as well."}; -static Switch gTotalSwitch = {"--totalonly", "-t", 0, NULL, "Output only one number." DESC_NEWLINE "The total overall size." DESC_NEWLINE "Overrides other output options."}; -static Switch gMinSize = {"--min-size", "-min", 1, NULL, "Only consider symbols equal to or greater than this size." DESC_NEWLINE "The default is 0x00000000."}; -static Switch gMaxSize = {"--max-size", "-max", 1, NULL, "Only consider symbols equal to or smaller than this size." DESC_NEWLINE "The default is 0xFFFFFFFF."}; -static Switch gMatchScope = {"--match-scope", "-msco", 1, NULL, "Only consider scopes that have a substring match." DESC_NEWLINE "Multiple uses allowed to specify a range of scopes," DESC_NEWLINE "though PUBLIC, STATIC, and UNDEF are your only choices."}; -static Switch gMatchClass = {"--match-class", "-mcla", 1, NULL, "Only consider classes that have a substring match." DESC_NEWLINE "Multiple uses allowed to specify a range of classes," DESC_NEWLINE "though CODE and DATA are your only choices."}; -static Switch gMatchModule = {"--match-module", "-mmod", 1, NULL, "Only consider modules that have a substring match." DESC_NEWLINE "Multiple uses allowed to specify an array of modules."}; -static Switch gMatchSection = {"--match-section", "-msec", 1, NULL, "Only consider sections that have a substring match." DESC_NEWLINE "Multiple uses allowed to specify an array of sections." DESC_NEWLINE "Section is considered symbol type."}; -static Switch gMatchObject = {"--match-object", "-mobj", 1, NULL, "Only consider objects that have a substring match." DESC_NEWLINE "Multiple uses allowed to specify an array of objects."}; -static Switch gMatchSymbol = {"--match-symbol", "-msym", 1, NULL, "Only consider symbols that have a substring match." DESC_NEWLINE "Multiple uses allowed to specify an array of symbols."}; - -static Switch* gSwitches[] = { - &gInputSwitch, - &gOutputSwitch, - &gModuleSwitch, - &gTotalSwitch, - &gMinSize, - &gMaxSize, - &gMatchClass, - &gMatchScope, - &gMatchModule, - &gMatchSection, - &gMatchObject, - &gMatchSymbol, - &gHelpSwitch -}; - - -typedef struct __struct_SizeStats -/* -** Track totals. -** -** mData Size of data. -** mCode Size of code. -*/ -{ - unsigned long mData; - unsigned long mCode; -} -SizeStats; - - -typedef struct __struct_ModuleStats -/* -** Track module level information. -** -** mModule Module name. -** mSize Size of module. -*/ -{ - char* mModule; - SizeStats mSize; -} -ModuleStats; - -typedef enum __enum_SegmentClass -{ - CODE, - DATA -} -SegmentClass; - - -static int moduleCompare(const void* in1, const void* in2) -/* -** qsort helper function. -*/ -{ - int retval = 0; - - const ModuleStats* one = (const ModuleStats*)in1; - const ModuleStats* two = (const ModuleStats*)in2; - unsigned long oneSize = one->mSize.mCode + one->mSize.mData; - unsigned long twoSize = two->mSize.mCode + two->mSize.mData; - - if(oneSize < twoSize) - { - retval = 1; - } - else if(oneSize > twoSize) - { - retval = -1; - } - - return retval; -} - - -void trimWhite(char* inString) -/* -** Remove any whitespace from the end of the string. -*/ -{ - int len = strlen(inString); - - while(len) - { - len--; - - if(isspace(*(inString + len))) - { - *(inString + len) = '\0'; - } - else - { - break; - } - } -} - - -int codesighs(Options* inOptions) -/* -** Output a simplistic report based on our options. -*/ -{ - int retval = 0; - char lineBuffer[0x1000]; - int scanRes = 0; - unsigned long size; - char segClass[0x10]; - char scope[0x10]; - char module[0x100]; - char segment[0x40]; - char object[0x100]; - char* symbol; - SizeStats overall; - ModuleStats* modules = NULL; - unsigned moduleCount = 0; - - memset(&overall, 0, sizeof(overall)); - - /* - ** Read the file line by line, regardless of number of fields. - ** We assume tab separated value formatting, at least 7 lead values: - ** size class scope module segment object symbol .... - */ - while(0 == retval && NULL != fgets(lineBuffer, sizeof(lineBuffer), inOptions->mInput)) - { - trimWhite(lineBuffer); - - scanRes = sscanf(lineBuffer, - "%x\t%s\t%s\t%s\t%s\t%s\t", - (unsigned*)&size, - segClass, - scope, - module, - segment, - object); - - if(6 == scanRes) - { - SegmentClass segmentClass = CODE; - - symbol = strchr(lineBuffer, '\t') + 1; - - /* - ** Qualify the segment class. - */ - if(0 == strcmp(segClass, "DATA")) - { - segmentClass = DATA; - } - else if(0 == strcmp(segClass, "CODE")) - { - segmentClass = CODE; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, segClass, "Unable to determine segment class."); - } - - if(0 == retval) - { - /* - ** Match any options required before continuing. - ** This is where you would want to add more restrictive totalling. - */ - - /* - ** Match size. - */ - if(size < inOptions->mMinSize) - { - continue; - } - if(size > inOptions->mMaxSize) - { - continue; - } - - /* - ** Match class. - */ - if(0 != inOptions->mMatchClassCount) - { - unsigned loop = 0; - - for(loop = 0; loop < inOptions->mMatchClassCount; loop++) - { - if(NULL != strstr(segClass, inOptions->mMatchClasses[loop])) - { - break; - } - } - - /* - ** If there was no match, we skip the line. - */ - if(loop == inOptions->mMatchClassCount) - { - continue; - } - } - - /* - ** Match scope. - */ - if(0 != inOptions->mMatchScopeCount) - { - unsigned loop = 0; - - for(loop = 0; loop < inOptions->mMatchScopeCount; loop++) - { - if(NULL != strstr(scope, inOptions->mMatchScopes[loop])) - { - break; - } - } - - /* - ** If there was no match, we skip the line. - */ - if(loop == inOptions->mMatchScopeCount) - { - continue; - } - } - - /* - ** Match modules. - */ - if(0 != inOptions->mMatchModuleCount) - { - unsigned loop = 0; - - for(loop = 0; loop < inOptions->mMatchModuleCount; loop++) - { - if(NULL != strstr(module, inOptions->mMatchModules[loop])) - { - break; - } - } - - /* - ** If there was no match, we skip the line. - */ - if(loop == inOptions->mMatchModuleCount) - { - continue; - } - } - - /* - ** Match sections. - */ - if(0 != inOptions->mMatchSectionCount) - { - unsigned loop = 0; - - for(loop = 0; loop < inOptions->mMatchSectionCount; loop++) - { - if(NULL != strstr(segment, inOptions->mMatchSections[loop])) - { - break; - } - } - - /* - ** If there was no match, we skip the line. - */ - if(loop == inOptions->mMatchSectionCount) - { - continue; - } - } - - /* - ** Match object. - */ - if(0 != inOptions->mMatchObjectCount) - { - unsigned loop = 0; - - for(loop = 0; loop < inOptions->mMatchObjectCount; loop++) - { - if(NULL != strstr(object, inOptions->mMatchObjects[loop])) - { - break; - } - } - - /* - ** If there was no match, we skip the line. - */ - if(loop == inOptions->mMatchObjectCount) - { - continue; - } - } - - /* - ** Match symbols. - */ - if(0 != inOptions->mMatchSymbolCount) - { - unsigned loop = 0; - - for(loop = 0; loop < inOptions->mMatchSymbolCount; loop++) - { - if(NULL != strstr(symbol, inOptions->mMatchSymbols[loop])) - { - break; - } - } - - /* - ** If there was no match, we skip the line. - */ - if(loop == inOptions->mMatchSymbolCount) - { - continue; - } - } - - /* - ** Update overall totals. - */ - if(CODE == segmentClass) - { - overall.mCode += size; - } - else if(DATA == segmentClass) - { - overall.mData += size; - } - - /* - ** See what else we should be tracking. - */ - if(0 == inOptions->mTotalOnly) - { - if(inOptions->mModules) - { - unsigned index = 0; - - /* - ** Find the module to modify. - */ - for(index = 0; index < moduleCount; index++) - { - if(0 == strcmp(modules[index].mModule, module)) - { - break; - } - } - - /* - ** If the index is the same as the count, we need to - ** add a new module. - */ - if(index == moduleCount) - { - void* moved = NULL; - - moved = realloc(modules, sizeof(ModuleStats) * (moduleCount + 1)); - if(NULL != moved) - { - modules = (ModuleStats*)moved; - moduleCount++; - - memset(modules + index, 0, sizeof(ModuleStats)); - modules[index].mModule = strdup(module); - if(NULL == modules[index].mModule) - { - retval = __LINE__; - ERROR_REPORT(retval, module, "Unable to duplicate string."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inOptions->mProgramName, "Unable to allocate module memory."); - } - } - - if(0 == retval) - { - if(CODE == segmentClass) - { - modules[index].mSize.mCode += size; - } - else if(DATA == segmentClass) - { - modules[index].mSize.mData += size; - } - } - } - } - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inOptions->mInputName, "Problem extracting values from file."); - } - } - - if(0 == retval && 0 != ferror(inOptions->mInput)) - { - retval = __LINE__; - ERROR_REPORT(retval, inOptions->mInputName, "Unable to read file."); - } - - /* - ** If all went well, time to report. - */ - if(0 == retval) - { - if(inOptions->mTotalOnly) - { - fprintf(inOptions->mOutput, "%u\n", (unsigned)(overall.mCode + overall.mData)); - } - else - { - fprintf(inOptions->mOutput, "Overall Size\n"); - fprintf(inOptions->mOutput, "\tTotal:\t%10u\n", (unsigned)(overall.mCode + overall.mData)); - fprintf(inOptions->mOutput, "\tCode:\t%10u\n", (unsigned)overall.mCode); - fprintf(inOptions->mOutput, "\tData:\t%10u\n", (unsigned)overall.mData); - } - - /* - ** Check options to see what else we should output. - */ - if(inOptions->mModules && moduleCount) - { - unsigned loop = 0; - - /* - ** Sort the modules by their size. - */ - qsort(modules, (size_t)moduleCount, sizeof(ModuleStats), moduleCompare); - - /* - ** Output each one. - ** Might as well clean up while we go too. - */ - for(loop = 0; loop < moduleCount; loop++) - { - fprintf(inOptions->mOutput, "\n"); - fprintf(inOptions->mOutput, "%s\n", modules[loop].mModule); - fprintf(inOptions->mOutput, "\tTotal:\t%10u\n", (unsigned)(modules[loop].mSize.mCode + modules[loop].mSize.mData)); - fprintf(inOptions->mOutput, "\tCode:\t%10u\n", (unsigned)modules[loop].mSize.mCode); - fprintf(inOptions->mOutput, "\tData:\t%10u\n", (unsigned)modules[loop].mSize.mData); - - CLEANUP(modules[loop].mModule); - } - - /* - ** Done with modules. - */ - CLEANUP(modules); - moduleCount = 0; - } - } - - return retval; -} - - -int initOptions(Options* outOptions, int inArgc, char** inArgv) -/* -** returns int 0 if successful. -*/ -{ - int retval = 0; - int loop = 0; - int switchLoop = 0; - int match = 0; - const int switchCount = sizeof(gSwitches) / sizeof(gSwitches[0]); - Switch* current = NULL; - - /* - ** Set any defaults. - */ - memset(outOptions, 0, sizeof(Options)); - outOptions->mProgramName = inArgv[0]; - outOptions->mInput = stdin; - outOptions->mInputName = strdup("stdin"); - outOptions->mOutput = stdout; - outOptions->mOutputName = strdup("stdout"); - outOptions->mMaxSize = 0xFFFFFFFFU; - - if(NULL == outOptions->mOutputName || NULL == outOptions->mInputName) - { - retval = __LINE__; - ERROR_REPORT(retval, "stdin/stdout", "Unable to strdup."); - } - - /* - ** Go through and attempt to do the right thing. - */ - for(loop = 1; loop < inArgc && 0 == retval; loop++) - { - match = 0; - current = NULL; - - for(switchLoop = 0; switchLoop < switchCount && 0 == retval; switchLoop++) - { - if(0 == strcmp(gSwitches[switchLoop]->mLongName, inArgv[loop])) - { - match = __LINE__; - } - else if(0 == strcmp(gSwitches[switchLoop]->mShortName, inArgv[loop])) - { - match = __LINE__; - } - - if(match) - { - if(gSwitches[switchLoop]->mHasValue) - { - /* - ** Attempt to absorb next option to fullfill value. - */ - if(loop + 1 < inArgc) - { - loop++; - - current = gSwitches[switchLoop]; - current->mValue = inArgv[loop]; - } - } - else - { - current = gSwitches[switchLoop]; - } - - break; - } - } - - if(0 == match) - { - outOptions->mHelp = __LINE__; - retval = __LINE__; - ERROR_REPORT(retval, inArgv[loop], "Unknown command line switch."); - } - else if(NULL == current) - { - outOptions->mHelp = __LINE__; - retval = __LINE__; - ERROR_REPORT(retval, inArgv[loop], "Command line switch requires a value."); - } - else - { - /* - ** Do something based on address/swtich. - */ - if(current == &gInputSwitch) - { - CLEANUP(outOptions->mInputName); - if(NULL != outOptions->mInput && stdin != outOptions->mInput) - { - fclose(outOptions->mInput); - outOptions->mInput = NULL; - } - - outOptions->mInput = fopen(current->mValue, "r"); - if(NULL == outOptions->mInput) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to open input file."); - } - else - { - outOptions->mInputName = strdup(current->mValue); - if(NULL == outOptions->mInputName) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to strdup."); - } - } - } - else if(current == &gOutputSwitch) - { - CLEANUP(outOptions->mOutputName); - if(NULL != outOptions->mOutput && stdout != outOptions->mOutput) - { - fclose(outOptions->mOutput); - outOptions->mOutput = NULL; - } - - outOptions->mOutput = fopen(current->mValue, "a"); - if(NULL == outOptions->mOutput) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to open output file."); - } - else - { - outOptions->mOutputName = strdup(current->mValue); - if(NULL == outOptions->mOutputName) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to strdup."); - } - } - } - else if(current == &gHelpSwitch) - { - outOptions->mHelp = __LINE__; - } - else if(current == &gModuleSwitch) - { - outOptions->mModules = __LINE__; - } - else if(current == &gTotalSwitch) - { - outOptions->mTotalOnly = __LINE__; - } - else if(current == &gMinSize) - { - unsigned long arg = 0; - char* endScan = NULL; - - errno = 0; - arg = strtoul(current->mValue, &endScan, 0); - if(0 == errno && endScan != current->mValue) - { - outOptions->mMinSize = arg; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to convert to a number."); - } - } - else if(current == &gMaxSize) - { - unsigned long arg = 0; - char* endScan = NULL; - - errno = 0; - arg = strtoul(current->mValue, &endScan, 0); - if(0 == errno && endScan != current->mValue) - { - outOptions->mMaxSize = arg; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to convert to a number."); - } - } - else if(current == &gMatchClass) - { - char* dupMatch = NULL; - - dupMatch = strdup(current->mValue); - if(NULL != dupMatch) - { - void* moved = NULL; - - moved = realloc(outOptions->mMatchClasses, sizeof(char*) * (outOptions->mMatchClassCount + 1)); - if(NULL != moved) - { - outOptions->mMatchClasses = (char**)moved; - outOptions->mMatchClasses[outOptions->mMatchClassCount] = dupMatch; - outOptions->mMatchClassCount++; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mLongName, "Unable to expand array."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to duplicate string."); - } - } - else if(current == &gMatchScope) - { - char* dupMatch = NULL; - - dupMatch = strdup(current->mValue); - if(NULL != dupMatch) - { - void* moved = NULL; - - moved = realloc(outOptions->mMatchScopes, sizeof(char*) * (outOptions->mMatchScopeCount + 1)); - if(NULL != moved) - { - outOptions->mMatchScopes = (char**)moved; - outOptions->mMatchScopes[outOptions->mMatchScopeCount] = dupMatch; - outOptions->mMatchScopeCount++; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mLongName, "Unable to expand array."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to duplicate string."); - } - } - else if(current == &gMatchModule) - { - char* dupMatch = NULL; - - dupMatch = strdup(current->mValue); - if(NULL != dupMatch) - { - void* moved = NULL; - - moved = realloc(outOptions->mMatchModules, sizeof(char*) * (outOptions->mMatchModuleCount + 1)); - if(NULL != moved) - { - outOptions->mMatchModules = (char**)moved; - outOptions->mMatchModules[outOptions->mMatchModuleCount] = dupMatch; - outOptions->mMatchModuleCount++; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mLongName, "Unable to expand array."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to duplicate string."); - } - } - else if(current == &gMatchSection) - { - char* dupMatch = NULL; - - dupMatch = strdup(current->mValue); - if(NULL != dupMatch) - { - void* moved = NULL; - - moved = realloc(outOptions->mMatchSections, sizeof(char*) * (outOptions->mMatchSectionCount + 1)); - if(NULL != moved) - { - outOptions->mMatchSections = (char**)moved; - outOptions->mMatchSections[outOptions->mMatchSectionCount] = dupMatch; - outOptions->mMatchSectionCount++; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mLongName, "Unable to expand array."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to duplicate string."); - } - } - else if(current == &gMatchObject) - { - char* dupMatch = NULL; - - dupMatch = strdup(current->mValue); - if(NULL != dupMatch) - { - void* moved = NULL; - - moved = realloc(outOptions->mMatchObjects, sizeof(char*) * (outOptions->mMatchObjectCount + 1)); - if(NULL != moved) - { - outOptions->mMatchObjects = (char**)moved; - outOptions->mMatchObjects[outOptions->mMatchObjectCount] = dupMatch; - outOptions->mMatchObjectCount++; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mLongName, "Unable to expand array."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to duplicate string."); - } - } - else if(current == &gMatchSymbol) - { - char* dupMatch = NULL; - - dupMatch = strdup(current->mValue); - if(NULL != dupMatch) - { - void* moved = NULL; - - moved = realloc(outOptions->mMatchSymbols, sizeof(char*) * (outOptions->mMatchSymbolCount + 1)); - if(NULL != moved) - { - outOptions->mMatchSymbols = (char**)moved; - outOptions->mMatchSymbols[outOptions->mMatchSymbolCount] = dupMatch; - outOptions->mMatchSymbolCount++; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mLongName, "Unable to expand array."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to duplicate string."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mLongName, "No handler for command line switch."); - } - } - } - - return retval; -} - - -void cleanOptions(Options* inOptions) -/* -** Clean up any open handles. -*/ -{ - unsigned loop = 0; - - CLEANUP(inOptions->mInputName); - if(NULL != inOptions->mInput && stdin != inOptions->mInput) - { - fclose(inOptions->mInput); - } - CLEANUP(inOptions->mOutputName); - if(NULL != inOptions->mOutput && stdout != inOptions->mOutput) - { - fclose(inOptions->mOutput); - } - - for(loop = 0; loop < inOptions->mMatchClassCount; loop++) - { - CLEANUP(inOptions->mMatchClasses[loop]); - } - CLEANUP(inOptions->mMatchClasses); - - for(loop = 0; loop < inOptions->mMatchScopeCount; loop++) - { - CLEANUP(inOptions->mMatchScopes[loop]); - } - CLEANUP(inOptions->mMatchScopes); - - for(loop = 0; loop < inOptions->mMatchModuleCount; loop++) - { - CLEANUP(inOptions->mMatchModules[loop]); - } - CLEANUP(inOptions->mMatchModules); - - for(loop = 0; loop < inOptions->mMatchSectionCount; loop++) - { - CLEANUP(inOptions->mMatchSections[loop]); - } - CLEANUP(inOptions->mMatchSections); - - for(loop = 0; loop < inOptions->mMatchObjectCount; loop++) - { - CLEANUP(inOptions->mMatchObjects[loop]); - } - CLEANUP(inOptions->mMatchObjects); - - for(loop = 0; loop < inOptions->mMatchSymbolCount; loop++) - { - CLEANUP(inOptions->mMatchSymbols[loop]); - } - CLEANUP(inOptions->mMatchSymbols); - - memset(inOptions, 0, sizeof(Options)); -} - - -void showHelp(Options* inOptions) -/* -** Show some simple help text on usage. -*/ -{ - int loop = 0; - const int switchCount = sizeof(gSwitches) / sizeof(gSwitches[0]); - const char* valueText = NULL; - - printf("usage:\t%s [arguments]\n", inOptions->mProgramName); - printf("\n"); - printf("arguments:\n"); - - for(loop = 0; loop < switchCount; loop++) - { - if(gSwitches[loop]->mHasValue) - { - valueText = " <value>"; - } - else - { - valueText = ""; - } - - printf("\t%s%s\n", gSwitches[loop]->mLongName, valueText); - printf("\t %s%s", gSwitches[loop]->mShortName, valueText); - printf(DESC_NEWLINE "%s\n\n", gSwitches[loop]->mDescription); - } - - printf("This tool takes a tsv file and reports composite code and data sizes.\n"); -} - - -int main(int inArgc, char** inArgv) -{ - int retval = 0; - Options options; - - retval = initOptions(&options, inArgc, inArgv); - if(options.mHelp) - { - showHelp(&options); - } - else if(0 == retval) - { - retval = codesighs(&options); - } - - cleanOptions(&options); - return retval; -} -
diff --git a/third_party/codesighs/maptsvdifftool.c b/third_party/codesighs/maptsvdifftool.c deleted file mode 100644 index 8207060..0000000 --- a/third_party/codesighs/maptsvdifftool.c +++ /dev/null
@@ -1,1311 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is maptsvdifftool.c code, released - * Oct 3, 2002. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Garrett Arch Blythe, 03-October-2002 - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <ctype.h> - -#define ERROR_REPORT(num, val, msg) fprintf(stderr, "error(%d):\t\"%s\"\t%s\n", (num), (val), (msg)); -#define CLEANUP(ptr) do { if(NULL != ptr) { free(ptr); ptr = NULL; } } while(0) - - -typedef struct __struct_Options -/* -** Options to control how we perform. -** -** mProgramName Used in help text. -** mInput File to read for input. -** Default is stdin. -** mInputName Name of the file. -** mOutput Output file, append. -** Default is stdout. -** mOutputName Name of the file. -** mHelp Whether or not help should be shown. -** mSummaryOnly Only output a signle line. -** mZeroDrift Output zero drift data. -** mNegation Perform negation heuristics on the symbol drifts. -*/ -{ - const char* mProgramName; - FILE* mInput; - char* mInputName; - FILE* mOutput; - char* mOutputName; - int mHelp; - int mSummaryOnly; - int mZeroDrift; - int mNegation; -} -Options; - - -typedef struct __struct_Switch -/* -** Command line options. -*/ -{ - const char* mLongName; - const char* mShortName; - int mHasValue; - const char* mValue; - const char* mDescription; -} -Switch; - -#define DESC_NEWLINE "\n\t\t" - -static Switch gInputSwitch = {"--input", "-i", 1, NULL, "Specify input file." DESC_NEWLINE "stdin is default."}; -static Switch gOutputSwitch = {"--output", "-o", 1, NULL, "Specify output file." DESC_NEWLINE "Appends if file exists." DESC_NEWLINE "stdout is default."}; -static Switch gSummarySwitch = {"--summary", "-s", 0, NULL, "Only output a single line." DESC_NEWLINE "The cumulative size changes." DESC_NEWLINE "Overrides all other output options."}; -static Switch gZeroDriftSwitch = {"--zerodrift", "-z", 0, NULL, "Output zero drift data." DESC_NEWLINE "Reports symbol changes even when there is no net drift."}; -static Switch gNegationSwitch = {"--negation", "-n", 0, NULL, "Use negation heuristics." DESC_NEWLINE "When symbol sizes are inferred by offset, order changes cause noise." DESC_NEWLINE "This helps see through the noise by eliminating equal and opposite drifts."}; -static Switch gHelpSwitch = {"--help", "-h", 0, NULL, "Information on usage."}; - -static Switch* gSwitches[] = { - &gInputSwitch, - &gOutputSwitch, - &gSummarySwitch, - &gZeroDriftSwitch, - &gNegationSwitch, - &gHelpSwitch -}; - - -typedef struct __struct_SizeComposition -/* -** Used to keep which parts positive and negative resulted in the total. -*/ -{ - int mPositive; - int mNegative; -} -SizeComposition; - - -typedef struct __struct_SizeStats -/* -** Keep track of sizes. -** Use signed integers so that negatives are valid, in which case we shrunk. -*/ -{ - int mCode; - SizeComposition mCodeComposition; - - int mData; - SizeComposition mDataComposition; -} -SizeStats; - - -typedef enum __enum_SegmentClass -/* -** What type of data a segment holds. -*/ -{ - CODE, - DATA -} -SegmentClass; - - -typedef struct __struct_SymbolStats -/* -** Symbol level stats. -*/ -{ - char* mSymbol; - int mSize; -} -SymbolStats; - - -typedef struct __struct_ObjectStats -/* -** Object level stats. -*/ -{ - char* mObject; - int mSize; - SizeComposition mComposition; - SymbolStats* mSymbols; - unsigned mSymbolCount; -} -ObjectStats; - - -typedef struct __struct_SegmentStats -/* -** Segment level stats. -*/ -{ - char* mSegment; - SegmentClass mClass; - int mSize; - SizeComposition mComposition; - ObjectStats* mObjects; - unsigned mObjectCount; -} -SegmentStats; - - -typedef struct __struct_ModuleStats -/* -** Module level stats. -*/ -{ - char* mModule; - SizeStats mSize; - SegmentStats* mSegments; - unsigned mSegmentCount; -} -ModuleStats; - - -static int moduleCompare(const void* in1, const void* in2) -/* -** qsort helper. -*/ -{ - int retval = 0; - - ModuleStats* one = (ModuleStats*)in1; - ModuleStats* two = (ModuleStats*)in2; - - int oneSize = (one->mSize.mCode + one->mSize.mData); - int twoSize = (two->mSize.mCode + two->mSize.mData); - - if(oneSize < twoSize) - { - retval = 1; - } - else if(oneSize > twoSize) - { - retval = -1; - } - else - { - retval = strcmp(one->mModule, two->mModule); - if(0 > oneSize && 0 > twoSize) - { - retval *= -1; - } - } - - return retval; -} - - -static int segmentCompare(const void* in1, const void* in2) -/* -** qsort helper. -*/ -{ - int retval = 0; - - SegmentStats* one = (SegmentStats*)in1; - SegmentStats* two = (SegmentStats*)in2; - - if(one->mSize < two->mSize) - { - retval = 1; - } - else if(one->mSize > two->mSize) - { - retval = -1; - } - else - { - retval = strcmp(one->mSegment, two->mSegment); - if(0 > one->mSize && 0 > two->mSize) - { - retval *= -1; - } - } - - return retval; -} - - -static int objectCompare(const void* in1, const void* in2) -/* -** qsort helper. -*/ -{ - int retval = 0; - - ObjectStats* one = (ObjectStats*)in1; - ObjectStats* two = (ObjectStats*)in2; - - if(one->mSize < two->mSize) - { - retval = 1; - } - else if(one->mSize > two->mSize) - { - retval = -1; - } - else - { - retval = strcmp(one->mObject, two->mObject); - if(0 > one->mSize && 0 > two->mSize) - { - retval *= -1; - } - } - - return retval; -} - - -static int symbolCompare(const void* in1, const void* in2) -/* -** qsort helper. -*/ -{ - int retval = 0; - - SymbolStats* one = (SymbolStats*)in1; - SymbolStats* two = (SymbolStats*)in2; - - if(one->mSize < two->mSize) - { - retval = 1; - } - else if(one->mSize > two->mSize) - { - retval = -1; - } - else - { - retval = strcmp(one->mSymbol, two->mSymbol); - if(0 > one->mSize && 0 > two->mSize) - { - retval *= -1; - } - } - - return retval; -} - - -void trimWhite(char* inString) -/* -** Remove any whitespace from the end of the string. -*/ -{ - int len = strlen(inString); - - while(len) - { - len--; - - if(isspace(*(inString + len))) - { - *(inString + len) = '\0'; - } - else - { - break; - } - } -} - - -int difftool(Options* inOptions) -/* -** Read a diff file and spit out relevant information. -*/ -{ - int retval = 0; - char lineBuffer[0x500]; - SizeStats overall; - ModuleStats* modules = NULL; - unsigned moduleCount = 0; - unsigned moduleLoop = 0; - ModuleStats* theModule = NULL; - unsigned segmentLoop = 0; - SegmentStats* theSegment = NULL; - unsigned objectLoop = 0; - ObjectStats* theObject = NULL; - unsigned symbolLoop = 0; - SymbolStats* theSymbol = NULL; - unsigned allSymbolCount = 0; - - memset(&overall, 0, sizeof(overall)); - - /* - ** Read the entire diff file. - ** We're only interested in lines beginning with < or > - */ - while(0 == retval && NULL != fgets(lineBuffer, sizeof(lineBuffer), inOptions->mInput)) - { - trimWhite(lineBuffer); - - if(('<' == lineBuffer[0] || '>' == lineBuffer[0]) && ' ' == lineBuffer[1]) - { - int additive = 0; - char* theLine = &lineBuffer[2]; - int scanRes = 0; - int size; - char segClass[0x10]; - char scope[0x10]; - char module[0x100]; - char segment[0x40]; - char object[0x100]; - char* symbol = NULL; - - /* - ** Figure out if the line adds or subtracts from something. - */ - if('>' == lineBuffer[0]) - { - additive = __LINE__; - } - - - /* - ** Scan the line for information. - */ - scanRes = sscanf(theLine, - "%x\t%s\t%s\t%s\t%s\t%s\t", - (unsigned*)&size, - segClass, - scope, - module, - segment, - object); - - if(6 == scanRes) - { - SegmentClass segmentClass = DATA; - - symbol = strrchr(theLine, '\t') + 1; - - if(0 == strcmp(segClass, "CODE")) - { - segmentClass = CODE; - } - else if(0 == strcmp(segClass, "DATA")) - { - segmentClass = DATA; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, segClass, "Unable to determine segment class."); - } - - if(0 == retval) - { - unsigned moduleIndex = 0; - - /* - ** Find, in succession, the following things: - ** the module - ** the segment - ** the object - ** the symbol - ** Failure to find any one of these means to create it. - */ - - for(moduleIndex = 0; moduleIndex < moduleCount; moduleIndex++) - { - if(0 == strcmp(modules[moduleIndex].mModule, module)) - { - break; - } - } - - if(moduleIndex == moduleCount) - { - void* moved = NULL; - - moved = realloc(modules, sizeof(ModuleStats) * (1 + moduleCount)); - if(NULL != moved) - { - modules = (ModuleStats*)moved; - moduleCount++; - memset(modules + moduleIndex, 0, sizeof(ModuleStats)); - - modules[moduleIndex].mModule = strdup(module); - if(NULL == modules[moduleIndex].mModule) - { - retval = __LINE__; - ERROR_REPORT(retval, module, "Unable to duplicate string."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inOptions->mProgramName, "Unable to increase module array."); - } - } - - if(0 == retval) - { - unsigned segmentIndex = 0; - theModule = (modules + moduleIndex); - - for(segmentIndex = 0; segmentIndex < theModule->mSegmentCount; segmentIndex++) - { - if(0 == strcmp(segment, theModule->mSegments[segmentIndex].mSegment)) - { - break; - } - } - - if(segmentIndex == theModule->mSegmentCount) - { - void* moved = NULL; - - moved = realloc(theModule->mSegments, sizeof(SegmentStats) * (theModule->mSegmentCount + 1)); - if(NULL != moved) - { - theModule->mSegments = (SegmentStats*)moved; - theModule->mSegmentCount++; - memset(theModule->mSegments + segmentIndex, 0, sizeof(SegmentStats)); - - theModule->mSegments[segmentIndex].mClass = segmentClass; - theModule->mSegments[segmentIndex].mSegment = strdup(segment); - if(NULL == theModule->mSegments[segmentIndex].mSegment) - { - retval = __LINE__; - ERROR_REPORT(retval, segment, "Unable to duplicate string."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inOptions->mProgramName, "Unable to increase segment array."); - } - } - - if(0 == retval) - { - unsigned objectIndex = 0; - theSegment = (theModule->mSegments + segmentIndex); - - for(objectIndex = 0; objectIndex < theSegment->mObjectCount; objectIndex++) - { - if(0 == strcmp(object, theSegment->mObjects[objectIndex].mObject)) - { - break; - } - } - - if(objectIndex == theSegment->mObjectCount) - { - void* moved = NULL; - - moved = realloc(theSegment->mObjects, sizeof(ObjectStats) * (1 + theSegment->mObjectCount)); - if(NULL != moved) - { - theSegment->mObjects = (ObjectStats*)moved; - theSegment->mObjectCount++; - memset(theSegment->mObjects + objectIndex, 0, sizeof(ObjectStats)); - - theSegment->mObjects[objectIndex].mObject = strdup(object); - if(NULL == theSegment->mObjects[objectIndex].mObject) - { - retval = __LINE__; - ERROR_REPORT(retval, object, "Unable to duplicate string."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inOptions->mProgramName, "Unable to increase object array."); - } - } - - if(0 == retval) - { - unsigned symbolIndex = 0; - theObject = (theSegment->mObjects + objectIndex); - - for(symbolIndex = 0; symbolIndex < theObject->mSymbolCount; symbolIndex++) - { - if(0 == strcmp(symbol, theObject->mSymbols[symbolIndex].mSymbol)) - { - break; - } - } - - if(symbolIndex == theObject->mSymbolCount) - { - void* moved = NULL; - - moved = realloc(theObject->mSymbols, sizeof(SymbolStats) * (1 + theObject->mSymbolCount)); - if(NULL != moved) - { - theObject->mSymbols = (SymbolStats*)moved; - theObject->mSymbolCount++; - allSymbolCount++; - memset(theObject->mSymbols + symbolIndex, 0, sizeof(SymbolStats)); - - theObject->mSymbols[symbolIndex].mSymbol = strdup(symbol); - if(NULL == theObject->mSymbols[symbolIndex].mSymbol) - { - retval = __LINE__; - ERROR_REPORT(retval, symbol, "Unable to duplicate string."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inOptions->mProgramName, "Unable to increase symbol array."); - } - } - - if(0 == retval) - { - theSymbol = (theObject->mSymbols + symbolIndex); - - /* - ** Update our various totals. - */ - if(additive) - { - if(CODE == segmentClass) - { - overall.mCode += size; - theModule->mSize.mCode += size; - } - else if(DATA == segmentClass) - { - overall.mData += size; - theModule->mSize.mData += size; - } - - theSegment->mSize += size; - theObject->mSize += size; - theSymbol->mSize += size; - } - else - { - if(CODE == segmentClass) - { - overall.mCode -= size; - theModule->mSize.mCode -= size; - } - else if(DATA == segmentClass) - { - overall.mData -= size; - theModule->mSize.mData -= size; - } - - theSegment->mSize -= size; - theObject->mSize -= size; - theSymbol->mSize -= size; - } - } - } - } - } - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inOptions->mInputName, "Unable to scan line data."); - } - } - } - - if(0 == retval && 0 != ferror(inOptions->mInput)) - { - retval = __LINE__; - ERROR_REPORT(retval, inOptions->mInputName, "Unable to read file."); - } - - /* - ** Next, it is time to perform revisionist history of sorts. - ** If the negation switch is in play, we perfrom the following - ** aggressive steps: - ** - ** For each section, find size changes which have an equal and - ** opposite change, and set them both to zero. - ** However, you can only do this if the number of negating changes - ** is even, as if it is odd, then any one of the many could be - ** at fault for the actual change. - ** - ** This orginally exists to make the win32 codesighs reports more - ** readable/meaningful. - */ - if(0 == retval && 0 != inOptions->mNegation) - { - ObjectStats** objArray = NULL; - SymbolStats** symArray = NULL; - - /* - ** Create arrays big enough to hold all symbols. - ** As well as an array to keep the owning object at the same index. - ** We will keep the object around as we may need to modify the size. - */ - objArray = (ObjectStats**)malloc(allSymbolCount * sizeof(ObjectStats*)); - symArray = (SymbolStats**)malloc(allSymbolCount * sizeof(SymbolStats*)); - if(NULL == objArray || NULL == symArray) - { - retval = __LINE__; - ERROR_REPORT(retval, inOptions->mProgramName, "Unable to allocate negation array memory."); - } - else - { - unsigned arrayCount = 0; - unsigned arrayLoop = 0; - - /* - ** Go through and perform the steps on each section/segment. - */ - for(moduleLoop = 0; moduleLoop < moduleCount; moduleLoop++) - { - theModule = modules + moduleLoop; - - for(segmentLoop = 0; segmentLoop < theModule->mSegmentCount; segmentLoop++) - { - theSegment = theModule->mSegments + segmentLoop; - - /* - ** Collect all symbols under this section. - ** The symbols are spread out between all the objects, - ** so keep track of both independently at the - ** same index. - */ - arrayCount = 0; - - for(objectLoop = 0; objectLoop < theSegment->mObjectCount; objectLoop++) - { - theObject = theSegment->mObjects + objectLoop; - - for(symbolLoop = 0; symbolLoop < theObject->mSymbolCount; symbolLoop++) - { - theSymbol = theObject->mSymbols + symbolLoop; - - objArray[arrayCount] = theObject; - symArray[arrayCount] = theSymbol; - arrayCount++; - } - } - - /* - ** Now that we have a list of symbols, go through each - ** and see if there is a chance of negation. - */ - for(arrayLoop = 0; arrayLoop < arrayCount; arrayLoop++) - { - /* - ** If the item is NULL, it was already negated. - ** Don't do this for items with a zero size. - */ - if(NULL != symArray[arrayLoop] && 0 != symArray[arrayLoop]->mSize) - { - unsigned identicalValues = 0; - unsigned oppositeValues = 0; - unsigned lookLoop = 0; - const int lookingFor = symArray[arrayLoop]->mSize; - - /* - ** Count the number of items with this value. - ** Count the number of items with the opposite equal value. - ** If they are equal, go through and negate all sizes. - */ - for(lookLoop = arrayLoop; lookLoop < arrayCount; lookLoop++) - { - /* - ** Skip negated items. - ** Skip zero length items. - */ - if(NULL == symArray[lookLoop] || 0 == symArray[lookLoop]->mSize) - { - continue; - } - - if(lookingFor == symArray[lookLoop]->mSize) - { - identicalValues++; - } - else if((-1 * lookingFor) == symArray[lookLoop]->mSize) - { - oppositeValues++; - } - } - - if(0 != identicalValues && identicalValues == oppositeValues) - { - unsigned negationLoop = 0; - - for(negationLoop = arrayLoop; 0 != identicalValues || 0 != oppositeValues; negationLoop++) - { - /* - ** Skip negated items. - ** Skip zero length items. - */ - if(NULL == symArray[negationLoop] || 0 == symArray[negationLoop]->mSize) - { - continue; - } - - /* - ** Negate any size matches. - ** Reflect the change in the object as well. - ** Clear the symbol. - */ - if(lookingFor == symArray[negationLoop]->mSize) - { - objArray[negationLoop]->mSize -= lookingFor; - symArray[negationLoop]->mSize = 0; - symArray[negationLoop] = NULL; - - identicalValues--; - } - else if((-1 * lookingFor) == symArray[negationLoop]->mSize) - { - objArray[negationLoop]->mSize += lookingFor; - symArray[negationLoop]->mSize = 0; - symArray[negationLoop] = NULL; - - oppositeValues--; - } - } - } - } - } - } - } - } - - CLEANUP(objArray); - CLEANUP(symArray); - } - - - /* - ** If all went well, time to report. - */ - if(0 == retval) - { - /* - ** Loop through our data once more, so that the symbols can - ** propigate their changes upwards in a positive/negative - ** fashion. - ** This will help give the composite change more meaning. - */ - for(moduleLoop = 0; moduleLoop < moduleCount; moduleLoop++) - { - theModule = modules + moduleLoop; - - /* - ** Skip if there is zero drift, or no net change. - */ - if(0 == inOptions->mZeroDrift && 0 == (theModule->mSize.mCode + theModule->mSize.mData)) - { - continue; - } - - for(segmentLoop = 0; segmentLoop < theModule->mSegmentCount; segmentLoop++) - { - theSegment = theModule->mSegments + segmentLoop; - - /* - ** Skip if there is zero drift, or no net change. - */ - if(0 == inOptions->mZeroDrift && 0 == theSegment->mSize) - { - continue; - } - - for(objectLoop = 0; objectLoop < theSegment->mObjectCount; objectLoop++) - { - theObject = theSegment->mObjects + objectLoop; - - /* - ** Skip if there is zero drift, or no net change. - */ - if(0 == inOptions->mZeroDrift && 0 == theObject->mSize) - { - continue; - } - - for(symbolLoop = 0; symbolLoop < theObject->mSymbolCount; symbolLoop++) - { - theSymbol = theObject->mSymbols + symbolLoop; - - /* - ** Propagate the composition all the way to the top. - ** Sizes of zero change are skipped. - */ - if(0 < theSymbol->mSize) - { - theObject->mComposition.mPositive += theSymbol->mSize; - theSegment->mComposition.mPositive += theSymbol->mSize; - if(CODE == theSegment->mClass) - { - overall.mCodeComposition.mPositive += theSymbol->mSize; - theModule->mSize.mCodeComposition.mPositive += theSymbol->mSize; - } - else if(DATA == theSegment->mClass) - { - overall.mDataComposition.mPositive += theSymbol->mSize; - theModule->mSize.mDataComposition.mPositive += theSymbol->mSize; - } - } - else if(0 > theSymbol->mSize) - { - theObject->mComposition.mNegative += theSymbol->mSize; - theSegment->mComposition.mNegative += theSymbol->mSize; - if(CODE == theSegment->mClass) - { - overall.mCodeComposition.mNegative += theSymbol->mSize; - theModule->mSize.mCodeComposition.mNegative += theSymbol->mSize; - } - else if(DATA == theSegment->mClass) - { - overall.mDataComposition.mNegative += theSymbol->mSize; - theModule->mSize.mDataComposition.mNegative += theSymbol->mSize; - } - } - } - } - } - } - - - if(inOptions->mSummaryOnly) - { - fprintf(inOptions->mOutput, "%+d (%+d/%+d)\n", overall.mCode + overall.mData, overall.mCodeComposition.mPositive + overall.mDataComposition.mPositive, overall.mCodeComposition.mNegative + overall.mDataComposition.mNegative); - } - else - { - fprintf(inOptions->mOutput, "Overall Change in Size\n"); - fprintf(inOptions->mOutput, "\tTotal:\t%+11d (%+d/%+d)\n", overall.mCode + overall.mData, overall.mCodeComposition.mPositive + overall.mDataComposition.mPositive, overall.mCodeComposition.mNegative + overall.mDataComposition.mNegative); - fprintf(inOptions->mOutput, "\tCode:\t%+11d (%+d/%+d)\n", overall.mCode, overall.mCodeComposition.mPositive, overall.mCodeComposition.mNegative); - fprintf(inOptions->mOutput, "\tData:\t%+11d (%+d/%+d)\n", overall.mData, overall.mDataComposition.mPositive, overall.mDataComposition.mNegative); - } - - /* - ** Check what else we should output. - */ - if(0 == inOptions->mSummaryOnly && NULL != modules && moduleCount) - { - const char* segmentType = NULL; - - /* - ** We're going to sort everything. - */ - qsort(modules, moduleCount, sizeof(ModuleStats), moduleCompare); - for(moduleLoop = 0; moduleLoop < moduleCount; moduleLoop++) - { - theModule = modules + moduleLoop; - - qsort(theModule->mSegments, theModule->mSegmentCount, sizeof(SegmentStats), segmentCompare); - - for(segmentLoop = 0; segmentLoop < theModule->mSegmentCount; segmentLoop++) - { - theSegment = theModule->mSegments + segmentLoop; - - qsort(theSegment->mObjects, theSegment->mObjectCount, sizeof(ObjectStats), objectCompare); - - for(objectLoop = 0; objectLoop < theSegment->mObjectCount; objectLoop++) - { - theObject = theSegment->mObjects + objectLoop; - - qsort(theObject->mSymbols, theObject->mSymbolCount, sizeof(SymbolStats), symbolCompare); - } - } - } - - /* - ** Loop through for output. - */ - for(moduleLoop = 0; moduleLoop < moduleCount; moduleLoop++) - { - theModule = modules + moduleLoop; - - /* - ** Skip if there is zero drift, or no net change. - */ - if(0 == inOptions->mZeroDrift && 0 == (theModule->mSize.mCode + theModule->mSize.mData)) - { - continue; - } - - fprintf(inOptions->mOutput, "\n"); - fprintf(inOptions->mOutput, "%s\n", theModule->mModule); - fprintf(inOptions->mOutput, "\tTotal:\t%+11d (%+d/%+d)\n", theModule->mSize.mCode + theModule->mSize.mData, theModule->mSize.mCodeComposition.mPositive + theModule->mSize.mDataComposition.mPositive, theModule->mSize.mCodeComposition.mNegative + theModule->mSize.mDataComposition.mNegative); - fprintf(inOptions->mOutput, "\tCode:\t%+11d (%+d/%+d)\n", theModule->mSize.mCode, theModule->mSize.mCodeComposition.mPositive, theModule->mSize.mCodeComposition.mNegative); - fprintf(inOptions->mOutput, "\tData:\t%+11d (%+d/%+d)\n", theModule->mSize.mData, theModule->mSize.mDataComposition.mPositive, theModule->mSize.mDataComposition.mNegative); - - for(segmentLoop = 0; segmentLoop < theModule->mSegmentCount; segmentLoop++) - { - theSegment = theModule->mSegments + segmentLoop; - - /* - ** Skip if there is zero drift, or no net change. - */ - if(0 == inOptions->mZeroDrift && 0 == theSegment->mSize) - { - continue; - } - - if(CODE == theSegment->mClass) - { - segmentType = "CODE"; - } - else if(DATA == theSegment->mClass) - { - segmentType = "DATA"; - } - - fprintf(inOptions->mOutput, "\t%+11d (%+d/%+d)\t%s (%s)\n", theSegment->mSize, theSegment->mComposition.mPositive, theSegment->mComposition.mNegative, theSegment->mSegment, segmentType); - - for(objectLoop = 0; objectLoop < theSegment->mObjectCount; objectLoop++) - { - theObject = theSegment->mObjects + objectLoop; - - /* - ** Skip if there is zero drift, or no net change. - */ - if(0 == inOptions->mZeroDrift && 0 == theObject->mSize) - { - continue; - } - - fprintf(inOptions->mOutput, "\t\t%+11d (%+d/%+d)\t%s\n", theObject->mSize, theObject->mComposition.mPositive, theObject->mComposition.mNegative, theObject->mObject); - - for(symbolLoop = 0; symbolLoop < theObject->mSymbolCount; symbolLoop++) - { - theSymbol = theObject->mSymbols + symbolLoop; - - /* - ** Skip if there is zero drift, or no net change. - */ - if(0 == inOptions->mZeroDrift && 0 == theSymbol->mSize) - { - continue; - } - - fprintf(inOptions->mOutput, "\t\t\t%+11d\t%s\n", theSymbol->mSize, theSymbol->mSymbol); - } - } - } - } - } - } - - /* - ** Cleanup time. - */ - for(moduleLoop = 0; moduleLoop < moduleCount; moduleLoop++) - { - theModule = modules + moduleLoop; - - for(segmentLoop = 0; segmentLoop < theModule->mSegmentCount; segmentLoop++) - { - theSegment = theModule->mSegments + segmentLoop; - - for(objectLoop = 0; objectLoop < theSegment->mObjectCount; objectLoop++) - { - theObject = theSegment->mObjects + objectLoop; - - for(symbolLoop = 0; symbolLoop < theObject->mSymbolCount; symbolLoop++) - { - theSymbol = theObject->mSymbols + symbolLoop; - - CLEANUP(theSymbol->mSymbol); - } - - CLEANUP(theObject->mSymbols); - CLEANUP(theObject->mObject); - } - - CLEANUP(theSegment->mObjects); - CLEANUP(theSegment->mSegment); - } - - CLEANUP(theModule->mSegments); - CLEANUP(theModule->mModule); - } - CLEANUP(modules); - - return retval; -} - - -int initOptions(Options* outOptions, int inArgc, char** inArgv) -/* -** returns int 0 if successful. -*/ -{ - int retval = 0; - int loop = 0; - int switchLoop = 0; - int match = 0; - const int switchCount = sizeof(gSwitches) / sizeof(gSwitches[0]); - Switch* current = NULL; - - /* - ** Set any defaults. - */ - memset(outOptions, 0, sizeof(Options)); - outOptions->mProgramName = inArgv[0]; - outOptions->mInput = stdin; - outOptions->mInputName = strdup("stdin"); - outOptions->mOutput = stdout; - outOptions->mOutputName = strdup("stdout"); - - if(NULL == outOptions->mOutputName || NULL == outOptions->mInputName) - { - retval = __LINE__; - ERROR_REPORT(retval, "stdin/stdout", "Unable to strdup."); - } - - /* - ** Go through and attempt to do the right thing. - */ - for(loop = 1; loop < inArgc && 0 == retval; loop++) - { - match = 0; - current = NULL; - - for(switchLoop = 0; switchLoop < switchCount && 0 == retval; switchLoop++) - { - if(0 == strcmp(gSwitches[switchLoop]->mLongName, inArgv[loop])) - { - match = __LINE__; - } - else if(0 == strcmp(gSwitches[switchLoop]->mShortName, inArgv[loop])) - { - match = __LINE__; - } - - if(match) - { - if(gSwitches[switchLoop]->mHasValue) - { - /* - ** Attempt to absorb next option to fullfill value. - */ - if(loop + 1 < inArgc) - { - loop++; - - current = gSwitches[switchLoop]; - current->mValue = inArgv[loop]; - } - } - else - { - current = gSwitches[switchLoop]; - } - - break; - } - } - - if(0 == match) - { - outOptions->mHelp = __LINE__; - retval = __LINE__; - ERROR_REPORT(retval, inArgv[loop], "Unknown command line switch."); - } - else if(NULL == current) - { - outOptions->mHelp = __LINE__; - retval = __LINE__; - ERROR_REPORT(retval, inArgv[loop], "Command line switch requires a value."); - } - else - { - /* - ** Do something based on address/swtich. - */ - if(current == &gInputSwitch) - { - CLEANUP(outOptions->mInputName); - if(NULL != outOptions->mInput && stdin != outOptions->mInput) - { - fclose(outOptions->mInput); - outOptions->mInput = NULL; - } - - outOptions->mInput = fopen(current->mValue, "r"); - if(NULL == outOptions->mInput) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to open input file."); - } - else - { - outOptions->mInputName = strdup(current->mValue); - if(NULL == outOptions->mInputName) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to strdup."); - } - } - } - else if(current == &gOutputSwitch) - { - CLEANUP(outOptions->mOutputName); - if(NULL != outOptions->mOutput && stdout != outOptions->mOutput) - { - fclose(outOptions->mOutput); - outOptions->mOutput = NULL; - } - - outOptions->mOutput = fopen(current->mValue, "a"); - if(NULL == outOptions->mOutput) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to open output file."); - } - else - { - outOptions->mOutputName = strdup(current->mValue); - if(NULL == outOptions->mOutputName) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to strdup."); - } - } - } - else if(current == &gHelpSwitch) - { - outOptions->mHelp = __LINE__; - } - else if(current == &gSummarySwitch) - { - outOptions->mSummaryOnly = __LINE__; - } - else if(current == &gZeroDriftSwitch) - { - outOptions->mZeroDrift = __LINE__; - } - else if(current == &gNegationSwitch) - { - outOptions->mNegation = __LINE__; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mLongName, "No handler for command line switch."); - } - } - } - - return retval; -} - - -void cleanOptions(Options* inOptions) -/* -** Clean up any open handles. -*/ -{ - CLEANUP(inOptions->mInputName); - if(NULL != inOptions->mInput && stdin != inOptions->mInput) - { - fclose(inOptions->mInput); - } - CLEANUP(inOptions->mOutputName); - if(NULL != inOptions->mOutput && stdout != inOptions->mOutput) - { - fclose(inOptions->mOutput); - } - - memset(inOptions, 0, sizeof(Options)); -} - - -void showHelp(Options* inOptions) -/* -** Show some simple help text on usage. -*/ -{ - int loop = 0; - const int switchCount = sizeof(gSwitches) / sizeof(gSwitches[0]); - const char* valueText = NULL; - - printf("usage:\t%s [arguments]\n", inOptions->mProgramName); - printf("\n"); - printf("arguments:\n"); - - for(loop = 0; loop < switchCount; loop++) - { - if(gSwitches[loop]->mHasValue) - { - valueText = " <value>"; - } - else - { - valueText = ""; - } - - printf("\t%s%s\n", gSwitches[loop]->mLongName, valueText); - printf("\t %s%s", gSwitches[loop]->mShortName, valueText); - printf(DESC_NEWLINE "%s\n\n", gSwitches[loop]->mDescription); - } - - printf("This tool takes the diff of two sorted tsv files to form a summary report\n"); - printf("of code and data size changes which is hoped to be human readable.\n"); -} - - -int main(int inArgc, char** inArgv) -{ - int retval = 0; - Options options; - - retval = initOptions(&options, inArgc, inArgv); - if(options.mHelp) - { - showHelp(&options); - } - else if(0 == retval) - { - retval = difftool(&options); - } - - cleanOptions(&options); - return retval; -} -
diff --git a/third_party/codesighs/msdump2symdb.c b/third_party/codesighs/msdump2symdb.c deleted file mode 100644 index 705c3c4..0000000 --- a/third_party/codesighs/msdump2symdb.c +++ /dev/null
@@ -1,1090 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is msdump2symdb.c code, released - * Jan 16, 2003. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Garrett Arch Blythe, 16-January-2003 - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <ctype.h> -#include <errno.h> - -#define ERROR_REPORT(num, val, msg) fprintf(stderr, "error(%d):\t\"%s\"\t%s\n", (num), (val), (msg)); -#define CLEANUP(ptr) do { if(NULL != ptr) { free(ptr); ptr = NULL; } } while(0) - - -typedef struct __struct_Options -/* -** Options to control how we perform. -** -** mProgramName Used in help text. -** mInput File to read for input. -** Default is stdin. -** mInputName Name of the file. -** mOutput Output file, append. -** Default is stdout. -** mOutputName Name of the file. -** mHelp Whether or not help should be shown. -*/ -{ - const char* mProgramName; - FILE* mInput; - char* mInputName; - FILE* mOutput; - char* mOutputName; - int mHelp; -} -Options; - - -typedef struct __struct_Switch -/* -** Command line options. -*/ -{ - const char* mLongName; - const char* mShortName; - int mHasValue; - const char* mValue; - const char* mDescription; -} -Switch; - -#define DESC_NEWLINE "\n\t\t" - -static Switch gInputSwitch = {"--input", "-i", 1, NULL, "Specify input file." DESC_NEWLINE "stdin is default."}; -static Switch gOutputSwitch = {"--output", "-o", 1, NULL, "Specify output file." DESC_NEWLINE "Appends if file exists." DESC_NEWLINE "stdout is default."}; -static Switch gHelpSwitch = {"--help", "-h", 0, NULL, "Information on usage."}; - -static Switch* gSwitches[] = { - &gInputSwitch, - &gOutputSwitch, - &gHelpSwitch -}; - - -typedef struct __struct_MSDump_Symbol -/* -** Struct to hold infomration on a symbol. -** -** mSize Size of the symbol once all work is complete. -** mOffset Offset of the symbol in the section. -** mName Symbolic name. -*/ -{ - unsigned mSize; - unsigned mOffset; - char* mName; -} -MSDump_Symbol; - - -typedef struct __struct_MSDump_Section -/* -** Struct for holding information on a section. -** -** mLength Length of the section in bytes. -** mUsed Number of bytes used in the section thus far. -** Should eventually match mLength after work is done. -** mType Type of section, as string (.data, .text, et. al.) -** mSymbols Symbols found inside the section. -** mSymbolCount Number of symbols in array. -*/ -{ - unsigned mLength; - unsigned mUsed; - char* mType; - - MSDump_Symbol* mSymbols; - unsigned mSymbolCount; -} -MSDump_Section; - - -typedef struct __struct_MSDump_Object -/* -** Struct for holding object's data. -*/ -{ - char* mObject; - - MSDump_Section* mSections; - unsigned mSectionCount; -} -MSDump_Object; - - -typedef struct __struct_MSDump_ReadState -/* -** State flags while reading the input gives us hints on what to do. -** -** mSkipLines Number of lines to skip without parsing. -** mSectionDetails Section information next, like line length. -** mCurrentObject Object file we are dealing with. -*/ -{ - unsigned mSkipLines; - unsigned mSectionDetails; - MSDump_Object* mCurrentObject; -} -MSDump_ReadState; - - -typedef struct __struct_MSDump_Container -/* -** Umbrella container for all data encountered. -*/ -{ - MSDump_ReadState mReadState; - - MSDump_Object* mObjects; - unsigned mObjectCount; -} -MSDump_Container; - - -void trimWhite(char* inString) -/* -** Remove any whitespace from the end of the string. -*/ -{ - int len = strlen(inString); - - while(len) - { - len--; - - if(isspace(*(inString + len))) - { - *(inString + len) = '\0'; - } - else - { - break; - } - } -} - - -const char* skipWhite(const char* inString) -/* -** Return pointer to first non white space character. -*/ -{ - const char* retval = inString; - - while('\0' != *retval && isspace(*retval)) - { - retval++; - } - - return retval; -} - - -const char* skipNonWhite(const char* inString) -/* -** Return pointer to first white space character. -*/ -{ - const char* retval = inString; - - while('\0' != *retval && !isspace(*retval)) - { - retval++; - } - - return retval; -} - - -void slash2bs(char* inString) -/* -** Change any forward slash to a backslash. -*/ -{ - char* slash = inString; - - while(NULL != (slash = strchr(slash, '/'))) - { - *slash = '\\'; - slash++; - } -} - - -const char* skipToArg(const char* inString, unsigned inArgIndex) -/* -** Return pointer either to the arg or NULL. -** 1 indexed. -*/ -{ - const char* retval = NULL; - - while(0 != inArgIndex && '\0' != *inString) - { - inArgIndex--; - - inString = skipWhite(inString); - if(0 != inArgIndex) - { - inString = skipNonWhite(inString); - } - } - - if('\0' != *inString) - { - retval = inString; - } - - return retval; -} - - -const char* getLastArg(const char* inString) -/* -** Return pointer to last arg in string. -*/ -{ - const char* retval = NULL; - int length = 0; - int sawString = 0; - - length = strlen(inString); - while(0 != length) - { - length--; - - if(0 == sawString) - { - if(0 == isspace(inString[length])) - { - sawString = __LINE__; - } - } - else - { - if(0 != isspace(inString[length])) - { - retval = inString + length + 1; - } - } - } - - return retval; -} - - -int processLine(Options* inOptions, MSDump_Container* inContainer, const char* inLine) -/* -** Handle one line at a time. -** Looking for several different types of lines. -** Ignore all other lines. -** The container is the state machine. -** returns 0 on no error. -*/ -{ - int retval = 0; - - /* - ** Check to see if we were expecting section details. - */ - if(0 != inContainer->mReadState.mSectionDetails) - { - const char* length = NULL; - unsigned sectionIndex = 0; - - /* - ** Detail is a 1 based index.... - ** Reset. - */ - sectionIndex = inContainer->mReadState.mSectionDetails - 1; - inContainer->mReadState.mSectionDetails = 0; - - if(0 == strncmp(" Section length", inLine, 18)) - { - const char* sectionLength = NULL; - unsigned numericLength = 0; - char* endScan = NULL; - - sectionLength = skipWhite(inLine + 18); - - errno = 0; - numericLength = strtoul(sectionLength, &endScan, 16); - if(0 == errno && endScan != sectionLength) - { - inContainer->mReadState.mCurrentObject->mSections[sectionIndex].mLength = numericLength; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inLine, "Cannot scan for section length."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inLine, "Cannot parse section line."); - } - } - /* - ** Check for switching object file symbols. - */ - else if(0 == strncmp("Dump of file ", inLine, 13)) - { - const char* dupMe = inLine + 13; - char* dup = NULL; - - dup = strdup(dupMe); - if(NULL != dup) - { - void* growth = NULL; - - trimWhite(dup); - slash2bs(dup); - - - growth = realloc(inContainer->mObjects, (inContainer->mObjectCount + 1) * sizeof(MSDump_Object)); - if(NULL != growth) - { - unsigned int index = inContainer->mObjectCount; - - inContainer->mObjectCount++; - inContainer->mObjects = growth; - memset(inContainer->mObjects + index, 0, sizeof(MSDump_Object)); - - inContainer->mObjects[index].mObject = dup; - - /* - ** Reset the read state for this new object. - */ - memset(&inContainer->mReadState, 0, sizeof(MSDump_ReadState)); - - /* - ** Record our current object file. - */ - inContainer->mReadState.mCurrentObject = inContainer->mObjects + index; - - /* - ** We can skip a few lines. - */ - inContainer->mReadState.mSkipLines = 4; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, dup, "Unable to grow object array."); - free(dup); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, dupMe, "Unable to copy string."); - - } - } - /* - ** Check for a symbol dump or a section header. - */ - else if(isxdigit(*inLine) && isxdigit(*(inLine + 1)) && isxdigit(*(inLine + 2))) - { - const char* sectionString = NULL; - - /* - ** Determine the section for this line. - ** Ignore DEBUG sections. - */ - sectionString = skipToArg(inLine, 3); - if(NULL != sectionString) - { - if(0 != strncmp(sectionString, "DEBUG", 5) && 0 != strncmp(sectionString, "ABS", 3) && 0 != strncmp(sectionString, "UNDEF", 5)) - { - /* - ** MUST start with "SECT" - */ - if(0 == strncmp(sectionString, "SECT", 4)) - { - unsigned sectionIndex1 = 0; - - char *endScan = NULL; - - sectionString += 4; - - /* - ** Convert the remaining string to an index. - ** It will be 1 based. - */ - errno = 0; - sectionIndex1 = strtoul(sectionString, &endScan, 16); - if(0 == errno && endScan != sectionString && 0 != sectionIndex1) - { - unsigned sectionIndex = sectionIndex1 - 1; - - /* - ** Is this a new section? Assumed to be ascending. - ** Or is this a symbol in the section? - */ - if(sectionIndex1 > inContainer->mReadState.mCurrentObject->mSectionCount) - { - const char* typeArg = NULL; - - /* - ** New Section, figure out the type. - */ - typeArg = skipToArg(sectionString, 5); - if(NULL != typeArg) - { - char* typeDup = NULL; - - /* - ** Skip the leading period before duping. - */ - if('.' == *typeArg) - { - typeArg++; - } - typeDup = strdup(typeArg); - - if(NULL != typeDup) - { - void* moved = NULL; - char* nonWhite = NULL; - - /* - ** Terminate the duplicate after the section type. - */ - nonWhite = (char*)skipNonWhite(typeDup); - if(NULL != nonWhite) - { - *nonWhite = '\0'; - } - - /* - ** Create more space for the section in the object... - */ - moved = realloc(inContainer->mReadState.mCurrentObject->mSections, sizeof(MSDump_Section) * sectionIndex1); - if(NULL != moved) - { - unsigned oldCount = inContainer->mReadState.mCurrentObject->mSectionCount; - - inContainer->mReadState.mCurrentObject->mSections = (MSDump_Section*)moved; - inContainer->mReadState.mCurrentObject->mSectionCount = sectionIndex1; - memset(&inContainer->mReadState.mCurrentObject->mSections[oldCount], 0, sizeof(MSDump_Section) * (sectionIndex1 - oldCount)); - - /* - ** Other section details. - */ - inContainer->mReadState.mCurrentObject->mSections[sectionIndex].mType = typeDup; - - - /* - ** Mark it so that we look for the length on the next line. - ** This happens on next entry into the read state. - */ - inContainer->mReadState.mSectionDetails = sectionIndex1; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inLine, "Unable to grow for new section."); - free(typeDup); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, typeArg, "Unable to duplicate type."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inLine, "Unable to determine section type."); - } - - } - else - { - const char* offsetArg = NULL; - const char* classArg = NULL; - unsigned classWords = 1; - const char* symbolArg = NULL; - - /* - ** This is an section we've seen before, and must list a symbol. - ** Figure out the things we want to know about the symbol, e.g. size. - ** We will ignore particular classes of symbols. - */ - - offsetArg = skipToArg(inLine, 2); - - classArg = skipToArg(offsetArg, 4); - if(0 == strncmp(classArg, "()", 2)) - { - classArg = skipToArg(classArg, 2); - } - if(0 == strncmp(classArg, ".bf or.ef", 9)) - { - classWords = 2; - } - - symbolArg = skipToArg(classArg, 3 + (classWords - 1)); - - /* - ** Skip particular lines/items. - */ - if( - 0 != strncmp(classArg, "Label", 5) && - 0 != strncmp(symbolArg, ".bf", 3) && - 0 != strncmp(symbolArg, ".lf", 3) && - 0 != strncmp(symbolArg, ".ef", 3) - ) - { - char* endOffsetArg = NULL; - unsigned offset = 0; - - /* - ** Convert the offset to something meaninful (size). - */ - errno = 0; - offset = strtoul(offsetArg, &endOffsetArg, 16); - if(0 == errno && endOffsetArg != offsetArg) - { - void* moved = NULL; - - /* - ** Increase the size of the symbol array in the section. - ** Assumed symbols are unique within each section. - */ - moved = realloc(inContainer->mReadState.mCurrentObject->mSections[sectionIndex].mSymbols, sizeof(MSDump_Symbol) * (inContainer->mReadState.mCurrentObject->mSections[sectionIndex].mSymbolCount + 1)); - if(NULL != moved) - { - unsigned symIndex = 0; - - /* - ** Record symbol details. - ** Assumed symbols are encountered in order for their section (size calc depends on it). - */ - symIndex = inContainer->mReadState.mCurrentObject->mSections[sectionIndex].mSymbolCount; - inContainer->mReadState.mCurrentObject->mSections[sectionIndex].mSymbolCount++; - inContainer->mReadState.mCurrentObject->mSections[sectionIndex].mSymbols = (MSDump_Symbol*)moved; - memset(&inContainer->mReadState.mCurrentObject->mSections[sectionIndex].mSymbols[symIndex], 0, sizeof(MSDump_Symbol)); - - inContainer->mReadState.mCurrentObject->mSections[sectionIndex].mSymbols[symIndex].mOffset = offset; - - /* - ** We could allocate smarter here if it ever mattered. - */ - inContainer->mReadState.mCurrentObject->mSections[sectionIndex].mSymbols[symIndex].mName = strdup(symbolArg); - if(NULL != inContainer->mReadState.mCurrentObject->mSections[sectionIndex].mSymbols[symIndex].mName) - { - char* trim = NULL; - - trim = (char*)skipNonWhite(inContainer->mReadState.mCurrentObject->mSections[sectionIndex].mSymbols[symIndex].mName); - if(NULL != trim) - { - *trim = '\0'; - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inLine, "Unable to duplicate symbol name."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inLine, "Unable to grow symbol array for section."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inLine, "Unable to convert offset to a number."); - } - } - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inLine, "Unable to determine section index."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inLine, "No match for section prefix."); - } - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inLine, "Unable to scan for section."); - } - } - - return retval; -} - - -void dumpCleanup(MSDump_Container* inContainer) -/* -** Attempt to be nice and free up what we have allocated. -*/ -{ - unsigned objectLoop = 0; - unsigned sectionLoop = 0; - unsigned symbolLoop = 0; - - for(objectLoop = 0; objectLoop < inContainer->mObjectCount; objectLoop++) - { - for(sectionLoop = 0; sectionLoop < inContainer->mObjects[objectLoop].mSectionCount; sectionLoop++) - { - for(symbolLoop = 0; symbolLoop < inContainer->mObjects[objectLoop].mSections[sectionLoop].mSymbolCount; symbolLoop++) - { - CLEANUP(inContainer->mObjects[objectLoop].mSections[sectionLoop].mSymbols[symbolLoop].mName); - } - inContainer->mObjects[objectLoop].mSections[sectionLoop].mSymbolCount = 0; - CLEANUP(inContainer->mObjects[objectLoop].mSections[sectionLoop].mSymbols); - CLEANUP(inContainer->mObjects[objectLoop].mSections[sectionLoop].mType); - } - inContainer->mObjects[objectLoop].mSectionCount = 0; - CLEANUP(inContainer->mObjects[objectLoop].mSections); - } - CLEANUP(inContainer->mObjects); - inContainer->mObjectCount = 0; -} - - -int qsortSymOffset(const void* in1, const void* in2) -/* -** qsort callback to sort the symbols by their offset. -*/ -{ - MSDump_Symbol* sym1 = (MSDump_Symbol*)in1; - MSDump_Symbol* sym2 = (MSDump_Symbol*)in2; - int retval = 0; - - if(sym1->mOffset < sym2->mOffset) - { - retval = 1; - } - else if(sym1->mOffset > sym2->mOffset) - { - retval = -1; - } - - return retval; -} - - -int calcContainer(Options* inOptions, MSDump_Container* inContainer) -/* -** Resposible for doing any size calculations based on the offsets known. -** After this calculation, each sections mUsed will match mSize. -** After this calculation, all symbols should know how big they are. -*/ -{ - int retval = 0; - unsigned objectLoop = 0; - unsigned sectionLoop = 0; - unsigned symbolLoop = 0; - - - /* - ** Need to sort all symbols by their offsets. - */ - for(objectLoop = 0; 0 == retval && objectLoop < inContainer->mObjectCount; objectLoop++) - { - for(sectionLoop = 0; 0 == retval && sectionLoop < inContainer->mObjects[objectLoop].mSectionCount; sectionLoop++) - { - qsort( - inContainer->mObjects[objectLoop].mSections[sectionLoop].mSymbols, - inContainer->mObjects[objectLoop].mSections[sectionLoop].mSymbolCount, - sizeof(MSDump_Symbol), - qsortSymOffset - ); - } - } - - - /* - ** Need to go through all symbols and calculate their size. - */ - for(objectLoop = 0; 0 == retval && objectLoop < inContainer->mObjectCount; objectLoop++) - { - for(sectionLoop = 0; 0 == retval && sectionLoop < inContainer->mObjects[objectLoop].mSectionCount; sectionLoop++) - { - for(symbolLoop = 0; 0 == retval && symbolLoop < inContainer->mObjects[objectLoop].mSections[sectionLoop].mSymbolCount; symbolLoop++) - { - inContainer->mObjects[objectLoop].mSections[sectionLoop].mSymbols[symbolLoop].mSize = - inContainer->mObjects[objectLoop].mSections[sectionLoop].mLength - - inContainer->mObjects[objectLoop].mSections[sectionLoop].mUsed - - inContainer->mObjects[objectLoop].mSections[sectionLoop].mSymbols[symbolLoop].mOffset; - - inContainer->mObjects[objectLoop].mSections[sectionLoop].mUsed += - inContainer->mObjects[objectLoop].mSections[sectionLoop].mSymbols[symbolLoop].mSize; - } - } - } - - - return retval; -} - - -int reportContainer(Options* inOptions, MSDump_Container* inContainer) -/* -** Display all symbols and their data. -** We'll use a tsv format. -*/ -{ - int retval = 0; - unsigned objectLoop = 0; - unsigned sectionLoop = 0; - unsigned symbolLoop = 0; - int printRes = 0; - - for(objectLoop = 0; 0 == retval && objectLoop < inContainer->mObjectCount; objectLoop++) - { - for(sectionLoop = 0; 0 == retval && sectionLoop < inContainer->mObjects[objectLoop].mSectionCount; sectionLoop++) - { - for(symbolLoop = 0; 0 == retval && symbolLoop < inContainer->mObjects[objectLoop].mSections[sectionLoop].mSymbolCount; symbolLoop++) - { - printRes = fprintf(inOptions->mOutput, "%s\t%s\t%.8X\t%s\n", - inContainer->mObjects[objectLoop].mSections[sectionLoop].mSymbols[symbolLoop].mName, - inContainer->mObjects[objectLoop].mSections[sectionLoop].mType, - inContainer->mObjects[objectLoop].mSections[sectionLoop].mSymbols[symbolLoop].mSize, - inContainer->mObjects[objectLoop].mObject - ); - - if(0 > printRes) - { - retval = __LINE__; - ERROR_REPORT(retval, inOptions->mOutputName, "Unable to write to file."); - } - } - } - } - - return retval; -} - - -int dump2symdb(Options* inOptions) -/* -** Convert the input into the output, respecting the options. -** Returns 0 on success. -*/ -{ - int retval = 0; - char lineBuffer[0x800]; - MSDump_Container container; - - memset(&container, 0, sizeof(container)); - - /* - ** Read the file line by line. - */ - while(0 == retval && NULL != fgets(lineBuffer, sizeof(lineBuffer), inOptions->mInput)) - { - if(0 != container.mReadState.mSkipLines) - { - container.mReadState.mSkipLines--; - continue; - } - retval = processLine(inOptions, &container, lineBuffer); - } - - /* - ** Perform whatever calculations desired. - */ - if(0 == retval) - { - retval = calcContainer(inOptions, &container); - } - - /* - ** Output what we know. - */ - if(0 == retval) - { - retval = reportContainer(inOptions, &container); - } - - /* - ** Cleanup what we've done. - */ - dumpCleanup(&container); - - return retval; -} - - -int initOptions(Options* outOptions, int inArgc, char** inArgv) -/* -** returns int 0 if successful. -*/ -{ - int retval = 0; - int loop = 0; - int switchLoop = 0; - int match = 0; - const int switchCount = sizeof(gSwitches) / sizeof(gSwitches[0]); - Switch* current = NULL; - - /* - ** Set any defaults. - */ - memset(outOptions, 0, sizeof(Options)); - outOptions->mProgramName = inArgv[0]; - outOptions->mInput = stdin; - outOptions->mInputName = strdup("stdin"); - outOptions->mOutput = stdout; - outOptions->mOutputName = strdup("stdout"); - - if(NULL == outOptions->mOutputName || NULL == outOptions->mInputName) - { - retval = __LINE__; - ERROR_REPORT(retval, "stdin/stdout", "Unable to strdup."); - } - - /* - ** Go through and attempt to do the right thing. - */ - for(loop = 1; loop < inArgc && 0 == retval; loop++) - { - match = 0; - current = NULL; - - for(switchLoop = 0; switchLoop < switchCount && 0 == retval; switchLoop++) - { - if(0 == strcmp(gSwitches[switchLoop]->mLongName, inArgv[loop])) - { - match = __LINE__; - } - else if(0 == strcmp(gSwitches[switchLoop]->mShortName, inArgv[loop])) - { - match = __LINE__; - } - - if(match) - { - if(gSwitches[switchLoop]->mHasValue) - { - /* - ** Attempt to absorb next option to fullfill value. - */ - if(loop + 1 < inArgc) - { - loop++; - - current = gSwitches[switchLoop]; - current->mValue = inArgv[loop]; - } - } - else - { - current = gSwitches[switchLoop]; - } - - break; - } - } - - if(0 == match) - { - outOptions->mHelp = __LINE__; - retval = __LINE__; - ERROR_REPORT(retval, inArgv[loop], "Unknown command line switch."); - } - else if(NULL == current) - { - outOptions->mHelp = __LINE__; - retval = __LINE__; - ERROR_REPORT(retval, inArgv[loop], "Command line switch requires a value."); - } - else - { - /* - ** Do something based on address/swtich. - */ - if(current == &gInputSwitch) - { - CLEANUP(outOptions->mInputName); - if(NULL != outOptions->mInput && stdin != outOptions->mInput) - { - fclose(outOptions->mInput); - outOptions->mInput = NULL; - } - - outOptions->mInput = fopen(current->mValue, "r"); - if(NULL == outOptions->mInput) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to open input file."); - } - else - { - outOptions->mInputName = strdup(current->mValue); - if(NULL == outOptions->mInputName) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to strdup."); - } - } - } - else if(current == &gOutputSwitch) - { - CLEANUP(outOptions->mOutputName); - if(NULL != outOptions->mOutput && stdout != outOptions->mOutput) - { - fclose(outOptions->mOutput); - outOptions->mOutput = NULL; - } - - outOptions->mOutput = fopen(current->mValue, "a"); - if(NULL == outOptions->mOutput) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to open output file."); - } - else - { - outOptions->mOutputName = strdup(current->mValue); - if(NULL == outOptions->mOutputName) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to strdup."); - } - } - } - else if(current == &gHelpSwitch) - { - outOptions->mHelp = __LINE__; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mLongName, "No handler for command line switch."); - } - } - } - - return retval; -} - - -void cleanOptions(Options* inOptions) -/* -** Clean up any open handles. -*/ -{ - CLEANUP(inOptions->mInputName); - if(NULL != inOptions->mInput && stdin != inOptions->mInput) - { - fclose(inOptions->mInput); - } - CLEANUP(inOptions->mOutputName); - if(NULL != inOptions->mOutput && stdout != inOptions->mOutput) - { - fclose(inOptions->mOutput); - } - - memset(inOptions, 0, sizeof(Options)); -} - - -void showHelp(Options* inOptions) -/* -** Show some simple help text on usage. -*/ -{ - int loop = 0; - const int switchCount = sizeof(gSwitches) / sizeof(gSwitches[0]); - const char* valueText = NULL; - - printf("usage:\t%s [arguments]\n", inOptions->mProgramName); - printf("\n"); - printf("arguments:\n"); - - for(loop = 0; loop < switchCount; loop++) - { - if(gSwitches[loop]->mHasValue) - { - valueText = " <value>"; - } - else - { - valueText = ""; - } - - printf("\t%s%s\n", gSwitches[loop]->mLongName, valueText); - printf("\t %s%s", gSwitches[loop]->mShortName, valueText); - printf(DESC_NEWLINE "%s\n\n", gSwitches[loop]->mDescription); - } - - printf("This tool takes the output of \"dumpbin /symbols\" to produce a simple\n"); - printf("tsv db file of symbols and their respective attributes, like size.\n"); -} - - -int main(int inArgc, char** inArgv) -{ - int retval = 0; - Options options; - - retval = initOptions(&options, inArgc, inArgv); - if(options.mHelp) - { - showHelp(&options); - } - else if(0 == retval) - { - retval = dump2symdb(&options); - } - - cleanOptions(&options); - return retval; -} -
diff --git a/third_party/codesighs/msmap.h b/third_party/codesighs/msmap.h deleted file mode 100644 index 3c528de5..0000000 --- a/third_party/codesighs/msmap.h +++ /dev/null
@@ -1,149 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is msmap.h code, released - * Oct 3, 2002. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Garrett Arch Blythe, 03-October-2002 - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#if !defined __msmap_H -#define __msmap_H - - -#if defined(__cplusplus) -extern "C" { -#endif -#if 0 -} -#endif - - -/* -** Used to numerically represent addresses. -*/ -typedef unsigned long address; - - -typedef enum __enum_MSMap_SymbolScope -/* -** Symbol scope. -*/ -{ - PUBLIC, - STATIC, - UNDEFINED -} -MSMap_SymbolScope; - - -typedef enum __enum_MSMap_SegmentClass -/* -** Segment class. -*/ -{ - CODE, - DATA -} -MSMap_SegmentClass; - - -typedef struct __struct_MSMap_Segment -/* -** Information about a segment. -*/ -{ - address mPrefix; - address mOffset; - address mLength; - address mUsed; - char* mSegment; - MSMap_SegmentClass mClass; -} -MSMap_Segment; - - -typedef struct __struct_MSMap_Symbol -/* -** Information about a symbol. -*/ -{ - address mPrefix; - address mOffset; - char* mSymbol; - address mRVABase; - char* mObject; - MSMap_SymbolScope mScope; - unsigned mSymDBSize; - MSMap_Segment* mSection; -} -MSMap_Symbol; - - -typedef struct __struct_MSMap_Module -/* -** Top level container of the map data. -*/ -{ - char* mModule; - time_t mTimestamp; - address mPreferredLoadAddress; - MSMap_Segment* mSegments; - unsigned mSegmentCount; - unsigned mSegmentCapacity; - address mEntryPrefix; - address mEntryOffset; - MSMap_Symbol* mSymbols; - unsigned mSymbolCount; - unsigned mSymbolCapacity; -} -MSMap_Module; - - -/* -** How much to grow our arrays by. -*/ -#define MSMAP_SEGMENT_GROWBY 0x10 -#define MSMAP_SYMBOL_GROWBY 0x100 - - -#if 0 -{ -#endif -#if defined(__cplusplus) -} /* extern "C" */ -#endif - - -#endif /* __msmap_H */
diff --git a/third_party/codesighs/msmap2tsv.c b/third_party/codesighs/msmap2tsv.c deleted file mode 100644 index 9158702..0000000 --- a/third_party/codesighs/msmap2tsv.c +++ /dev/null
@@ -1,2237 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is msmap2tsv.c code, released - * Oct 3, 2002. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Garrett Arch Blythe, 03-October-2002 - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <ctype.h> - -#include "msmap.h" - -#if defined(_WIN32) -#include <windows.h> -#include <imagehlp.h> - -#define F_DEMANGLE 1 -#define DEMANGLE_STATE_NORMAL 0 -#define DEMANGLE_STATE_QDECODE 1 -#define DEMANGLE_STATE_PROLOGUE_1 2 -#define DEMANGLE_STATE_HAVE_TYPE 3 -#define DEMANGLE_STATE_DEC_LENGTH 4 -#define DEMANGLE_STATE_HEX_LENGTH 5 -#define DEMANGLE_STATE_PROLOGUE_SECONDARY 6 -#define DEMANGLE_STATE_DOLLAR_1 7 -#define DEMANGLE_STATE_DOLLAR_2 8 -#define DEMANGLE_STATE_START 9 -#define DEMANGLE_STATE_STOP 10 -#define DEMANGLE_SAFE_CHAR(eval) (isprint(eval) ? eval : ' ') - -#else -#define F_DEMANGLE 0 -#endif /* WIN32 */ - - -#define ERROR_REPORT(num, val, msg) fprintf(stderr, "error(%d):\t\"%s\"\t%s\n", (num), (val), (msg)); -#define CLEANUP(ptr) do { if(NULL != ptr) { free(ptr); ptr = NULL; } } while(0) - - -typedef struct __struct_SymDB_Size -/* -** The size of the symbol. -** The size is nested withing a symbols structures to produce a fast -** lookup path. -** The objects are listed in case the client of the symdb needs to -** match the object name in the scenario where multiple symbol -** sizes are present. -** -** mSize The size of the symbol in these objects. -** mObjects A list of objects containing said symbol. -** mObjectCount Number of objects. -*/ -{ - unsigned mSize; - char** mObjects; - unsigned mObjectCount; -} -SymDB_Size; - - -typedef struct __struct_SymDB_Section -/* -** Each section for a symbol has a list of sizes. -** Should there be exactly one size for the symbol, then that -** is the size that should be accepted. -** If there is more than one size, then a match on the object -** should be attempted, held withing each size. -** -** mName The section name. -** mSizes The varoius sizes of the symbol in this section. -** mSizeCount The number of available sizes. -*/ -{ - char* mName; - SymDB_Size* mSizes; - unsigned mSizeCount; -} -SymDB_Section; - - -typedef struct __struct_SymDB_Symbol -/* -** Each symbol has at least one section. -** The section indicates what type of symbol a client may be looking for. -** If there is no match on the section, then the client should not trust -** the symbdb. -** -** mName The mangled name of the symbol. -** mSections Various sections this symbol belongs to. -** mSectionCount The number of sections. -*/ -{ - char* mName; - SymDB_Section* mSections; - unsigned mSectionCount; -} -SymDB_Symbol; - - -#define SYMDB_SYMBOL_GROWBY 0x1000 /* how many sybols to allocate at a time */ - - -typedef struct __struct_SymDB_Container -/* -** The symbol DB container object. -** The goal of the symbol DB is to have exactly one SymDB_Symbol for each -** mangled name, no matter how ever many identical mangled names there -** are in the input. -** The input is already expected to be well sorted, futher this leads to -** the ability to binary search for symbol name matches. -** -** mSymbols The symbols. -** mSymbolCount The number of symbols in the DB. -** mSymbolCapacity The number of symbols we can hold (before realloc). -*/ -{ - SymDB_Symbol* mSymbols; - unsigned mSymbolCount; - unsigned mSymbolCapacity; -} -SymDB_Container; - - -typedef struct __struct_Options -/* -** Options to control how we perform. -** -** mProgramName Used in help text. -** mInput File to read for input. -** Default is stdin. -** mInputName Name of the file. -** mOutput Output file, append. -** Default is stdout. -** mOutputName Name of the file. -** mHelp Whether or not help should be shown. -** mMatchModules Array of strings which the module name should match. -** mMatchModuleCount Number of items in array. -** mSymDBName Symbol DB filename. -** mBatchMode Batch mode. -** When in batch mode, the input file contains a list of -** map files to process. -** Normally the input file is a single map file itself. -*/ -{ - const char* mProgramName; - FILE* mInput; - char* mInputName; - FILE* mOutput; - char* mOutputName; - int mHelp; - char** mMatchModules; - unsigned mMatchModuleCount; - char* mSymDBName; - SymDB_Container* mSymDB; - int mBatchMode; -} -Options; - - -typedef struct __struct_Switch -/* -** Command line options. -*/ -{ - const char* mLongName; - const char* mShortName; - int mHasValue; - const char* mValue; - const char* mDescription; -} -Switch; - -#define DESC_NEWLINE "\n\t\t" - -static Switch gInputSwitch = {"--input", "-i", 1, NULL, "Specify input file." DESC_NEWLINE "stdin is default."}; -static Switch gOutputSwitch = {"--output", "-o", 1, NULL, "Specify output file." DESC_NEWLINE "Appends if file exists." DESC_NEWLINE "stdout is default."}; -static Switch gHelpSwitch = {"--help", "-h", 0, NULL, "Information on usage."}; -static Switch gMatchModuleSwitch = {"--match-module", "-mm", 1, NULL, "Specify a valid module name." DESC_NEWLINE "Multiple specifications allowed." DESC_NEWLINE "If a module name does not match one of the names specified then no output will occur."}; -static Switch gSymDBSwitch = {"--symdb", "-sdb", 1, NULL, "Specify a symbol tsv db input file." DESC_NEWLINE "Such a symdb is produced using the tool msdump2symdb." DESC_NEWLINE "This allows better symbol size approximations." DESC_NEWLINE "The symdb file must be pre-sorted."}; -static Switch gBatchModeSwitch = {"--batch", "-b", 0, NULL, "Runs in batch mode." DESC_NEWLINE "The input file contains a list of map files." DESC_NEWLINE "Normally the input file is a map file itself." DESC_NEWLINE "This eliminates reprocessing the symdb for multiple map files."}; - -static Switch* gSwitches[] = { - &gInputSwitch, - &gOutputSwitch, - &gMatchModuleSwitch, - &gSymDBSwitch, - &gBatchModeSwitch, - &gHelpSwitch -}; - - -typedef struct __struct_MSMap_ReadState -/* -** Keep track of what state we are while reading input. -** This gives the input context in which we absorb the datum. -*/ -{ - int mHasModule; - - int mHasTimestamp; - - int mHasPreferredLoadAddress; - - int mHasSegmentData; - int mSegmentDataSkippedLine; - - int mHasPublicSymbolData; - int mHasPublicSymbolDataSkippedLines; - - int mHasEntryPoint; - - int mFoundStaticSymbols; -} -MSMap_ReadState; - - -char* skipWhite(char* inScan) -/* -** Skip whitespace. -*/ -{ - char* retval = inScan; - - while(isspace(*retval)) - { - retval++; - } - - return retval; -} - -void trimWhite(char* inString) -/* -** Remove any whitespace from the end of the string. -*/ -{ - int len = strlen(inString); - - while(len) - { - len--; - - if(isspace(*(inString + len))) - { - *(inString + len) = '\0'; - } - else - { - break; - } - } -} - - -char* lastWord(char* inString) -/* -** Finds and returns the last word in a string. -** It is assumed no whitespace is at the end of the string. -*/ -{ - int mod = 0; - int len = strlen(inString); - - while(len) - { - len--; - if(isspace(*(inString + len))) - { - mod = 1; - break; - } - } - - return inString + len + mod; -} - - -MSMap_Segment* getSymbolSection(MSMap_Module* inModule, MSMap_Symbol* inoutSymbol) -/* -** Perform a lookup for the section of the symbol. -** The function could cache the value. -*/ -{ - MSMap_Segment* retval = NULL; - - if(NULL != inoutSymbol->mSection) - { - /* - ** Use cached value. - */ - retval = inoutSymbol->mSection; - } - else - { - unsigned secLoop = 0; - - /* - ** Go through sections in module to find the match for the symbol. - */ - for(secLoop = 0; secLoop < inModule->mSegmentCount; secLoop++) - { - if(inoutSymbol->mPrefix == inModule->mSegments[secLoop].mPrefix) - { - if(inoutSymbol->mOffset >= inModule->mSegments[secLoop].mOffset) - { - if(inoutSymbol->mOffset < (inModule->mSegments[secLoop].mOffset + inModule->mSegments[secLoop].mLength)) - { - /* - ** We have the section. - */ - retval = &inModule->mSegments[secLoop]; - break; - } - } - } - } - - /* - ** Cache the value for next time. - */ - inoutSymbol->mSection = retval; - } - - return retval; -} - - -int readSymDB(const char* inDBName, SymDB_Container** outDB) -/* -** Intialize the symbol DB. -** Only call if the symbol DB should be initialized. -*/ -{ - int retval = 0; - - /* - ** Initialize out arguments. - */ - if(NULL != outDB) - { - *outDB = NULL; - } - - if(NULL != outDB && NULL != inDBName) - { - FILE* symDB = NULL; - - symDB = fopen(inDBName, "r"); - if(NULL != symDB) - { - *outDB = (SymDB_Container*)calloc(1, sizeof(SymDB_Container)); - if(NULL != *outDB) - { - char lineBuf[0x400]; - char* symbol = NULL; - char* section = NULL; - char* object = NULL; - char* length = NULL; - unsigned lengthNum = 0; - char* endLength = NULL; - - /* - ** Read the file line by line. - */ - while(0 == retval && NULL != fgets(lineBuf, sizeof(lineBuf), symDB)) - { - trimWhite(lineBuf); - - /* - ** Each line has four arguments. tab separated values (tsv). - ** Symbol - ** Section - ** Length - ** Object - */ - - symbol = skipWhite(lineBuf); - if(NULL == symbol) - { - retval = __LINE__; - ERROR_REPORT(retval, inDBName, "File does not appear to be a symbol DB."); - break; - } - - section = strchr(symbol, '\t'); - if(NULL == section) - { - retval = __LINE__; - ERROR_REPORT(retval, inDBName, "File does not appear to be a symbol DB."); - break; - } - *section = '\0'; - section++; - - length = strchr(section, '\t'); - if(NULL == length) - { - retval = __LINE__; - ERROR_REPORT(retval, inDBName, "File does not appear to be a symbol DB."); - break; - } - *length = '\0'; - length++; - - object = strchr(length, '\t'); - if(NULL == object) - { - retval = __LINE__; - ERROR_REPORT(retval, inDBName, "File does not appear to be a symbol DB."); - break; - } - *object = '\0'; - object++; - - /* - ** Convert the length into a number. - */ - errno = 0; - lengthNum = strtoul(length, &endLength, 16); - if(0 == errno && endLength != length) - { - SymDB_Symbol* dbSymbol = NULL; - SymDB_Section* dbSection = NULL; - SymDB_Size* dbSize = NULL; - char* dbObject = NULL; - void* moved = NULL; - - /* - ** Are we looking at the same symbol as last line? - ** This assumes the symdb is pre sorted!!! - */ - if(0 != (*outDB)->mSymbolCount) - { - unsigned index = (*outDB)->mSymbolCount - 1; - - if(0 == strcmp((*outDB)->mSymbols[index].mName, symbol)) - { - dbSymbol = &(*outDB)->mSymbols[index]; - } - } - - /* - ** May need to create symbol. - */ - if(NULL == dbSymbol) - { - /* - ** Could be time to grow the symbol pool. - */ - if((*outDB)->mSymbolCount >= (*outDB)->mSymbolCapacity) - { - moved = realloc((*outDB)->mSymbols, sizeof(SymDB_Symbol) * ((*outDB)->mSymbolCapacity + SYMDB_SYMBOL_GROWBY)); - if(NULL != moved) - { - (*outDB)->mSymbols = (SymDB_Symbol*)moved; - memset(&(*outDB)->mSymbols[(*outDB)->mSymbolCapacity], 0, sizeof(SymDB_Symbol) * SYMDB_SYMBOL_GROWBY); - (*outDB)->mSymbolCapacity += SYMDB_SYMBOL_GROWBY; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inDBName, "Unable to grow symbol DB symbol array."); - break; - } - } - - if((*outDB)->mSymbolCount < (*outDB)->mSymbolCapacity) - { - dbSymbol = &(*outDB)->mSymbols[(*outDB)->mSymbolCount]; - (*outDB)->mSymbolCount++; - - dbSymbol->mName = strdup(symbol); - if(NULL == dbSymbol->mName) - { - retval = __LINE__; - ERROR_REPORT(retval, symbol, "Unable to duplicate string."); - break; - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, symbol, "Unable to grow symbol DB for symbol."); - break; - } - } - - /* - ** Assume we have the symbol. - ** - ** Is this the same section as the last section in the symbol? - ** This assumes the symdb was presorted!!!! - */ - if(0 != dbSymbol->mSectionCount) - { - unsigned index = dbSymbol->mSectionCount - 1; - - if(0 == strcmp(dbSymbol->mSections[index].mName, section)) - { - dbSection = &dbSymbol->mSections[index]; - } - } - - /* - ** May need to create the section. - */ - if(NULL == dbSection) - { - moved = realloc(dbSymbol->mSections, sizeof(SymDB_Section) * (dbSymbol->mSectionCount + 1)); - if(NULL != moved) - { - dbSymbol->mSections = (SymDB_Section*)moved; - dbSection = &dbSymbol->mSections[dbSymbol->mSectionCount]; - dbSymbol->mSectionCount++; - - memset(dbSection, 0, sizeof(SymDB_Section)); - - dbSection->mName = strdup(section); - if(NULL == dbSection->mName) - { - retval = __LINE__; - ERROR_REPORT(retval, section, "Unable to duplicate string."); - break; - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, section, "Unable to grow symbol sections for symbol DB."); - break; - } - } - - /* - ** Assume we have the section. - ** - ** Is this the same size as the last size? - ** This assumes the symdb was presorted!!! - */ - if(0 != dbSection->mSizeCount) - { - unsigned index = dbSection->mSizeCount - 1; - - if(dbSection->mSizes[index].mSize == lengthNum) - { - dbSize = &dbSection->mSizes[index]; - } - } - - /* - ** May need to create the size in question. - */ - if(NULL == dbSize) - { - moved = realloc(dbSection->mSizes, sizeof(SymDB_Size) * (dbSection->mSizeCount + 1)); - if(NULL != moved) - { - dbSection->mSizes = (SymDB_Size*)moved; - dbSize = &dbSection->mSizes[dbSection->mSizeCount]; - dbSection->mSizeCount++; - - memset(dbSize, 0, sizeof(SymDB_Size)); - - dbSize->mSize = lengthNum; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, length, "Unable to grow symbol section sizes for symbol DB."); - break; - } - } - - /* - ** Assume we have the size. - ** - ** We assume a one to one correllation between size and object. - ** Always try to add the new object name. - ** As the symdb is assumed to be sorted, the object names should also be in order. - */ - moved = realloc(dbSize->mObjects, sizeof(char*) * (dbSize->mObjectCount + 1)); - if(NULL != moved) - { - dbObject = strdup(object); - - dbSize->mObjects = (char**)moved; - dbSize->mObjects[dbSize->mObjectCount] = dbObject; - dbSize->mObjectCount++; - - if(NULL == dbObject) - { - retval = __LINE__; - ERROR_REPORT(retval, object, "Unable to duplicate string."); - break; - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, object, "Unable to grow symbol section size objects for symbol DB."); - break; - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, length, "Unable to convert symbol DB length into a number."); - break; - } - } - - if(0 == retval && 0 != ferror(symDB)) - { - retval = __LINE__; - ERROR_REPORT(retval, inDBName, "Unable to read file."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inDBName, "Unable to allocate symbol DB."); - } - - fclose(symDB); - symDB = NULL; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inDBName, "Unable to open symbol DB."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, "(NULL)", "Invalid arguments."); - } - - return retval; -} - - -void cleanSymDB(SymDB_Container** inDB) -/* -** Free it all up. -*/ -{ - if(NULL != inDB && NULL != *inDB) - { - unsigned symLoop = 0; - unsigned secLoop = 0; - unsigned sizLoop = 0; - unsigned objLoop = 0; - - for(symLoop = 0; symLoop < (*inDB)->mSymbolCount; symLoop++) - { - for(secLoop = 0; secLoop < (*inDB)->mSymbols[symLoop].mSectionCount; secLoop++) - { - for(sizLoop = 0; sizLoop < (*inDB)->mSymbols[symLoop].mSections[secLoop].mSizeCount; sizLoop++) - { - for(objLoop = 0; objLoop < (*inDB)->mSymbols[symLoop].mSections[secLoop].mSizes[sizLoop].mObjectCount; objLoop++) - { - CLEANUP((*inDB)->mSymbols[symLoop].mSections[secLoop].mSizes[sizLoop].mObjects[objLoop]); - } - CLEANUP((*inDB)->mSymbols[symLoop].mSections[secLoop].mSizes[sizLoop].mObjects); - } - CLEANUP((*inDB)->mSymbols[symLoop].mSections[secLoop].mName); - CLEANUP((*inDB)->mSymbols[symLoop].mSections[secLoop].mSizes); - } - CLEANUP((*inDB)->mSymbols[symLoop].mName); - CLEANUP((*inDB)->mSymbols[symLoop].mSections); - } - CLEANUP((*inDB)->mSymbols); - CLEANUP(*inDB); - } -} - - -int symDBLookup(const void* inKey, const void* inItem) -/* -** bsearch utility routine to find the symbol in the symdb. -*/ -{ - int retval = 0; - const char* key = (const char*)inKey; - const SymDB_Symbol* symbol = (const SymDB_Symbol*)inItem; - - retval = strcmp(key, symbol->mName); - - return retval; -} - - -int fillSymbolSizeFromDB(Options* inOptions, MSMap_Module* inModule, MSMap_Symbol* inoutSymbol, const char* inMangledName) -/* -** If we have a symbol DB, attempt to determine the real size of the symbol -** up front. -** This helps us later in the game to avoid performing size guesses by -** offset. -*/ -{ - int retval = 0; - - /* - ** May need to initialize symdb. - */ - if(NULL == inOptions->mSymDB && NULL != inOptions->mSymDBName) - { - retval = readSymDB(inOptions->mSymDBName, &inOptions->mSymDB); - } - - /* - ** Optional - */ - if(0 == retval && NULL != inOptions->mSymDB) - { - void* match = NULL; - - /* - ** Find the symbol. - */ - match = bsearch(inMangledName, inOptions->mSymDB->mSymbols, inOptions->mSymDB->mSymbolCount, sizeof(SymDB_Symbol), symDBLookup); - if(NULL != match) - { - SymDB_Symbol* symbol = (SymDB_Symbol*)match; - unsigned symDBSize = 0; - MSMap_Segment* mapSection = NULL; - - /* - ** We found the symbol. - ** - ** See if it has the section in question. - */ - mapSection = getSymbolSection(inModule, inoutSymbol); - if(NULL != mapSection) - { - unsigned secLoop = 0; - - for(secLoop = 0; secLoop < symbol->mSectionCount; secLoop++) - { - if(0 == strcmp(mapSection->mSegment, symbol->mSections[secLoop].mName)) - { - SymDB_Section* section = &symbol->mSections[secLoop]; - - /* - ** We have a section match. - ** Should there be a single size for the symbol, - ** then we just default to that. - ** If more than one size, we have to do an - ** object match search. - ** Should there be no object match, we do nothign. - */ - if(1 == section->mSizeCount) - { - symDBSize = section->mSizes[0].mSize; - } - else - { - char* mapObject = NULL; - - /* - ** Figure out the map object file name. - ** Skip any colon. - ** If it doesn't have a .obj in it, not worth continuing. - */ - mapObject = strrchr(inoutSymbol->mObject, ':'); - if(NULL == mapObject) - { - mapObject = inoutSymbol->mObject; - } - else - { - mapObject++; /* colon */ - } - - if(NULL != strstr(mapObject, ".obj")) - { - unsigned sizLoop = 0; - unsigned objLoop = 0; - SymDB_Size* size = NULL; - - for(sizLoop = 0; sizLoop < section->mSizeCount; sizLoop++) - { - size = §ion->mSizes[sizLoop]; - - for(objLoop = 0; objLoop < size->mObjectCount; objLoop++) - { - if(NULL != strstr(size->mObjects[objLoop], mapObject)) - { - /* - ** As we matched the object, in a particular section, - ** we'll go with this as the number. - */ - symDBSize = size->mSize; - break; - } - } - - /* - ** If the object loop broke early, we break too. - */ - if(objLoop < size->mObjectCount) - { - break; - } - } - } - } - - break; - } - } - } - - /* - ** Put the size in. - */ - inoutSymbol->mSymDBSize = symDBSize; - } - } - - return retval; -} - - -char* symdup(const char* inSymbol) -/* -** Attempts to demangle the symbol if appropriate. -** Otherwise acts like strdup. -*/ -{ - char* retval = NULL; - -#if F_DEMANGLE - { - int isImport = 0; - - if(0 == strncmp("__imp_", inSymbol, 6)) - { - isImport = __LINE__; - inSymbol += 6; - } - - if('?' == inSymbol[0]) - { - char demangleBuf[0x200]; - DWORD demangleRes = 0; - - demangleRes = UnDecorateSymbolName(inSymbol, demangleBuf, sizeof(demangleBuf), UNDNAME_COMPLETE); - if(0 != demangleRes) - { - if (strcmp(demangleBuf, "`string'") == 0) - { - - /* attempt manual demangling of string prefix.. */ - - /* first make sure we have enough space for the - updated string - the demangled string will - always be shorter than strlen(inSymbol) and the - prologue will always be longer than the - "string: " that we tack on the front of the string - */ - char *curresult = retval = malloc(strlen(inSymbol) + 11); - const char *curchar = inSymbol; - - int state = DEMANGLE_STATE_START; - - /* the hex state is for stuff like ?$EA which - really means hex value 0x40 */ - char hex_state = 0; - char string_is_unicode = 0; - - /* sometimes we get a null-termination before the - final @ sign - in that case, remember that - we've seen the whole string */ - int have_null_char = 0; - - /* stick our user-readable prefix on */ - strcpy(curresult, "string: \""); - curresult += 9; - - while (*curchar) { - - // process current state - switch (state) { - - /* the Prologue states are divided up so - that someday we can try to decode - the random letters in between the '@' - signs. Also, some strings only have 2 - prologue '@' signs, so we have to - figure out how to distinguish between - them at some point. */ - case DEMANGLE_STATE_START: - if (*curchar == '@') - state = DEMANGLE_STATE_PROLOGUE_1; - /* ignore all other states */ - break; - - case DEMANGLE_STATE_PROLOGUE_1: - switch (*curchar) { - case '0': - string_is_unicode=0; - state = DEMANGLE_STATE_HAVE_TYPE; - break; - case '1': - string_is_unicode=1; - state = DEMANGLE_STATE_HAVE_TYPE; - break; - - /* ignore all other characters */ - } - break; - - case DEMANGLE_STATE_HAVE_TYPE: - if (*curchar >= '0' && *curchar <= '9') { - state = DEMANGLE_STATE_DEC_LENGTH; - } else if (*curchar >= 'A' && *curchar <= 'Z') { - state = DEMANGLE_STATE_HEX_LENGTH; - } - case DEMANGLE_STATE_DEC_LENGTH: - /* decimal lengths don't have the 2nd - field - */ - if (*curchar == '@') - state = DEMANGLE_STATE_NORMAL; - break; - - case DEMANGLE_STATE_HEX_LENGTH: - /* hex lengths have a 2nd field - (though I have no idea what it is for) - */ - if (*curchar == '@') - state = DEMANGLE_STATE_PROLOGUE_SECONDARY; - break; - - case DEMANGLE_STATE_PROLOGUE_SECONDARY: - if (*curchar == '@') - state = DEMANGLE_STATE_NORMAL; - break; - - case DEMANGLE_STATE_NORMAL: - switch (*curchar) { - case '?': - state = DEMANGLE_STATE_QDECODE; - break; - case '@': - state = DEMANGLE_STATE_STOP; - break; - default: - *curresult++ = DEMANGLE_SAFE_CHAR(*curchar); - state = DEMANGLE_STATE_NORMAL; - break; - } - break; - - /* found a '?' */ - case DEMANGLE_STATE_QDECODE: - state = DEMANGLE_STATE_NORMAL; - - /* there are certain shortcuts, like - "?3" means ":" - */ - switch (*curchar) { - case '1': - *curresult++ = '/'; - break; - case '2': - *curresult++ = '\\'; - break; - case '3': - *curresult++ = ':'; - break; - case '4': - *curresult++ = '.'; - break; - case '5': - *curresult++ = ' '; - break; - case '6': - *curresult++ = '\\'; - *curresult++ = 'n'; - break; - case '8': - *curresult++ = '\''; - break; - case '9': - *curresult++ = '-'; - break; - - /* any other arbitrary ASCII value can - be stored by prefixing it with ?$ - */ - case '$': - state = DEMANGLE_STATE_DOLLAR_1; - } - break; - - case DEMANGLE_STATE_DOLLAR_1: - /* first digit of ?$ notation. All digits - are hex, represented starting with the - capital leter 'A' such that 'A' means 0x0, - 'B' means 0x1, 'K' means 0xA - */ - hex_state = (*curchar - 'A') * 0x10; - state = DEMANGLE_STATE_DOLLAR_2; - break; - - case DEMANGLE_STATE_DOLLAR_2: - /* same mechanism as above */ - hex_state += (*curchar - 'A'); - if (hex_state) { - *curresult++ = DEMANGLE_SAFE_CHAR(hex_state); - have_null_char = 0; - } - else { - have_null_char = 1; - } - - state = DEMANGLE_STATE_NORMAL; - break; - - case DEMANGLE_STATE_STOP: - break; - } - - curchar++; - } - - /* add the appropriate termination depending - if we completed the string or not */ - if (!have_null_char) - strcpy(curresult, "...\""); - else - strcpy(curresult, "\""); - } else { - retval = strdup(demangleBuf); - } - } - else - { - /* - ** fall back to normal. - */ - retval = strdup(inSymbol); - } - } - else if('_' == inSymbol[0]) - { - retval = strdup(inSymbol + 1); - } - else - { - retval = strdup(inSymbol); - } - - /* - ** May need to rewrite the symbol if an import. - */ - if(NULL != retval && isImport) - { - const char importPrefix[] = "__declspec(dllimport) "; - char importBuf[0x200]; - int printRes = 0; - - printRes = _snprintf(importBuf, sizeof(importBuf), "%s%s", importPrefix, retval); - free(retval); - retval = NULL; - - if(printRes > 0) - { - retval = strdup(importBuf); - } - } - } -#else /* F_DEMANGLE */ - retval = strdup(inSymbol); -#endif /* F_DEMANGLE */ - - return retval; -} - - -int readmap(Options* inOptions, MSMap_Module* inModule) -/* -** Read the input line by line, adding it to the module. -*/ -{ - int retval = 0; - char lineBuffer[0x400]; - char* current = NULL; - MSMap_ReadState fsm; - int len = 0; - int forceContinue = 0; - - memset(&fsm, 0, sizeof(fsm)); - - /* - ** Read the map file line by line. - ** We keep a simple state machine to determine what we're looking at. - */ - while(0 == retval && NULL != fgets(lineBuffer, sizeof(lineBuffer), inOptions->mInput)) - { - if(forceContinue) - { - /* - ** Used to skip anticipated blank lines. - */ - forceContinue--; - continue; - } - - current = skipWhite(lineBuffer); - trimWhite(current); - - len = strlen(current); - - if(fsm.mHasModule) - { - if(fsm.mHasTimestamp) - { - if(fsm.mHasPreferredLoadAddress) - { - if(fsm.mHasSegmentData) - { - if(fsm.mHasPublicSymbolData) - { - if(fsm.mHasEntryPoint) - { - if(fsm.mFoundStaticSymbols) - { - /* - ** A blank line means we've reached the end of all static symbols. - */ - if(len) - { - /* - ** We're adding a new symbol. - ** Make sure we have room for it. - */ - if(inModule->mSymbolCapacity == inModule->mSymbolCount) - { - void* moved = NULL; - - moved = realloc(inModule->mSymbols, sizeof(MSMap_Symbol) * (inModule->mSymbolCapacity + MSMAP_SYMBOL_GROWBY)); - if(NULL != moved) - { - inModule->mSymbolCapacity += MSMAP_SYMBOL_GROWBY; - inModule->mSymbols = (MSMap_Symbol*)moved; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inModule->mModule, "Unable to grow symbols."); - } - } - - if(0 == retval && inModule->mSymbolCapacity > inModule->mSymbolCount) - { - MSMap_Symbol* theSymbol = NULL; - unsigned index = 0; - int scanRes = 0; - char symbolBuf[0x200]; - - index = inModule->mSymbolCount; - inModule->mSymbolCount++; - theSymbol = (inModule->mSymbols + index); - - memset(theSymbol, 0, sizeof(MSMap_Symbol)); - theSymbol->mScope = STATIC; - - scanRes = sscanf(current, "%x:%x %s %x", (unsigned*)&(theSymbol->mPrefix), (unsigned*)&(theSymbol->mOffset), symbolBuf, (unsigned*)&(theSymbol->mRVABase)); - if(4 == scanRes) - { - theSymbol->mSymbol = symdup(symbolBuf); - - if(0 == retval) - { - if(NULL != theSymbol->mSymbol) - { - char *last = lastWord(current); - - theSymbol->mObject = strdup(last); - if(NULL == theSymbol->mObject) - { - retval = __LINE__; - ERROR_REPORT(retval, last, "Unable to copy object name."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, symbolBuf, "Unable to copy symbol name."); - } - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inModule->mModule, "Unable to scan static symbols."); - } - } - } - else - { - /* - ** All done. - */ - break; - } - } - else - { - /* - ** Static symbols are optional. - ** If no static symbols we're done. - ** Otherwise, set the flag such that it will work more. - */ - if(0 == strcmp(current, "Static symbols")) - { - fsm.mFoundStaticSymbols = __LINE__; - forceContinue = 1; - } - else - { - /* - ** All done. - */ - break; - } - } - } - else - { - int scanRes = 0; - - scanRes = sscanf(current, "entry point at %x:%x", (unsigned*)&(inModule->mEntryPrefix), (unsigned*)&(inModule->mEntryOffset)); - if(2 == scanRes) - { - fsm.mHasEntryPoint = __LINE__; - forceContinue = 1; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current, "Unable to obtain entry point."); - } - } - } - else - { - /* - ** Skip the N lines of public symbol data (column headers). - */ - if(2 <= fsm.mHasPublicSymbolDataSkippedLines) - { - /* - ** A blank line indicates end of public symbols. - */ - if(len) - { - /* - ** We're adding a new symbol. - ** Make sure we have room for it. - */ - if(inModule->mSymbolCapacity == inModule->mSymbolCount) - { - void* moved = NULL; - - moved = realloc(inModule->mSymbols, sizeof(MSMap_Symbol) * (inModule->mSymbolCapacity + MSMAP_SYMBOL_GROWBY)); - if(NULL != moved) - { - inModule->mSymbolCapacity += MSMAP_SYMBOL_GROWBY; - inModule->mSymbols = (MSMap_Symbol*)moved; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inModule->mModule, "Unable to grow symbols."); - } - } - - if(0 == retval && inModule->mSymbolCapacity > inModule->mSymbolCount) - { - MSMap_Symbol* theSymbol = NULL; - unsigned index = 0; - int scanRes = 0; - char symbolBuf[0x200]; - - index = inModule->mSymbolCount; - inModule->mSymbolCount++; - theSymbol = (inModule->mSymbols + index); - - memset(theSymbol, 0, sizeof(MSMap_Symbol)); - theSymbol->mScope = PUBLIC; - - scanRes = sscanf(current, "%x:%x %s %x", (unsigned*)&(theSymbol->mPrefix), (unsigned*)&(theSymbol->mOffset), symbolBuf, (unsigned *)&(theSymbol->mRVABase)); - if(4 == scanRes) - { - theSymbol->mSymbol = symdup(symbolBuf); - - if(NULL != theSymbol->mSymbol) - { - char *last = lastWord(current); - - theSymbol->mObject = strdup(last); - if(NULL != theSymbol->mObject) - { - /* - ** Finally, attempt to lookup the actual size of the symbol - ** if there is a symbol DB available. - */ - retval = fillSymbolSizeFromDB(inOptions, inModule, theSymbol, symbolBuf); - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, last, "Unable to copy object name."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, symbolBuf, "Unable to copy symbol name."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inModule->mModule, "Unable to scan public symbols."); - } - } - } - else - { - fsm.mHasPublicSymbolData = __LINE__; - } - } - else - { - fsm.mHasPublicSymbolDataSkippedLines++; - } - } - } - else - { - /* - ** Skip the first line of segment data (column headers). - ** Mark that we've begun grabbing segement data. - */ - if(fsm.mSegmentDataSkippedLine) - { - /* - ** A blank line means end of the segment data. - */ - if(len) - { - /* - ** We're adding a new segment. - ** Make sure we have room for it. - */ - if(inModule->mSegmentCapacity == inModule->mSegmentCount) - { - void* moved = NULL; - - moved = realloc(inModule->mSegments, sizeof(MSMap_Segment) * (inModule->mSegmentCapacity + MSMAP_SEGMENT_GROWBY)); - if(NULL != moved) - { - inModule->mSegmentCapacity += MSMAP_SEGMENT_GROWBY; - inModule->mSegments = (MSMap_Segment*)moved; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inModule->mModule, "Unable to grow segments."); - } - } - - if(0 == retval && inModule->mSegmentCapacity > inModule->mSegmentCount) - { - MSMap_Segment* theSegment = NULL; - unsigned index = 0; - char classBuf[0x10]; - char nameBuf[0x20]; - int scanRes = 0; - - index = inModule->mSegmentCount; - inModule->mSegmentCount++; - theSegment = (inModule->mSegments + index); - - memset(theSegment, 0, sizeof(MSMap_Segment)); - - scanRes = sscanf(current, "%x:%x %xH %s %s", (unsigned*)&(theSegment->mPrefix), (unsigned*)&(theSegment->mOffset), (unsigned*)&(theSegment->mLength), nameBuf, classBuf); - if(5 == scanRes) - { - if('.' == nameBuf[0]) - { - theSegment->mSegment = strdup(&nameBuf[1]); - } - else - { - theSegment->mSegment = strdup(nameBuf); - } - - if(NULL != theSegment->mSegment) - { - if(0 == strcmp("DATA", classBuf)) - { - theSegment->mClass = DATA; - } - else if(0 == strcmp("CODE", classBuf)) - { - theSegment->mClass = CODE; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, classBuf, "Unrecognized segment class."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, nameBuf, "Unable to copy segment name."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, inModule->mModule, "Unable to scan segments."); - } - } - } - else - { - fsm.mHasSegmentData = __LINE__; - } - } - else - { - fsm.mSegmentDataSkippedLine = __LINE__; - } - } - } - else - { - int scanRes = 0; - - /* - ** The PLA has a particular format. - */ - scanRes = sscanf(current, "Preferred load address is %x", (unsigned*)&(inModule->mPreferredLoadAddress)); - if(1 == scanRes) - { - fsm.mHasPreferredLoadAddress = __LINE__; - forceContinue = 1; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current, "Unable to obtain preferred load address."); - } - } - } - else - { - int scanRes = 0; - - /* - ** The timestamp has a particular format. - */ - scanRes = sscanf(current, "Timestamp is %x", (unsigned*)&(inModule->mTimestamp)); - if(1 == scanRes) - { - fsm.mHasTimestamp = __LINE__; - forceContinue = 1; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current, "Unable to obtain timestamp."); - } - } - } - else - { - /* - ** The module is on a line by itself. - */ - inModule->mModule = strdup(current); - if(NULL != inModule->mModule) - { - fsm.mHasModule = __LINE__; - forceContinue = 1; - - if(0 != inOptions->mMatchModuleCount) - { - unsigned matchLoop = 0; - - /* - ** If this module name doesn't match, then bail. - ** Compare in a case sensitive manner, exact match only. - */ - for(matchLoop = 0; matchLoop < inOptions->mMatchModuleCount; matchLoop++) - { - if(0 == strcmp(inModule->mModule, inOptions->mMatchModules[matchLoop])) - { - break; - } - } - - if(matchLoop == inOptions->mMatchModuleCount) - { - /* - ** A match did not occur, bail out of read loop. - ** No error, however. - */ - break; - } - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current, "Unable to obtain module."); - } - } - } - - if(0 == retval && 0 != ferror(inOptions->mInput)) - { - retval = __LINE__; - ERROR_REPORT(retval, inOptions->mInputName, "Unable to read file."); - } - - return retval; -} - - -static int qsortRVABase(const void* in1, const void* in2) -/* -** qsort callback to sort the symbols by their RVABase. -*/ -{ - MSMap_Symbol* sym1 = (MSMap_Symbol*)in1; - MSMap_Symbol* sym2 = (MSMap_Symbol*)in2; - int retval = 0; - - if(sym1->mRVABase < sym2->mRVABase) - { - retval = -1; - } - else if(sym1->mRVABase > sym2->mRVABase) - { - retval = 1; - } - - return retval; -} - - -static int tsvout(Options* inOptions, unsigned inSize, MSMap_SegmentClass inClass, MSMap_SymbolScope inScope, const char* inModule, const char* inSegment, const char* inObject, const char* inSymbol) -/* -** Output a line of map information separated by tabs. -** Some items (const char*), if not present, will receive a default value. -*/ -{ - int retval = 0; - - /* - ** No need to output on no size. - ** This can happen with zero sized segments, - ** or an imported symbol which has multiple names (one will count). - */ - if(0 != inSize) - { - char objectBuf[0x100]; - const char* symScope = NULL; - const char* segClass = NULL; - const char* undefined = "UNDEF"; - - /* - ** Fill in unspecified values. - */ - if(NULL == inObject) - { - sprintf(objectBuf, "%s:%s:%s", undefined, inModule, inSegment); - inObject = objectBuf; - } - if(NULL == inSymbol) - { - inSymbol = inObject; - } - - /* - ** Convert some enumerations to text. - */ - switch(inClass) - { - case CODE: - segClass = "CODE"; - break; - case DATA: - segClass = "DATA"; - break; - default: - retval = __LINE__; - ERROR_REPORT(retval, "", "Unable to determine class for output."); - break; - } - - switch(inScope) - { - case PUBLIC: - symScope = "PUBLIC"; - break; - case STATIC: - symScope = "STATIC"; - break; - case UNDEFINED: - symScope = undefined; - break; - default: - retval = __LINE__; - ERROR_REPORT(retval, "", "Unable to determine scope for symbol."); - break; - } - - if(0 == retval) - { - int printRes = 0; - - printRes = fprintf(inOptions->mOutput, - "%.8X\t%s\t%s\t%s\t%s\t%s\t%s\n", - inSize, - segClass, - symScope, - inModule, - inSegment, - inObject, - inSymbol - ); - - if(0 > printRes) - { - retval = __LINE__; - ERROR_REPORT(retval, inOptions->mOutputName, "Unable to output tsv data."); - } - } - } - - return retval; -} - - -void cleanModule(MSMap_Module* inModule) -{ - unsigned loop = 0; - - for(loop = 0; loop < inModule->mSymbolCount; loop++) - { - CLEANUP(inModule->mSymbols[loop].mObject); - CLEANUP(inModule->mSymbols[loop].mSymbol); - } - CLEANUP(inModule->mSymbols); - - for(loop = 0; loop < inModule->mSegmentCount; loop++) - { - CLEANUP(inModule->mSegments[loop].mSegment); - } - CLEANUP(inModule->mSegments); - - CLEANUP(inModule->mModule); - - memset(inModule, 0, sizeof(MSMap_Module)); -} - - -int map2tsv(Options* inOptions) -/* -** Read all input. -** Output tab separated value data. -*/ -{ - int retval = 0; - MSMap_Module module; - - memset(&module, 0, sizeof(module)); - - /* - ** Read in the map file. - */ - retval = readmap(inOptions, &module); - if(0 == retval) - { - unsigned symLoop = 0; - MSMap_Symbol* symbol = NULL; - unsigned secLoop = 0; - MSMap_Segment* section = NULL; - unsigned size = 0; - unsigned dbSize = 0; - unsigned offsetSize = 0; - unsigned endOffset = 0; - - /* - ** Quick sort the symbols via RVABase. - */ - qsort(module.mSymbols, module.mSymbolCount, sizeof(MSMap_Symbol), qsortRVABase); - - /* - ** Go through all the symbols (in order by sort). - ** Output their sizes. - */ - for(symLoop = 0; 0 == retval && symLoop < module.mSymbolCount; symLoop++) - { - symbol = &module.mSymbols[symLoop]; - section = getSymbolSection(&module, symbol); - if (!section) - continue; - - /* - ** Use the symbol DB size if available. - */ - dbSize = symbol->mSymDBSize; - - /* - ** Guess using offsets. - ** Is there a next symbol available? If so, its start offset is the end of this symbol. - ** Otherwise, our section offset + length is the end of this symbol. - ** - ** The trick is, the DB size can not go beyond the offset size, for sanity. - */ - - /* - ** Try next symbol, but only if in same section. - ** If still not, use the end of the segment. - ** This implies we were the last symbol in the segment. - */ - if((symLoop + 1) < module.mSymbolCount) - { - MSMap_Symbol* nextSymbol = NULL; - MSMap_Segment* nextSection = NULL; - - nextSymbol = &module.mSymbols[symLoop + 1]; - nextSection = getSymbolSection(&module, nextSymbol); - - if(section == nextSection) - { - endOffset = nextSymbol->mOffset; - } - else - { - endOffset = section->mOffset + section->mLength; - } - } - else - { - endOffset = section->mOffset + section->mLength; - } - - /* - ** Can now guess at size. - */ - offsetSize = endOffset - symbol->mOffset; - - /* - ** Now, determine which size to use. - ** This is really a sanity check as well. - */ - size = offsetSize; - if(0 != dbSize) - { - if(dbSize < offsetSize) - { - size = dbSize; - } - } - - /* - ** Output the symbol with the size. - */ - retval = tsvout(inOptions, - size, - section->mClass, - symbol->mScope, - module.mModule, - section->mSegment, - symbol->mObject, - symbol->mSymbol - ); - - /* - ** Make sure we mark this amount of space as used in the section. - */ - section->mUsed += size; - } - - /* - ** Go through the sections, and those whose length is longer than the - ** amount of space used, output dummy filler values. - */ - for(secLoop = 0; 0 == retval && secLoop < module.mSegmentCount; secLoop++) - { - section = &module.mSegments[secLoop]; - - if(section && section->mUsed < section->mLength) - { - retval = tsvout(inOptions, - section->mLength - section->mUsed, - section->mClass, - UNDEFINED, - module.mModule, - section->mSegment, - NULL, - NULL - ); - } - } - } - - /* - ** Cleanup. - */ - cleanModule(&module); - - return retval; -} - - -int initOptions(Options* outOptions, int inArgc, char** inArgv) -/* -** returns int 0 if successful. -*/ -{ - int retval = 0; - int loop = 0; - int switchLoop = 0; - int match = 0; - const int switchCount = sizeof(gSwitches) / sizeof(gSwitches[0]); - Switch* current = NULL; - - /* - ** Set any defaults. - */ - memset(outOptions, 0, sizeof(Options)); - outOptions->mProgramName = inArgv[0]; - outOptions->mInput = stdin; - outOptions->mInputName = strdup("stdin"); - outOptions->mOutput = stdout; - outOptions->mOutputName = strdup("stdout"); - - if(NULL == outOptions->mOutputName || NULL == outOptions->mInputName) - { - retval = __LINE__; - ERROR_REPORT(retval, "stdin/stdout", "Unable to strdup."); - } - - /* - ** Go through and attempt to do the right thing. - */ - for(loop = 1; loop < inArgc && 0 == retval; loop++) - { - match = 0; - current = NULL; - - for(switchLoop = 0; switchLoop < switchCount && 0 == retval; switchLoop++) - { - if(0 == strcmp(gSwitches[switchLoop]->mLongName, inArgv[loop])) - { - match = __LINE__; - } - else if(0 == strcmp(gSwitches[switchLoop]->mShortName, inArgv[loop])) - { - match = __LINE__; - } - - if(match) - { - if(gSwitches[switchLoop]->mHasValue) - { - /* - ** Attempt to absorb next option to fullfill value. - */ - if(loop + 1 < inArgc) - { - loop++; - - current = gSwitches[switchLoop]; - current->mValue = inArgv[loop]; - } - } - else - { - current = gSwitches[switchLoop]; - } - - break; - } - } - - if(0 == match) - { - outOptions->mHelp = __LINE__; - retval = __LINE__; - ERROR_REPORT(retval, inArgv[loop], "Unknown command line switch."); - } - else if(NULL == current) - { - outOptions->mHelp = __LINE__; - retval = __LINE__; - ERROR_REPORT(retval, inArgv[loop], "Command line switch requires a value."); - } - else - { - /* - ** Do something based on address/swtich. - */ - if(current == &gInputSwitch) - { - CLEANUP(outOptions->mInputName); - if(NULL != outOptions->mInput && stdin != outOptions->mInput) - { - fclose(outOptions->mInput); - outOptions->mInput = NULL; - } - - outOptions->mInput = fopen(current->mValue, "r"); - if(NULL == outOptions->mInput) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to open input file."); - } - else - { - outOptions->mInputName = strdup(current->mValue); - if(NULL == outOptions->mInputName) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to strdup."); - } - } - } - else if(current == &gOutputSwitch) - { - CLEANUP(outOptions->mOutputName); - if(NULL != outOptions->mOutput && stdout != outOptions->mOutput) - { - fclose(outOptions->mOutput); - outOptions->mOutput = NULL; - } - - outOptions->mOutput = fopen(current->mValue, "a"); - if(NULL == outOptions->mOutput) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to open output file."); - } - else - { - outOptions->mOutputName = strdup(current->mValue); - if(NULL == outOptions->mOutputName) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to strdup."); - } - } - } - else if(current == &gHelpSwitch) - { - outOptions->mHelp = __LINE__; - } - else if(current == &gMatchModuleSwitch) - { - void* moved = NULL; - - /* - ** Add the value to the list of allowed module names. - */ - moved = realloc(outOptions->mMatchModules, sizeof(char*) * (outOptions->mMatchModuleCount + 1)); - if(NULL != moved) - { - outOptions->mMatchModules = (char**)moved; - outOptions->mMatchModules[outOptions->mMatchModuleCount] = strdup(current->mValue); - if(NULL != outOptions->mMatchModules[outOptions->mMatchModuleCount]) - { - outOptions->mMatchModuleCount++; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to duplicate string."); - } - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to allocate space for string."); - } - } - else if(current == &gSymDBSwitch) - { - CLEANUP(outOptions->mSymDBName); - outOptions->mSymDBName = strdup(current->mValue); - if(NULL == outOptions->mSymDBName) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to duplicate symbol db name."); - } - } - else if(current == &gBatchModeSwitch) - { - outOptions->mBatchMode = __LINE__; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mLongName, "No handler for command line switch."); - } - } - } - - return retval; -} - - -void cleanOptions(Options* inOptions) -/* -** Clean up any open handles, et. al. -*/ -{ - CLEANUP(inOptions->mInputName); - if(NULL != inOptions->mInput && stdin != inOptions->mInput) - { - fclose(inOptions->mInput); - } - CLEANUP(inOptions->mOutputName); - if(NULL != inOptions->mOutput && stdout != inOptions->mOutput) - { - fclose(inOptions->mOutput); - } - while(0 != inOptions->mMatchModuleCount) - { - inOptions->mMatchModuleCount--; - CLEANUP(inOptions->mMatchModules[inOptions->mMatchModuleCount]); - } - CLEANUP(inOptions->mMatchModules); - - cleanSymDB(&inOptions->mSymDB); - - memset(inOptions, 0, sizeof(Options)); -} - - -void showHelp(Options* inOptions) -/* -** Show some simple help text on usage. -*/ -{ - int loop = 0; - const int switchCount = sizeof(gSwitches) / sizeof(gSwitches[0]); - const char* valueText = NULL; - - printf("usage:\t%s [arguments]\n", inOptions->mProgramName); - printf("\n"); - printf("arguments:\n"); - - for(loop = 0; loop < switchCount; loop++) - { - if(gSwitches[loop]->mHasValue) - { - valueText = " <value>"; - } - else - { - valueText = ""; - } - - printf("\t%s%s\n", gSwitches[loop]->mLongName, valueText); - printf("\t %s%s", gSwitches[loop]->mShortName, valueText); - printf(DESC_NEWLINE "%s\n\n", gSwitches[loop]->mDescription); - } - - printf("This tool normalizes MS linker .map files for use by other tools.\n"); -} - - -int batchMode(Options* inOptions) -/* -** Batch mode means that the input file is actually a list of map files. -** We simply swap out our input file names while we do this. -*/ -{ - int retval = 0; - char lineBuf[0x400]; - FILE* realInput = NULL; - char* realInputName = NULL; - FILE* mapFile = NULL; - int finalRes = 0; - - realInput = inOptions->mInput; - realInputName = inOptions->mInputName; - - while(0 == retval && NULL != fgets(lineBuf, sizeof(lineBuf), realInput)) - { - trimWhite(lineBuf); - - /* - ** Skip/allow blank lines. - */ - if('\0' == lineBuf[0]) - { - continue; - } - - /* - ** Override what we believe to be the input for this line. - */ - inOptions->mInputName = lineBuf; - inOptions->mInput = fopen(lineBuf, "r"); - if(NULL != inOptions->mInput) - { - int mapRes = 0; - - /* - ** Do it. - */ - mapRes = map2tsv(inOptions); - - /* - ** We report the first error that we encounter, but we continue. - ** This is batch mode after all. - */ - if(0 == finalRes) - { - finalRes = mapRes; - } - - /* - ** Close the input file. - */ - fclose(inOptions->mInput); - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, lineBuf, "Unable to open map file."); - break; - } - } - - if(0 == retval && 0 != ferror(realInput)) - { - retval = __LINE__; - ERROR_REPORT(retval, realInputName, "Unable to read file."); - } - - /* - ** Restore what we've swapped. - */ - inOptions->mInput = realInput; - inOptions->mInputName = realInputName; - - /* - ** Report first map file error if there were no other operational - ** problems. - */ - if(0 == retval) - { - retval = finalRes; - } - - return retval; -} - - -int main(int inArgc, char** inArgv) -{ - int retval = 0; - Options options; - - retval = initOptions(&options, inArgc, inArgv); - if(options.mHelp) - { - showHelp(&options); - } - else if(0 == retval) - { - if(options.mBatchMode) - { - retval = batchMode(&options); - } - else - { - retval = map2tsv(&options); - } - } - - cleanOptions(&options); - return retval; -} -
diff --git a/third_party/codesighs/nm2tsv.c b/third_party/codesighs/nm2tsv.c deleted file mode 100644 index 07b4563..0000000 --- a/third_party/codesighs/nm2tsv.c +++ /dev/null
@@ -1,505 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is nm2tsv.c code, released - * Oct 10, 2002. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Garrett Arch Blythe, 10-October-2002 - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <ctype.h> - - -#define ERROR_REPORT(num, val, msg) fprintf(stderr, "error(%d):\t\"%s\"\t%s\n", (num), (val), (msg)); -#define CLEANUP(ptr) do { if(NULL != ptr) { free(ptr); ptr = NULL; } } while(0) - - -typedef struct __struct_Options -/* -** Options to control how we perform. -** -** mProgramName Used in help text. -** mInput File to read for input. -** Default is stdin. -** mInputName Name of the file. -** mOutput Output file, append. -** Default is stdout. -** mOutputName Name of the file. -** mHelp Whether or not help should be shown. -*/ -{ - const char* mProgramName; - FILE* mInput; - char* mInputName; - FILE* mOutput; - char* mOutputName; - int mHelp; -} -Options; - - -typedef struct __struct_Switch -/* -** Command line options. -*/ -{ - const char* mLongName; - const char* mShortName; - int mHasValue; - const char* mValue; - const char* mDescription; -} -Switch; - -#define DESC_NEWLINE "\n\t\t" - -static Switch gInputSwitch = {"--input", "-i", 1, NULL, "Specify input file." DESC_NEWLINE "stdin is default."}; -static Switch gOutputSwitch = {"--output", "-o", 1, NULL, "Specify output file." DESC_NEWLINE "Appends if file exists." DESC_NEWLINE "stdout is default."}; -static Switch gHelpSwitch = {"--help", "-h", 0, NULL, "Information on usage."}; - -static Switch* gSwitches[] = { - &gInputSwitch, - &gOutputSwitch, - &gHelpSwitch -}; - - -char* scanWhite(char* inScan) -/* -** Scan for whitespace. -*/ -{ - char* retval = inScan; - - while('\0' != *retval && 0 == isspace(*retval)) - { - retval++; - } - - return retval; -} - - -void trimWhite(char* inString) -/* -** Remove any whitespace from the end of the string. -*/ -{ - int len = strlen(inString); - - while(len) - { - len--; - - if(isspace(*(inString + len))) - { - *(inString + len) = '\0'; - } - else - { - break; - } - } -} - - -int nm2tsv(Options* inOptions) -/* -** Read all input. -** Output tab separated value data. -** -** We expect our data to be in a particular format. -** nm --format=bsd --size-sort --print-file-name --demangle -*/ -{ - int retval = 0; - char lineBuffer[4096]; /* yes, the are some very large symbols */ - char* module = NULL; - char* size = NULL; - char* type = NULL; - char* symbol = NULL; - - /* - ** Read in the nm file. - */ - while(0 == retval && NULL != fgets(lineBuffer, sizeof(lineBuffer), inOptions->mInput)) - { - trimWhite(lineBuffer); - - /* - ** Find the various pieces of information we'll be looking for. - */ - size = strchr(lineBuffer, ':'); - if(NULL != size) - { - *size = '\0'; - size++; - - module = strrchr(lineBuffer, '/'); - if(NULL == module) - { - module = lineBuffer; - } - else - { - *module = '\0'; - module++; - } - - type = scanWhite(size); - *type = '\0'; - type++; - - symbol = type + 1; - *symbol = '\0'; - symbol++; - - /* - ** Skip certain types. - */ - switch(*type) - { - case '-': - continue; - break; - default: - break; - } - - /* - ** Simply output the data with a little more interpretation. - ** First is size. - */ - fprintf(inOptions->mOutput, "%s\t", size); - - /* - ** Type, CODE or DATA - */ - switch(toupper(*type)) - { - case 'T': /* text (code) */ - case 'W': /* weak symbol ??? */ - fprintf(inOptions->mOutput, "CODE\t"); - break; - default: - fprintf(inOptions->mOutput, "DATA\t"); - break; - } - - /* - ** Scope, PUBLIC, STATIC, or UNDEF - */ - if(islower(*type)) - { - fprintf(inOptions->mOutput, "STATIC\t"); - } - else - { - switch(*type) - { - case '?': - fprintf(inOptions->mOutput, "UNDEF\t"); - break; - default: - fprintf(inOptions->mOutput, "PUBLIC\t"); - break; - } - } - - /* - ** Module name, segment. - */ - fprintf(inOptions->mOutput, "%s\t", module); - fprintf(inOptions->mOutput, "%c\t", toupper(*type)); - - /* - ** Origin - */ - fprintf(inOptions->mOutput, "UNDEF:%s:%c\t", module, toupper(*type)); - - /* - ** Symbol is last. - */ - fprintf(inOptions->mOutput, "%s\n", symbol); - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, lineBuffer, "Malformed input line."); - } - } - - if(0 == retval && 0 != ferror(inOptions->mInput)) - { - retval = __LINE__; - ERROR_REPORT(retval, inOptions->mInputName, "Unable to read file."); - } - - return retval; -} - - -int initOptions(Options* outOptions, int inArgc, char** inArgv) -/* -** returns int 0 if successful. -*/ -{ - int retval = 0; - int loop = 0; - int switchLoop = 0; - int match = 0; - const int switchCount = sizeof(gSwitches) / sizeof(gSwitches[0]); - Switch* current = NULL; - - /* - ** Set any defaults. - */ - memset(outOptions, 0, sizeof(Options)); - outOptions->mProgramName = inArgv[0]; - outOptions->mInput = stdin; - outOptions->mInputName = strdup("stdin"); - outOptions->mOutput = stdout; - outOptions->mOutputName = strdup("stdout"); - - if(NULL == outOptions->mOutputName || NULL == outOptions->mInputName) - { - retval = __LINE__; - ERROR_REPORT(retval, "stdin/stdout", "Unable to strdup."); - } - - /* - ** Go through and attempt to do the right thing. - */ - for(loop = 1; loop < inArgc && 0 == retval; loop++) - { - match = 0; - current = NULL; - - for(switchLoop = 0; switchLoop < switchCount && 0 == retval; switchLoop++) - { - if(0 == strcmp(gSwitches[switchLoop]->mLongName, inArgv[loop])) - { - match = __LINE__; - } - else if(0 == strcmp(gSwitches[switchLoop]->mShortName, inArgv[loop])) - { - match = __LINE__; - } - - if(match) - { - if(gSwitches[switchLoop]->mHasValue) - { - /* - ** Attempt to absorb next option to fullfill value. - */ - if(loop + 1 < inArgc) - { - loop++; - - current = gSwitches[switchLoop]; - current->mValue = inArgv[loop]; - } - } - else - { - current = gSwitches[switchLoop]; - } - - break; - } - } - - if(0 == match) - { - outOptions->mHelp = __LINE__; - retval = __LINE__; - ERROR_REPORT(retval, inArgv[loop], "Unknown command line switch."); - } - else if(NULL == current) - { - outOptions->mHelp = __LINE__; - retval = __LINE__; - ERROR_REPORT(retval, inArgv[loop], "Command line switch requires a value."); - } - else - { - /* - ** Do something based on address/swtich. - */ - if(current == &gInputSwitch) - { - CLEANUP(outOptions->mInputName); - if(NULL != outOptions->mInput && stdin != outOptions->mInput) - { - fclose(outOptions->mInput); - outOptions->mInput = NULL; - } - - outOptions->mInput = fopen(current->mValue, "r"); - if(NULL == outOptions->mInput) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to open input file."); - } - else - { - outOptions->mInputName = strdup(current->mValue); - if(NULL == outOptions->mInputName) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to strdup."); - } - } - } - else if(current == &gOutputSwitch) - { - CLEANUP(outOptions->mOutputName); - if(NULL != outOptions->mOutput && stdout != outOptions->mOutput) - { - fclose(outOptions->mOutput); - outOptions->mOutput = NULL; - } - - outOptions->mOutput = fopen(current->mValue, "a"); - if(NULL == outOptions->mOutput) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to open output file."); - } - else - { - outOptions->mOutputName = strdup(current->mValue); - if(NULL == outOptions->mOutputName) - { - retval = __LINE__; - ERROR_REPORT(retval, current->mValue, "Unable to strdup."); - } - } - } - else if(current == &gHelpSwitch) - { - outOptions->mHelp = __LINE__; - } - else - { - retval = __LINE__; - ERROR_REPORT(retval, current->mLongName, "No handler for command line switch."); - } - } - } - - return retval; -} - - -void cleanOptions(Options* inOptions) -/* -** Clean up any open handles. -*/ -{ - CLEANUP(inOptions->mInputName); - if(NULL != inOptions->mInput && stdin != inOptions->mInput) - { - fclose(inOptions->mInput); - } - CLEANUP(inOptions->mOutputName); - if(NULL != inOptions->mOutput && stdout != inOptions->mOutput) - { - fclose(inOptions->mOutput); - } - - memset(inOptions, 0, sizeof(Options)); -} - - -void showHelp(Options* inOptions) -/* -** Show some simple help text on usage. -*/ -{ - int loop = 0; - const int switchCount = sizeof(gSwitches) / sizeof(gSwitches[0]); - const char* valueText = NULL; - - printf("usage:\t%s [arguments]\n", inOptions->mProgramName); - printf("\n"); - printf("arguments:\n"); - - for(loop = 0; loop < switchCount; loop++) - { - if(gSwitches[loop]->mHasValue) - { - valueText = " <value>"; - } - else - { - valueText = ""; - } - - printf("\t%s%s\n", gSwitches[loop]->mLongName, valueText); - printf("\t %s%s", gSwitches[loop]->mShortName, valueText); - printf(DESC_NEWLINE "%s\n\n", gSwitches[loop]->mDescription); - } - - printf("This tool normalizes nm output for use by other tools.\n"); - printf("GNU nm is assumed for symbol type determination.\n"); - printf("i.e. Use this tool to parse the output of:\n"); - printf("\t/usr/bin/nm --format=bsd --size-sort --print-file-name --demangle <exefile>\n"); -} - - -int main(int inArgc, char** inArgv) -{ - int retval = 0; - Options options; - - retval = initOptions(&options, inArgc, inArgv); - if(options.mHelp) - { - showHelp(&options); - } - else if(0 == retval) - { - retval = nm2tsv(&options); - } - - cleanOptions(&options); - return retval; -} -
diff --git a/third_party/codesighs/nm_wrap_osx.pl b/third_party/codesighs/nm_wrap_osx.pl deleted file mode 100755 index cf1181f..0000000 --- a/third_party/codesighs/nm_wrap_osx.pl +++ /dev/null
@@ -1,105 +0,0 @@ -#!/usr/bin/perl -w -# -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is autosummary.linx.bash code, released -# Oct 10, 2002. -# -# The Initial Developer of the Original Code is -# Netscape Communications Corporation. -# Portions created by the Initial Developer are Copyright (C) 2002 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Simon Fraser <sfraser@netscape.com> -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -use strict; - -# -# A wrapper for nm that produces output listing symbol size. -# -my($prev_addr) = 0; -my($prev_module) = ""; -my($prev_kind) = ""; -my($prev_symbol) = ""; - -open(NM_OUTPUT, "nm -fnol $ARGV[0] | c++filt |") or die "nm failed to run on $ARGV[0]\n"; -while (<NM_OUTPUT>) -{ - my($line) = $_; - chomp($line); - - if ($line =~ /^([^:]+):\s*([0-9a-f]{8}) (\w) (.+)$/) - { - my($module) = $1; - my($addr) = $2; - my($kind) = $3; - my($symbol) = $4; - - #Skip absolute addresses, there should be only a few - if ('a' eq lc $kind) { - if ('trampoline_size' ne $symbol) { - warn "Encountered unknown absolutely addressed symbol '$symbol' in $module"; - } - next; - } - - # we expect the input to have been piped through c++filt to - # demangle symbols. For some reason, it doesn't always demangle - # all of them, so push still-mangled symbols back through c++filt again. - if ($symbol =~ /^(_[_Z].+)/) - { - # warn "Trying again to unmangle $1\n"; - $symbol = `c++filt '$1'`; - chomp($symbol); - # warn "Unmangling again to $symbol\n"; - } - - my($prev_size) = hex($addr) - hex($prev_addr); - # print "Outputting line $line\n"; - - # always print one behind, because only now do we know its size - if ($prev_module ne "") { - printf "%s:%08x %s %s\n", $prev_module, $prev_size, $prev_kind, $prev_symbol; - } - - $prev_addr = $addr; - $prev_module = $module; - $prev_kind = $kind; - $prev_symbol = $symbol; - } - else - { - # warn " Discaring line $line\n"; - } -} - -# we don't know how big the last symbol is, so always show 4. -if ($prev_module ne "") { - printf "%s:%08x %s %s\n", $prev_module, 4, $prev_kind, $prev_symbol; -}
diff --git a/third_party/codesighs/readelf_wrap.pl b/third_party/codesighs/readelf_wrap.pl deleted file mode 100755 index 7e2b15e..0000000 --- a/third_party/codesighs/readelf_wrap.pl +++ /dev/null
@@ -1,192 +0,0 @@ -#!/usr/bin/perl -w -# -*- Mode: perl; tab-width: 4; indent-tabs-mode: nil; -*- -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is readelf_wrap.pl. -# -# The Initial Developer of the Original Code is -# IBM Corporation. -# Portions created by the Initial Developer are Copyright (C) 2003 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Brian Ryner <bryner@brianryner.com> -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -use strict; - -# Section fields (the full list of values is in <elf.h>) -my $SECT_NUM = 0; # section index -my $SECT_NAME = 1; # section name -my $SECT_TYPE = 2; # section type -my $SECT_ADDR = 3; # section virtual address -my $SECT_OFF = 4; # section offset in file -my $SECT_SIZE = 5; # size of section -my $SECT_ES = 6; # section entry size -my $SECT_FLG = 7; # section flags -my $SECT_LK = 8; # link to another section -my $SECT_INF = 9; # additional section info -my $SECT_AL = 10; # section alignment - - -# Symbol fields (note: the full list of possible values for each field -# is given in <elf.h>) - -my $SYM_NUM = 0; # unique index of the symbol -my $SYM_VALUE = 1; # value of the symbol -my $SYM_SIZE = 2; # size of the symbol -my $SYM_TYPE = 3; # type (NOTYPE, OBJECT, FUNC, SECTION, FILE, ...) -my $SYM_BIND = 4; # binding/scope (LOCAL, GLOBAL, WEAK, ...) -my $SYM_VIS = 5; # visibility (DEFAULT, INTERNAL, HIDDEN, PROTECTED) -my $SYM_NDX = 6; # index of section the symbol is in -my $SYM_NAME = 7; # name of the symbol -my $SYM_FILE = 8; # (not part of readelf) file for symbol - -# Tell readelf to print out the list of sections and then the symbols -die "Usage: $^X <binary>\n" unless ($#ARGV >= 0); -my $readelf = $ENV{'READELF_PROG'}; -if (!$readelf) { - $readelf = 'readelf'; -} -open(READELF_OUTPUT, "$readelf -Ss $ARGV[0] 2>/dev/null | c++filt |") or die "readelf failed to run on $ARGV[0]\n"; - -my @section_list; -my @symbol_list; -my ($module) = ($ARGV[0] =~ /([^\/]+)$/); -my $in_symbols = 0; - -while (<READELF_OUTPUT>) { - - if (!$in_symbols) { - if (/^ *\[ *(\d+)\]/) { - my @section; - - # note that we strip off the leading '.' of section names for - # readability - if (! (@section = (/^ *\[ *(\d+)\] \.([\w\.\-]+) *(\w+) *(.{8}) (.{6}[0-9a-fA-F]*) (.{6}[0-9a-fA-F]*) *(\d+) ([a-zA-Z]+ +| +[a-zA-Z]+|) *(\d+) *(\w+) *(\d+)/))) { - # capture the 'null' section which has no name, so that the - # array indices are the same as the section indices. - - @section = ($1, '', 'NULL', '00000000', '000000', '000000', - '00', '', '0', '0', '0'); - } - - push (@section_list, \@section); - } elsif (/^Symbol table/) { - $in_symbols = 1; - } - } else { - - my @sym; - - if (@sym = /^\s*(\d+): (\w+)\s*(\d+)\s*(\w+)\s*(\w+)\s*(\w+)\s*(\w+) (.*)/) - { - # Filter out types of symbols that we don't care about: - # - anything that's not of type OBJECT or FUNC - # - any undefined symbols (ndx = UND[EF]) - # - any 0-size symbols - - if (($sym[$SYM_TYPE] !~ /^(OBJECT|FUNC)$/) || - $sym[$SYM_NDX] eq 'UND' || $sym[$SYM_NDX] eq 'UNDEF' - || $sym[$SYM_SIZE] eq '0') { - next; - } - push (@symbol_list, \@sym); - } - elsif (/^Symbol table .*'\.symtab'/) { - # We've been using .dynsym up to this point, but if we have .symtab - # available, it will have everything in .dynsym and more. - # So, reset our symbol list. - - @symbol_list = (); - } - } -} - -close(READELF_OUTPUT); - -# spit them out in codesighs TSV format -my $sym; -my @section_sizes; -$#section_sizes = $#section_list; -foreach (@section_sizes) { $_ = 0; } - -foreach $sym (@symbol_list) { - # size - printf "%08x\t", $sym->[$SYM_SIZE]; - - # code or data - if ($sym->[$SYM_TYPE] eq 'FUNC') { - print "CODE\t"; - } else { # OBJECT - print "DATA\t"; - } - - # scope - if ($sym->[$SYM_BIND] eq 'LOCAL') { - print "STATIC\t"; - } elsif ($sym->[$SYM_BIND] =~ /(GLOBAL|WEAK)/) { - print "PUBLIC\t"; - } else { - print "UNDEF\t"; - } - - # module name - - print "$module\t"; - - # section - my $section = $section_list[$sym->[$SYM_NDX]]->[$SECT_NAME]; - print "$section\t"; - - # should be the object file, but for now just module/section - print "UNDEF:$module:$section\t"; - - # now the symbol name - print $sym->[$SYM_NAME]."\n"; - - # update our cumulative section sizes - $section_sizes[$section_list[$sym->[$SYM_NDX]]->[$SECT_NUM]] += $sym->[$SYM_SIZE]; -} - -# Output extra entries to make the sum of the symbol sizes equal the -# section size. - -my $section; -foreach $section (@section_list) { - - my $diff = hex($section->[$SECT_SIZE]) - $section_sizes[$section->[$SECT_NUM]]; - if ($diff > 0) { - my $sectname = $section->[$SECT_NAME]; - if ($section->[$SECT_NAME] =~ /^(rodata|data|text|bss)/) { - printf "%08x", $diff; - print "\tDATA\tSTATIC\t$module\t$sectname\tUNDEF:$module:$sectname\t.nosyms.$sectname\n"; -# } else { -# print "ignoring $diff bytes of empty space in $sectname section\n"; - } - } -}
diff --git a/third_party/fuzzymatch/README.chromium b/third_party/fuzzymatch/README.chromium deleted file mode 100644 index 8bc0d31..0000000 --- a/third_party/fuzzymatch/README.chromium +++ /dev/null
@@ -1,9 +0,0 @@ -Name: fuzzymatch -URL: None -License: BSD -License File: NOT_SHIPPED -Security Critical: no -Version: None - -This was written by agl@chromium.org as part of Chromium, but is in -third_party/ because there were plans to contribute it to WebKit.
diff --git a/third_party/fuzzymatch/SConstruct b/third_party/fuzzymatch/SConstruct deleted file mode 100644 index 4fe7baa..0000000 --- a/third_party/fuzzymatch/SConstruct +++ /dev/null
@@ -1 +0,0 @@ -Program('fuzzymatch.c', LIBS = ['lept', 'png', 'jpeg', 'tiff', 'z', 'm'])
diff --git a/third_party/fuzzymatch/fuzzymatch.c b/third_party/fuzzymatch/fuzzymatch.c deleted file mode 100644 index c68fcf73..0000000 --- a/third_party/fuzzymatch/fuzzymatch.c +++ /dev/null
@@ -1,158 +0,0 @@ -// Copyright (c) 2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/* Fuzzy pixel test matching. - * - * This is designed to compare two layout test images (RGB 800x600) and manage - * to ignore the noise caused by the font renderers choosing slightly different - * pixels. - * - * A B - * | | - * |--->delta<---| - * | - * V - * gray - * | - * V - * binary - * | - * |-------------| - * | | - * 1x3 3x1 Morphological openings - * | | - * |-----OR------| - * | - * V - * count pixels - * - * The result is that three different pixels in a row (vertically or - * horizontally) will cause the match to fail and the binary exits with code 1. - * Otherwise the binary exists with code 0. - * - * This requires leptonica to be installed. On Ubuntu do - * # apt-get install libleptonica libleptonica-dev libtiff4-dev - * - * Build with: - * % gcc -o fuzzymatch fuzzymatch.c -llept -ljpeg -ltiff -lpng -lz -lm -Wall -O2 - * - * Options: - * --highlight: write highlight.png which is a copy of the first image - * argument where the differing areas (after noise removal) are ringed - * in red - * --no-ignore-scrollbars: usually the rightmost 15px of the image are - * ignored to account for scrollbars. Use this flag to include them in - * consideration - */ - -#include <unistd.h> -#include <stdio.h> -#include <leptonica/allheaders.h> - -static int -usage(const char *argv0) { - fprintf(stderr, "Usage: %s [--highlight] [--no-ignore-scrollbars] " - "[--output filename] " - "<input a> <input b>\n", argv0); - return 1; -} - -int -main(int argc, char **argv) { - if (argc < 3) - return usage(argv[0]); - - char highlight = 0; - char ignore_scrollbars = 1; - /* Default output filename; can be overridden by command line. */ - const char *output_filename = "highlight.png"; - - int argi = 1; - - for (; argi < argc; ++argi) { - if (strcmp("--highlight", argv[argi]) == 0) { - highlight = 1; - } else if (strcmp("--no-ignore-scrollbars", argv[argi]) == 0) { - ignore_scrollbars = 0; - } else if (strcmp("--output", argv[argi]) == 0) { - if (argi + 1 >= argc) { - fprintf(stderr, "missing argument to --output\n"); - return 1; - } - output_filename = argv[++argi]; - } else { - break; - } - } - - if (argc - argi < 2) - return usage(argv[0]); - - PIX *a = pixRead(argv[argi]); - PIX *b = pixRead(argv[argi + 1]); - - if (!a) { - fprintf(stderr, "Failed to open %s\n", argv[argi]); - return 1; - } - - if (!b) { - fprintf(stderr, "Failed to open %s\n", argv[argi + 1]); - return 1; - } - - if (pixGetWidth(a) != pixGetWidth(b) || - pixGetHeight(a) != pixGetHeight(b)) { - fprintf(stderr, "Inputs are difference sizes\n"); - return 1; - } - - PIX *delta = pixAbsDifference(a, b); - pixInvert(delta, delta); - if (!highlight) - pixDestroy(&a); - pixDestroy(&b); - - PIX *deltagray = pixConvertRGBToGray(delta, 0, 0, 0); - pixDestroy(&delta); - - PIX *deltabinary = pixThresholdToBinary(deltagray, 254); - PIX *deltabinaryclipped; - const int clipwidth = pixGetWidth(deltabinary) - 15; - const int clipheight = pixGetHeight(deltabinary) - 15; - - if (ignore_scrollbars && clipwidth > 0 && clipheight > 0) { - BOX *clip = boxCreate(0, 0, clipwidth, clipheight); - - deltabinaryclipped = pixClipRectangle(deltabinary, clip, NULL); - boxDestroy(&clip); - pixDestroy(&deltabinary); - } else { - deltabinaryclipped = deltabinary; - deltabinary = NULL; - } - - PIX *hopened = pixOpenBrick(NULL, deltabinaryclipped, 3, 1); - PIX *vopened = pixOpenBrick(NULL, deltabinaryclipped, 1, 3); - pixDestroy(&deltabinaryclipped); - - PIX *opened = pixOr(NULL, hopened, vopened); - pixDestroy(&hopened); - pixDestroy(&vopened); - - l_int32 count; - pixCountPixels(opened, &count, NULL); - fprintf(stderr, "%d\n", count); - - if (count && highlight) { - PIX *d1 = pixDilateBrick(NULL, opened, 7, 7); - PIX *d2 = pixDilateBrick(NULL, opened, 3, 3); - pixInvert(d2, d2); - pixAnd(d1, d1, d2); - pixPaintThroughMask(a, d1, 0, 0, 0xff << 24); - pixWrite(output_filename, a, IFF_PNG); - } - - return count > 0; -}
diff --git a/tools/licenses.py b/tools/licenses.py index 45e783e..b7ea2334 100755 --- a/tools/licenses.py +++ b/tools/licenses.py
@@ -271,7 +271,6 @@ os.path.join('third_party', 'bspatch'), os.path.join('third_party', 'cacheinvalidation'), os.path.join('third_party', 'cld'), - os.path.join('third_party', 'codesighs'), os.path.join('third_party', 'flot'), os.path.join('third_party', 'gtk+'), os.path.join('third_party', 'iaccessible2'),
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index c57beff..09367e4 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml
@@ -34808,6 +34808,16 @@ </summary> </histogram> +<histogram name="Net.ResourceLoader.ExpectedContentSizeResult" + enum="ResourceLoaderExpectedContentSizeResult"> + <owner>maksim.sisov@intel.com</owner> + <owner>mmenke@chromium.org</owner> + <summary> + Records how many times expected content size equals/less/more than size of + read body/buffer or content size is unkown. Recorded for each resource load. + </summary> +</histogram> + <histogram name="Net.ResourceLoader.InliningStatus" enum="ResourceLoaderInliningStatus"> <owner>tzik@chromium.org</owner> @@ -103232,6 +103242,15 @@ <int value="1" label="Has client"/> </enum> +<enum name="ResourceLoaderExpectedContentSizeResult" type="int"> + <int value="0" label="EQ_RESPONSE_BODY"/> + <int value="1" label="EQ_RESPONSE_BODY_GT_EQ_BUFFER_SIZE"/> + <int value="2" label="GT_EQ_BUFFER_SIZE"/> + <int value="3" label="LT_RESPONSE_BODY"/> + <int value="4" label="GT_RESPONSE_BODY"/> + <int value="5" label="UNKNOWN"/> +</enum> + <enum name="ResourceLoaderInliningStatus" type="int"> <int value="0" label="Applicable"/> <int value="1" label="EarlyAllocation"/>
diff --git a/ui/views/controls/menu/menu_runner.h b/ui/views/controls/menu/menu_runner.h index f0adccf..63bb56a 100644 --- a/ui/views/controls/menu/menu_runner.h +++ b/ui/views/controls/menu/menu_runner.h
@@ -108,6 +108,8 @@ // Creates a new MenuRunner, which may use a native menu if available. // |run_types| is a bitmask of RunTypes. If provided, // |on_menu_closed_callback| is invoked when the menu is closed. + // Note that with a native menu (e.g. on Mac), the ASYNC flag in |run_types| + // may be ignored. See http://crbug.com/682544. MenuRunner(ui::MenuModel* menu_model, int32_t run_types, const base::Closure& on_menu_closed_callback = base::Closure());