thread-configuration.js (2834B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 const { Actor } = require("resource://devtools/shared/protocol.js"); 8 const { 9 threadConfigurationSpec, 10 } = require("resource://devtools/shared/specs/thread-configuration.js"); 11 12 const { SessionDataHelpers } = ChromeUtils.importESModule( 13 "resource://devtools/server/actors/watcher/SessionDataHelpers.sys.mjs", 14 { global: "contextual" } 15 ); 16 const { 17 SUPPORTED_DATA: { THREAD_CONFIGURATION }, 18 } = SessionDataHelpers; 19 20 // List of options supported by this thread configuration actor. 21 /* eslint sort-keys: "error" */ 22 const SUPPORTED_OPTIONS = { 23 // Disable pausing on caught exceptions. 24 ignoreCaughtExceptions: true, 25 // Log the event break points. 26 logEventBreakpoints: true, 27 // Enable debugging asm & wasm. 28 // See https://searchfox.org/mozilla-central/source/js/src/doc/Debugger/Debugger.md#16-26 29 observeAsmJS: true, 30 observeWasm: true, 31 // Enable pausing on exceptions. 32 pauseOnExceptions: true, 33 // Boolean to know if we should display the overlay when pausing 34 pauseOverlay: true, 35 // Should pause all the workers untill thread has attached. 36 pauseWorkersUntilAttach: true, 37 // Include async stack frames when paused. 38 shouldIncludeAsyncLiveFrames: true, 39 // Include previously saved stack frames when paused. 40 shouldIncludeSavedFrames: true, 41 // Controls pausing on debugger statement. 42 // (This is enabled by default if omitted) 43 shouldPauseOnDebuggerStatement: true, 44 // Stop pausing on breakpoints. 45 skipBreakpoints: true, 46 }; 47 /* eslint-disable sort-keys */ 48 49 /** 50 * This actor manages the configuration options which apply to thread actor for all the targets. 51 * 52 * Configuration options should be applied to all concerned targets when the 53 * configuration is updated, and new targets should also be able to read the 54 * flags when they are created. The flags will be forwarded to the WatcherActor 55 * and stored as THREAD_CONFIGURATION data entries. 56 * 57 * @class 58 */ 59 class ThreadConfigurationActor extends Actor { 60 constructor(watcherActor) { 61 super(watcherActor.conn, threadConfigurationSpec); 62 this.watcherActor = watcherActor; 63 } 64 65 async updateConfiguration(configuration) { 66 const configArray = Object.keys(configuration) 67 .filter(key => { 68 if (!SUPPORTED_OPTIONS[key]) { 69 console.warn(`Unsupported option for ThreadConfiguration: ${key}`); 70 return false; 71 } 72 return true; 73 }) 74 .map(key => ({ key, value: configuration[key] })); 75 76 await this.watcherActor.addOrSetDataEntry( 77 THREAD_CONFIGURATION, 78 configArray, 79 "add" 80 ); 81 } 82 } 83 84 exports.ThreadConfigurationActor = ThreadConfigurationActor;