mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 09:22:44 +00:00 
			
		
		
		
	LibJS/JIT: Produce & register an ELF image for GDB JIT Interface
Using the code that it has just produced, the JIT::Compiler can build an ELF image so that we can attach meaningful symbols to JITted code, and thus enable GDB to display more information about the code that we're running.
This commit is contained in:
		
							parent
							
								
									149e382735
								
							
						
					
					
						commit
						f0b984567a
					
				
					 3 changed files with 20 additions and 3 deletions
				
			
		|  | @ -6,6 +6,7 @@ | |||
|  */ | ||||
| 
 | ||||
| #include <AK/BinarySearch.h> | ||||
| #include <LibJIT/GDB.h> | ||||
| #include <LibJS/Bytecode/Interpreter.h> | ||||
| #include <LibJS/JIT/NativeExecutable.h> | ||||
| #include <LibJS/Runtime/VM.h> | ||||
|  | @ -14,10 +15,11 @@ | |||
| 
 | ||||
| namespace JS::JIT { | ||||
| 
 | ||||
| NativeExecutable::NativeExecutable(void* code, size_t size, Vector<BytecodeMapping> mapping) | ||||
| NativeExecutable::NativeExecutable(void* code, size_t size, Vector<BytecodeMapping> mapping, Optional<FixedArray<u8>> gdb_object) | ||||
|     : m_code(code) | ||||
|     , m_size(size) | ||||
|     , m_mapping(move(mapping)) | ||||
|     , m_gdb_object(move(gdb_object)) | ||||
| { | ||||
|     // Translate block index to instruction address, so the native code can just jump to it.
 | ||||
|     for (auto const& entry : m_mapping) { | ||||
|  | @ -28,10 +30,14 @@ NativeExecutable::NativeExecutable(void* code, size_t size, Vector<BytecodeMappi | |||
|             m_block_entry_points.append(bit_cast<FlatPtr>(m_code) + entry.native_offset); | ||||
|         } | ||||
|     } | ||||
|     if (m_gdb_object.has_value()) | ||||
|         ::JIT::GDB::register_into_gdb(m_gdb_object.value().span()); | ||||
| } | ||||
| 
 | ||||
| NativeExecutable::~NativeExecutable() | ||||
| { | ||||
|     if (m_gdb_object.has_value()) | ||||
|         ::JIT::GDB::unregister_from_gdb(m_gdb_object.value().span()); | ||||
|     munmap(m_code, m_size); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Jesús (gsus) Lapastora
						Jesús (gsus) Lapastora