Complete the implementation + tests of compact common encoding lookup.

This commit is contained in:
Landon Fuller 2013-03-14 15:26:28 -04:00
Родитель 594dbc47b8
Коммит 92b0e45319
7 изменённых файлов: 28 добавлений и 16 удалений

Просмотреть файл

@ -4,6 +4,7 @@
// Keep in sync with PLCrashAsyncCompactUnwindEncodingTests
#define BASE_PC 0
#define PC_COMPACT_COMMON (BASE_PC+1)
#define PC_COMPACT_COMMON_ENCODING (UNWIND_X86_64_MODE_DWARF | 0xFF)
struct unwind_sect_compressed_page {
@ -50,7 +51,7 @@ struct unwind_sect data __attribute__((section("__TEXT,__unwind_info"))) = {
},
.common_encodings = {
0x0, // PC_COMPACT_COMMON
PC_COMPACT_COMMON_ENCODING,
},
.regular_page_1 = {
@ -73,6 +74,7 @@ struct unwind_sect data __attribute__((section("__TEXT,__unwind_info"))) = {
.entryCount = 1
},
.entries = {
/* Note that these are offsets from the first-level functionOffset */
COMPRESSED(0, 0)
},
},

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -136,13 +136,17 @@ plcrash_error_t plcrash_async_cfe_reader_init (plcrash_async_cfe_reader_t *reade
#define VERIFY_SIZE_T(_etype, _ecount) (SIZE_MAX / sizeof(_etype) < _ecount)
/**
* TODO
* Return the compact frame encoding entry for @a pc via @a encoding, if available.
*
* @param reader The initialized CFE reader.
* @param reader The initialized CFE reader which will be searched for the entry.
* @param pc The PC value to search for within the CFE data. Note that this value must be relative to
* the target Mach-O image's __TEXT vmaddr.
* @param encoding On success, will be populated with the compact frame encoding entry.
*
* @return Returns PLFRAME_ESUCCCESS on success, or one of the remaining error codes if a CFE parsing error occurs. If
* the entry can not be found, PLFRAME_ENOTFOUND will be returned.
*/
plcrash_error_t plcrash_async_cfe_reader_find_pc (plcrash_async_cfe_reader_t *reader, pl_vm_address_t pc) {
plcrash_error_t plcrash_async_cfe_reader_find_pc (plcrash_async_cfe_reader_t *reader, pl_vm_address_t pc, uint32_t *encoding) {
const plcrash_async_byteorder_t *byteorder = reader->byteorder;
const pl_vm_address_t base_addr = plcrash_async_mobject_base_address(reader->mobj);
@ -266,18 +270,19 @@ plcrash_error_t plcrash_async_cfe_reader_find_pc (plcrash_async_cfe_reader_t *re
/* Find the actual encoding */
uint32_t c_entry = byteorder->swap32(*c_entry_ptr);
uint8_t c_encoding_idx = UNWIND_INFO_COMPRESSED_ENTRY_ENCODING_INDEX(c_entry);
if (c_encoding_idx < common_enc_count) {
/* Found in the common table */
} else {
// TODO
__builtin_trap();
/* Handle common table entries */
if (c_encoding_idx < common_enc_count) {
/* Found in the common table. The offset is verified as being within the mapped memory range by
* the < common_enc_count check above. */
*encoding = common_enc[c_encoding_idx];
return PLCRASH_ESUCCESS;
}
// TODO
__builtin_trap();
PLCF_DEBUG("FOUND func_offset=%" PRIx32 " idx = %" PRIx32, base_foffset + UNWIND_INFO_COMPRESSED_ENTRY_FUNC_OFFSET(c_entry), UNWIND_INFO_COMPRESSED_ENTRY_ENCODING_INDEX(c_entry));
break;
return PLCRASH_ESUCCESS;
}
default:
@ -285,7 +290,9 @@ plcrash_error_t plcrash_async_cfe_reader_find_pc (plcrash_async_cfe_reader_t *re
return PLCRASH_EINVAL;
}
return PLCRASH_ESUCCESS;
// Unreachable
__builtin_trap();
return PLCRASH_ENOTFOUND;
}
/**

Просмотреть файл

@ -57,7 +57,7 @@ typedef struct plcrash_async_cfe_reader {
plcrash_error_t plcrash_async_cfe_reader_init (plcrash_async_cfe_reader_t *reader, plcrash_async_mobject_t *mobj, cpu_type_t cputype);
plcrash_error_t plcrash_async_cfe_reader_find_pc (plcrash_async_cfe_reader_t *reader, pl_vm_address_t pc);
plcrash_error_t plcrash_async_cfe_reader_find_pc (plcrash_async_cfe_reader_t *reader, pl_vm_address_t pc, uint32_t *encoding);
void plcrash_async_cfe_reader_free (plcrash_async_cfe_reader_t *reader);

Просмотреть файл

@ -51,6 +51,7 @@
/** PC to use for the compact-common test */
#define PC_COMPACT_COMMON (BASE_PC+1)
#define PC_COMPACT_COMMON_ENCODING (UNWIND_X86_64_MODE_DWARF | 0xFF)
/**
* @internal
@ -209,8 +210,10 @@
- (void) testReadCompressedCommonEncoding {
plcrash_error_t err;
err = plcrash_async_cfe_reader_find_pc(&_reader, PC_COMPACT_COMMON);
uint32_t encoding;
err = plcrash_async_cfe_reader_find_pc(&_reader, PC_COMPACT_COMMON, &encoding);
STAssertEquals(PLCRASH_ESUCCESS, err, @"Failed to locate CFE entry");
STAssertEquals(encoding, (uint32_t)PC_COMPACT_COMMON_ENCODING, @"Incorrect encoding returned");
}
@end