mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-27 14:02:07 +00:00 
			
		
		
		
	 ac53569bd1
			
		
	
	
		ac53569bd1
		
	
	
	
	
		
			
			These forms were introduced in DWARF5, and have a fair deal of advantages over the more traditional encodings: they reduce the size of the binary and the number of relocations. GCC does not emit these with `-g1` by default, but Clang does at all debug levels.
		
			
				
	
	
		
			49 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Daniel Bertalan <dani@danielbertalan.dev>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include "AttributeValue.h"
 | |
| #include "CompilationUnit.h"
 | |
| 
 | |
| namespace Debug::Dwarf {
 | |
| 
 | |
| FlatPtr AttributeValue::as_addr() const
 | |
| {
 | |
|     switch (m_form) {
 | |
|     case AttributeDataForm::Addr:
 | |
|         return m_data.as_addr;
 | |
|     case AttributeDataForm::AddrX:
 | |
|     case AttributeDataForm::AddrX1:
 | |
|     case AttributeDataForm::AddrX2:
 | |
|     case AttributeDataForm::AddrX3:
 | |
|     case AttributeDataForm::AddrX4: {
 | |
|         auto index = m_data.as_unsigned;
 | |
|         return m_compilation_unit->get_address(index);
 | |
|     }
 | |
|     default:
 | |
|         VERIFY_NOT_REACHED();
 | |
|     }
 | |
| }
 | |
| 
 | |
| char const* AttributeValue::as_string() const
 | |
| {
 | |
|     switch (m_form) {
 | |
|     case AttributeDataForm::String:
 | |
|     case AttributeDataForm::StringPointer:
 | |
|     case AttributeDataForm::LineStrP:
 | |
|         return m_data.as_string;
 | |
|     case AttributeDataForm::StrX:
 | |
|     case AttributeDataForm::StrX1:
 | |
|     case AttributeDataForm::StrX2:
 | |
|     case AttributeDataForm::StrX3:
 | |
|     case AttributeDataForm::StrX4: {
 | |
|         auto index = m_data.as_unsigned;
 | |
|         return m_compilation_unit->get_string(index);
 | |
|     }
 | |
|     default:
 | |
|         VERIFY_NOT_REACHED();
 | |
|     }
 | |
| }
 | |
| }
 |