11cb0ef41Sopenharmony_ci// Copyright 2010 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#ifndef V8_DIAGNOSTICS_GDB_JIT_H_ 61cb0ef41Sopenharmony_ci#define V8_DIAGNOSTICS_GDB_JIT_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include "src/base/address-region.h" 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci// 111cb0ef41Sopenharmony_ci// GDB has two ways of interacting with JIT code. With the "JIT compilation 121cb0ef41Sopenharmony_ci// interface", V8 can tell GDB when it emits JIT code. Unfortunately to do so, 131cb0ef41Sopenharmony_ci// it has to create platform-native object files, possibly with platform-native 141cb0ef41Sopenharmony_ci// debugging information. Currently only ELF and Mach-O are supported, which 151cb0ef41Sopenharmony_ci// limits this interface to Linux and Mac OS. This JIT compilation interface 161cb0ef41Sopenharmony_ci// was introduced in GDB 7.0. V8 support can be enabled with the --gdbjit flag. 171cb0ef41Sopenharmony_ci// 181cb0ef41Sopenharmony_ci// The other way that GDB can know about V8 code is via the "custom JIT reader" 191cb0ef41Sopenharmony_ci// interface, in which a GDB extension parses V8's private data to determine the 201cb0ef41Sopenharmony_ci// function, file, and line of a JIT frame, and how to unwind those frames. 211cb0ef41Sopenharmony_ci// This interface was introduced in GDB 7.6. This interface still relies on V8 221cb0ef41Sopenharmony_ci// to register its code via the JIT compilation interface, but doesn't require 231cb0ef41Sopenharmony_ci// that V8 create ELF images. Support will be added for this interface in the 241cb0ef41Sopenharmony_ci// future. 251cb0ef41Sopenharmony_ci// 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_cinamespace v8 { 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_cistruct JitCodeEvent; 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_cinamespace internal { 321cb0ef41Sopenharmony_cinamespace GDBJITInterface { 331cb0ef41Sopenharmony_ci#ifdef ENABLE_GDB_JIT_INTERFACE 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci// JitCodeEventHandler that creates ELF/Mach-O objects and registers them with 361cb0ef41Sopenharmony_ci// GDB. 371cb0ef41Sopenharmony_civoid EventHandler(const v8::JitCodeEvent* event); 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ci// Expose some functions for unittests. These only exercise the logic to add 401cb0ef41Sopenharmony_ci// AddressRegion to CodeMap, and checking for overlap. It does not touch the 411cb0ef41Sopenharmony_ci// actual JITCodeEntry at all. 421cb0ef41Sopenharmony_ciV8_EXPORT_PRIVATE void AddRegionForTesting(const base::AddressRegion region); 431cb0ef41Sopenharmony_ciV8_EXPORT_PRIVATE void ClearCodeMapForTesting(); 441cb0ef41Sopenharmony_ciV8_EXPORT_PRIVATE size_t 451cb0ef41Sopenharmony_ciNumOverlapEntriesForTesting(const base::AddressRegion region); 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_ci#endif 481cb0ef41Sopenharmony_ci} // namespace GDBJITInterface 491cb0ef41Sopenharmony_ci} // namespace internal 501cb0ef41Sopenharmony_ci} // namespace v8 511cb0ef41Sopenharmony_ci 521cb0ef41Sopenharmony_ci#endif // V8_DIAGNOSTICS_GDB_JIT_H_ 53