diff options
author | Evgeny Pavlov <lucenticus@gmail.com> | 2017-01-20 14:59:34 +0300 |
---|---|---|
committer | Jan Vorlicek <janvorli@microsoft.com> | 2017-01-20 12:59:34 +0100 |
commit | 4ac7fe064c2e57c818f565ba2c5192bc73250bf4 (patch) | |
tree | eb110175facbd5b172044e0d6f3ce8024dc6862b | |
parent | d17e8c5f587fd8971dd61c2f282d98d395b5e4fc (diff) | |
download | coreclr-4ac7fe064c2e57c818f565ba2c5192bc73250bf4.tar.gz coreclr-4ac7fe064c2e57c818f565ba2c5192bc73250bf4.tar.bz2 coreclr-4ac7fe064c2e57c818f565ba2c5192bc73250bf4.zip |
[GDB-JIT][Linux] Fix incorrect displaying of (s)byte and char in lldb (#9022)
* [GDB-JIT] Initial support of typedef for correct displaying 'byte' and 'sbyte'
* [GDB-JIT] Add char typedef to show correct type in lldb
* Code cleanup
-rw-r--r-- | src/vm/gdbjit.cpp | 71 | ||||
-rw-r--r-- | src/vm/gdbjit.h | 37 |
2 files changed, 103 insertions, 5 deletions
diff --git a/src/vm/gdbjit.cpp b/src/vm/gdbjit.cpp index 8e728839d6..e7049b5c2f 100644 --- a/src/vm/gdbjit.cpp +++ b/src/vm/gdbjit.cpp @@ -30,11 +30,16 @@ GetTypeInfoFromTypeHandle(TypeHandle typeHandle, NotifyGdb::PTK_TypeInfoMap pTyp CorElementType corType = typeHandle.GetSignatureCorElementType(); switch (corType) { - case ELEMENT_TYPE_VOID: - case ELEMENT_TYPE_BOOLEAN: - case ELEMENT_TYPE_CHAR: case ELEMENT_TYPE_I1: case ELEMENT_TYPE_U1: + case ELEMENT_TYPE_CHAR: + typeInfo = new (nothrow) ByteTypeInfo(typeHandle, CorElementTypeToDWEncoding[corType]); + if (typeInfo == nullptr) + return nullptr; + typeInfo->m_type_size = CorTypeInfo::Size(corType); + break; + case ELEMENT_TYPE_VOID: + case ELEMENT_TYPE_BOOLEAN: case ELEMENT_TYPE_I2: case ELEMENT_TYPE_U2: case ELEMENT_TYPE_I4: @@ -678,8 +683,7 @@ const unsigned char AbbrevTable[] = { 2, DW_TAG_base_type, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_encoding, DW_FORM_data1, DW_AT_byte_size, DW_FORM_data1, 0, 0, - 3, DW_TAG_typedef, DW_CHILDREN_no, - DW_AT_name, DW_FORM_strp, DW_AT_decl_file, DW_FORM_data1, DW_AT_decl_line, DW_FORM_data1, + 3, DW_TAG_typedef, DW_CHILDREN_no, DW_AT_name, DW_FORM_strp, DW_AT_type, DW_FORM_ref4, 0, 0, 4, DW_TAG_subprogram, DW_CHILDREN_yes, @@ -893,6 +897,13 @@ struct __attribute__((packed)) DebugInfoVar uint32_t m_var_type; }; +struct __attribute__((packed)) DebugInfoTypeDef +{ + uint8_t m_typedef_abbrev; + uint32_t m_typedef_name; + uint32_t m_typedef_type; +}; + struct __attribute__((packed)) DebugInfoClassType { uint8_t m_type_abbrev; @@ -964,6 +975,56 @@ TypeKey* TypeInfoBase::GetTypeKey() return &typeKey; } +void TypeDefInfo::DumpStrings(char *ptr, int &offset) +{ + if (ptr != nullptr) + { + strcpy(ptr + offset, m_typedef_name); + m_typedef_name_offset = offset; + } + offset += strlen(m_typedef_name) + 1; +} + +void TypeDefInfo::DumpDebugInfo(char *ptr, int &offset) +{ + if (ptr != nullptr) + { + DebugInfoTypeDef buf; + buf.m_typedef_abbrev = 3; + buf.m_typedef_name = m_typedef_name_offset; + buf.m_typedef_type = offset + sizeof(DebugInfoTypeDef); + m_typedef_type_offset = offset; + + memcpy(ptr + offset, + &buf, + sizeof(DebugInfoTypeDef)); + } + + offset += sizeof(DebugInfoTypeDef); +} + +void ByteTypeInfo::DumpStrings(char* ptr, int& offset) +{ + PrimitiveTypeInfo::DumpStrings(ptr, offset); + m_typedef_info->m_typedef_name = new (nothrow) char[strlen(m_type_name) + 1]; + if (strcmp(m_type_name, "System.Byte") == 0) + strcpy(m_typedef_info->m_typedef_name, "byte"); + else if (strcmp(m_type_name, "System.SByte") == 0) + strcpy(m_typedef_info->m_typedef_name, "sbyte"); + else if (strcmp(m_type_name, "char16_t") == 0) + strcpy(m_typedef_info->m_typedef_name, "char"); + else + strcpy(m_typedef_info->m_typedef_name, m_type_name); + m_typedef_info->DumpStrings(ptr, offset); +} + +void ByteTypeInfo::DumpDebugInfo(char *ptr, int &offset) +{ + m_typedef_info->DumpDebugInfo(ptr, offset); + m_type_offset = m_typedef_info->m_typedef_type_offset; + PrimitiveTypeInfo::DumpDebugInfo(ptr, offset); +} + void PrimitiveTypeInfo::DumpDebugInfo(char* ptr, int& offset) { if (m_type_offset != 0) diff --git a/src/vm/gdbjit.h b/src/vm/gdbjit.h index 3160eccf57..19ece0180a 100644 --- a/src/vm/gdbjit.h +++ b/src/vm/gdbjit.h @@ -184,6 +184,43 @@ public: int m_type_encoding; }; +class TypeDefInfo : public DwarfDumpable +{ +public: + TypeDefInfo(char *typedef_name,int typedef_type): + m_typedef_name(typedef_name), m_typedef_type(typedef_type) {} + void DumpStrings(char* ptr, int& offset) override; + void DumpDebugInfo(char* ptr, int& offset) override; + virtual ~TypeDefInfo() + { + if (m_typedef_name != nullptr) + { + delete [] m_typedef_name; + } + } + char *m_typedef_name; + int m_typedef_type; + int m_typedef_type_offset; + int m_typedef_name_offset; +}; + +class ByteTypeInfo : public PrimitiveTypeInfo +{ +public: + ByteTypeInfo(TypeHandle typeHandle, int encoding) : PrimitiveTypeInfo(typeHandle, encoding) + { + m_typedef_info = new (nothrow) TypeDefInfo(nullptr, 0); + } + virtual ~ByteTypeInfo() + { + delete m_typedef_info; + } + void DumpDebugInfo(char* ptr, int& offset) override; + void DumpStrings(char* ptr, int& offset) override; + + TypeDefInfo* m_typedef_info; +}; + class RefTypeInfo: public TypeInfoBase { public: |