Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsExceptionHandler_h__ |
michael@0 | 7 | #define nsExceptionHandler_h__ |
michael@0 | 8 | |
michael@0 | 9 | #include <stddef.h> |
michael@0 | 10 | #include <stdint.h> |
michael@0 | 11 | #include "nsError.h" |
michael@0 | 12 | #include "nsStringGlue.h" |
michael@0 | 13 | |
michael@0 | 14 | #if defined(XP_WIN32) |
michael@0 | 15 | #ifdef WIN32_LEAN_AND_MEAN |
michael@0 | 16 | #undef WIN32_LEAN_AND_MEAN |
michael@0 | 17 | #endif |
michael@0 | 18 | #include <windows.h> |
michael@0 | 19 | #endif |
michael@0 | 20 | |
michael@0 | 21 | #if defined(XP_MACOSX) |
michael@0 | 22 | #include <mach/mach.h> |
michael@0 | 23 | #endif |
michael@0 | 24 | |
michael@0 | 25 | #if defined(XP_LINUX) |
michael@0 | 26 | #include <signal.h> |
michael@0 | 27 | #endif |
michael@0 | 28 | |
michael@0 | 29 | class nsIFile; |
michael@0 | 30 | template<class KeyClass, class DataType> class nsDataHashtable; |
michael@0 | 31 | class nsCStringHashKey; |
michael@0 | 32 | |
michael@0 | 33 | namespace CrashReporter { |
michael@0 | 34 | nsresult SetExceptionHandler(nsIFile* aXREDirectory, bool force=false); |
michael@0 | 35 | nsresult UnsetExceptionHandler(); |
michael@0 | 36 | |
michael@0 | 37 | /** |
michael@0 | 38 | * Tell the crash reporter to recalculate where crash events files should go. |
michael@0 | 39 | * |
michael@0 | 40 | * This should be called during crash reporter initialization and when a |
michael@0 | 41 | * profile is activated or deactivated. |
michael@0 | 42 | */ |
michael@0 | 43 | void UpdateCrashEventsDir(); |
michael@0 | 44 | |
michael@0 | 45 | /** |
michael@0 | 46 | * Get the path where crash event files should be written. |
michael@0 | 47 | */ |
michael@0 | 48 | bool GetCrashEventsDir(nsAString& aPath); |
michael@0 | 49 | |
michael@0 | 50 | bool GetEnabled(); |
michael@0 | 51 | bool GetServerURL(nsACString& aServerURL); |
michael@0 | 52 | nsresult SetServerURL(const nsACString& aServerURL); |
michael@0 | 53 | bool GetMinidumpPath(nsAString& aPath); |
michael@0 | 54 | nsresult SetMinidumpPath(const nsAString& aPath); |
michael@0 | 55 | |
michael@0 | 56 | |
michael@0 | 57 | // AnnotateCrashReport and AppendAppNotesToCrashReport may be called from any |
michael@0 | 58 | // thread in a chrome process, but may only be called from the main thread in |
michael@0 | 59 | // a content process. |
michael@0 | 60 | nsresult AnnotateCrashReport(const nsACString& key, const nsACString& data); |
michael@0 | 61 | nsresult AppendAppNotesToCrashReport(const nsACString& data); |
michael@0 | 62 | |
michael@0 | 63 | void AnnotateOOMAllocationSize(size_t size); |
michael@0 | 64 | nsresult SetGarbageCollecting(bool collecting); |
michael@0 | 65 | void SetEventloopNestingLevel(uint32_t level); |
michael@0 | 66 | |
michael@0 | 67 | nsresult SetRestartArgs(int argc, char** argv); |
michael@0 | 68 | nsresult SetupExtraData(nsIFile* aAppDataDirectory, |
michael@0 | 69 | const nsACString& aBuildID); |
michael@0 | 70 | bool GetLastRunCrashID(nsAString& id); |
michael@0 | 71 | |
michael@0 | 72 | // Registers an additional memory region to be included in the minidump |
michael@0 | 73 | nsresult RegisterAppMemory(void* ptr, size_t length); |
michael@0 | 74 | nsresult UnregisterAppMemory(void* ptr); |
michael@0 | 75 | |
michael@0 | 76 | // Functions for working with minidumps and .extras |
michael@0 | 77 | typedef nsDataHashtable<nsCStringHashKey, nsCString> AnnotationTable; |
michael@0 | 78 | |
michael@0 | 79 | bool GetMinidumpForID(const nsAString& id, nsIFile** minidump); |
michael@0 | 80 | bool GetIDFromMinidump(nsIFile* minidump, nsAString& id); |
michael@0 | 81 | bool GetExtraFileForID(const nsAString& id, nsIFile** extraFile); |
michael@0 | 82 | bool GetExtraFileForMinidump(nsIFile* minidump, nsIFile** extraFile); |
michael@0 | 83 | bool AppendExtraData(const nsAString& id, const AnnotationTable& data); |
michael@0 | 84 | bool AppendExtraData(nsIFile* extraFile, const AnnotationTable& data); |
michael@0 | 85 | void RenameAdditionalHangMinidump(nsIFile* minidump, nsIFile* childMinidump, |
michael@0 | 86 | const nsACString& name); |
michael@0 | 87 | |
michael@0 | 88 | #ifdef XP_WIN32 |
michael@0 | 89 | nsresult WriteMinidumpForException(EXCEPTION_POINTERS* aExceptionInfo); |
michael@0 | 90 | #endif |
michael@0 | 91 | #ifdef XP_LINUX |
michael@0 | 92 | bool WriteMinidumpForSigInfo(int signo, siginfo_t* info, void* uc); |
michael@0 | 93 | #endif |
michael@0 | 94 | #ifdef XP_MACOSX |
michael@0 | 95 | nsresult AppendObjCExceptionInfoToAppNotes(void *inException); |
michael@0 | 96 | #endif |
michael@0 | 97 | nsresult GetSubmitReports(bool* aSubmitReport); |
michael@0 | 98 | nsresult SetSubmitReports(bool aSubmitReport); |
michael@0 | 99 | |
michael@0 | 100 | // Out-of-process crash reporter API. |
michael@0 | 101 | |
michael@0 | 102 | // Initializes out-of-process crash reporting. This method must be called |
michael@0 | 103 | // before the platform-specifi notificationpipe APIs are called. |
michael@0 | 104 | void OOPInit(); |
michael@0 | 105 | |
michael@0 | 106 | // Return true if a dump was found for |childPid|, and return the |
michael@0 | 107 | // path in |dump|. The caller owns the last reference to |dump| if it |
michael@0 | 108 | // is non-nullptr. The sequence parameter will be filled with an ordinal |
michael@0 | 109 | // indicating which remote process crashed first. |
michael@0 | 110 | bool TakeMinidumpForChild(uint32_t childPid, |
michael@0 | 111 | nsIFile** dump, |
michael@0 | 112 | uint32_t* aSequence = nullptr); |
michael@0 | 113 | |
michael@0 | 114 | #if defined(XP_WIN) |
michael@0 | 115 | typedef HANDLE ProcessHandle; |
michael@0 | 116 | typedef DWORD ThreadId; |
michael@0 | 117 | #elif defined(XP_MACOSX) |
michael@0 | 118 | typedef task_t ProcessHandle; |
michael@0 | 119 | typedef mach_port_t ThreadId; |
michael@0 | 120 | #else |
michael@0 | 121 | typedef int ProcessHandle; |
michael@0 | 122 | typedef int ThreadId; |
michael@0 | 123 | #endif |
michael@0 | 124 | |
michael@0 | 125 | // Return the current thread's ID. |
michael@0 | 126 | // |
michael@0 | 127 | // XXX: this is a somewhat out-of-place interface to expose through |
michael@0 | 128 | // crashreporter, but it takes significant work to call sys_gettid() |
michael@0 | 129 | // correctly on Linux and breakpad has already jumped through those |
michael@0 | 130 | // hoops for us. |
michael@0 | 131 | ThreadId CurrentThreadId(); |
michael@0 | 132 | |
michael@0 | 133 | // Create a hang report with two minidumps that are snapshots of the state |
michael@0 | 134 | // of this parent process and |childPid|. The "main" minidump will be the |
michael@0 | 135 | // child process, and this parent process will have the -browser extension. |
michael@0 | 136 | // |
michael@0 | 137 | // Returns true on success. If this function fails, it will attempt to delete |
michael@0 | 138 | // any files that were created. |
michael@0 | 139 | // |
michael@0 | 140 | // The .extra information created will not include an additional_minidumps |
michael@0 | 141 | // annotation: the caller should annotate additional_minidumps with |
michael@0 | 142 | // at least "browser" and perhaps other minidumps attached to this report. |
michael@0 | 143 | bool CreatePairedMinidumps(ProcessHandle childPid, |
michael@0 | 144 | ThreadId childBlamedThread, |
michael@0 | 145 | nsIFile** childDump); |
michael@0 | 146 | |
michael@0 | 147 | // Create an additional minidump for a child of a process which already has |
michael@0 | 148 | // a minidump (|parentMinidump|). |
michael@0 | 149 | // The resulting dump will get the id of the parent and use the |name| as |
michael@0 | 150 | // an extension. |
michael@0 | 151 | bool CreateAdditionalChildMinidump(ProcessHandle childPid, |
michael@0 | 152 | ThreadId childBlamedThread, |
michael@0 | 153 | nsIFile* parentMinidump, |
michael@0 | 154 | const nsACString& name); |
michael@0 | 155 | |
michael@0 | 156 | # if defined(XP_WIN32) || defined(XP_MACOSX) |
michael@0 | 157 | // Parent-side API for children |
michael@0 | 158 | const char* GetChildNotificationPipe(); |
michael@0 | 159 | |
michael@0 | 160 | #ifdef MOZ_CRASHREPORTER_INJECTOR |
michael@0 | 161 | // Inject a crash report client into an arbitrary process, and inform the |
michael@0 | 162 | // callback object when it crashes. Parent process only. |
michael@0 | 163 | |
michael@0 | 164 | class InjectorCrashCallback |
michael@0 | 165 | { |
michael@0 | 166 | public: |
michael@0 | 167 | InjectorCrashCallback() { } |
michael@0 | 168 | |
michael@0 | 169 | /** |
michael@0 | 170 | * Inform the callback of a crash. The client code should call |
michael@0 | 171 | * TakeMinidumpForChild to remove it from the PID mapping table. |
michael@0 | 172 | * |
michael@0 | 173 | * The callback will not be fired if the client has already called |
michael@0 | 174 | * TakeMinidumpForChild for this process ID. |
michael@0 | 175 | */ |
michael@0 | 176 | virtual void OnCrash(DWORD processID) = 0; |
michael@0 | 177 | }; |
michael@0 | 178 | |
michael@0 | 179 | // This method implies OOPInit |
michael@0 | 180 | void InjectCrashReporterIntoProcess(DWORD processID, InjectorCrashCallback* cb); |
michael@0 | 181 | void UnregisterInjectorCallback(DWORD processID); |
michael@0 | 182 | #endif |
michael@0 | 183 | |
michael@0 | 184 | // Child-side API |
michael@0 | 185 | bool SetRemoteExceptionHandler(const nsACString& crashPipe); |
michael@0 | 186 | |
michael@0 | 187 | # elif defined(XP_LINUX) |
michael@0 | 188 | // Parent-side API for children |
michael@0 | 189 | |
michael@0 | 190 | // Set the outparams for crash reporter server's fd (|childCrashFd|) |
michael@0 | 191 | // and the magic fd number it should be remapped to |
michael@0 | 192 | // (|childCrashRemapFd|) before exec() in the child process. |
michael@0 | 193 | // |SetRemoteExceptionHandler()| in the child process expects to find |
michael@0 | 194 | // the server at |childCrashRemapFd|. Return true iff successful. |
michael@0 | 195 | // |
michael@0 | 196 | // If crash reporting is disabled, both outparams will be set to -1 |
michael@0 | 197 | // and |true| will be returned. |
michael@0 | 198 | bool CreateNotificationPipeForChild(int* childCrashFd, int* childCrashRemapFd); |
michael@0 | 199 | |
michael@0 | 200 | // Child-side API |
michael@0 | 201 | bool SetRemoteExceptionHandler(); |
michael@0 | 202 | |
michael@0 | 203 | #endif // XP_WIN32 |
michael@0 | 204 | |
michael@0 | 205 | bool UnsetRemoteExceptionHandler(); |
michael@0 | 206 | |
michael@0 | 207 | #if defined(MOZ_WIDGET_ANDROID) |
michael@0 | 208 | // Android builds use a custom library loader, so /proc/<pid>/maps |
michael@0 | 209 | // will just show anonymous mappings for all the non-system |
michael@0 | 210 | // shared libraries. This API is to work around that by providing |
michael@0 | 211 | // info about the shared libraries that are mapped into these anonymous |
michael@0 | 212 | // mappings. |
michael@0 | 213 | void AddLibraryMapping(const char* library_name, |
michael@0 | 214 | uintptr_t start_address, |
michael@0 | 215 | size_t mapping_length, |
michael@0 | 216 | size_t file_offset); |
michael@0 | 217 | |
michael@0 | 218 | #endif |
michael@0 | 219 | } |
michael@0 | 220 | |
michael@0 | 221 | #endif /* nsExceptionHandler_h__ */ |