jankratochvil created this revision. jankratochvil added reviewers: dblaikie, davide. jankratochvil added a project: LLDB. Herald added a reviewer: jdoerfert. Herald added a subscriber: sstefan1. jankratochvil retitled this revision from "Fix SLEB128 decoding" to "[lldb] Fix SLEB128 decoding". davide added reviewers: clayborg, labath. davide added a comment.
Greg & Pavel might have opinions on this patch. I'm not qualified to review it. Bug 46181 <https://bugs.llvm.org/show_bug.cgi?id=46181> shows SLEB128 `0xED9A924C00011151` decoded as `0xffffffff80011151`. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D81119 Files: lldb/source/Utility/DataExtractor.cpp lldb/test/Shell/SymbolFile/DWARF/dwarf-sleb128.s
Index: lldb/test/Shell/SymbolFile/DWARF/dwarf-sleb128.s =================================================================== --- /dev/null +++ lldb/test/Shell/SymbolFile/DWARF/dwarf-sleb128.s @@ -0,0 +1,181 @@ +# This tests that lldb is able to process 64-bit wide negative SLEB128. + +# REQUIRES: lld, x86 + +# RUN: llvm-mc -g -dwarf-version=5 -triple x86_64-unknown-linux-gnu %s -filetype=obj > %t.o +# RUN: ld.lld -m elf_x86_64 %t.o -o %t +# RUN: %lldb %t -o "p/x magic64" -o exit | FileCheck %s + +# CHECK: (const long) $0 = 0xed9a924c00011151 + +# It is built from this source with a few #-marked patched lines: +# static const long magic64 = 0xED9A924C00011151; +# int main(void) { return magic64; } + + .text + .file "lldb46181c.c" + .file 1 "" "lldb46181c.c" + .globl main # -- Begin function main + .p2align 4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin0: + .loc 1 2 0 # lldb46181c.c:2:0 + .cfi_startproc +# %bb.0: + .loc 1 2 18 prologue_end # lldb46181c.c:2:18 + movl $69969, %eax # imm = 0x11151 + retq +.Ltmp0: +.Lfunc_end0: + .size main, .Lfunc_end0-main + .cfi_endproc + # -- End function + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 10.0.0 (Fedora 10.0.0-1.fc32)" # string offset=0 +.Linfo_string1: + .asciz "lldb46181c.c" # string offset=44 +.Linfo_string2: + .asciz "" # string offset=57 +.Linfo_string3: + .asciz "magic64" # string offset=74 +.Linfo_string4: + .asciz "long int" # string offset=82 +.Linfo_string5: + .asciz "main" # string offset=91 +.Linfo_string6: + .asciz "int" # string offset=96 + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 52 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line +# .byte 11 # DW_FORM_data1 + .byte 5 # DW_FORM_data2 + .byte 28 # DW_AT_const_value +# .byte 15 # DW_FORM_udata + .byte 13 # DW_FORM_sdata + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 38 # DW_TAG_const_type + .byte 0 # DW_CHILDREN_no + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 4 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 62 # DW_AT_encoding + .byte 11 # DW_FORM_data1 + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 5 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 0 # DW_CHILDREN_no + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 64 # DW_AT_frame_base + .byte 24 # DW_FORM_exprloc + .ascii "\227B" # DW_AT_GNU_all_call_sites + .byte 25 # DW_FORM_flag_present + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 39 # DW_AT_prototyped + .byte 25 # DW_FORM_flag_present + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x61 DW_TAG_compile_unit + .long .Linfo_string0 # DW_AT_producer + .short 12 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long .Lline_table_start0 # DW_AT_stmt_list + .long .Linfo_string2 # DW_AT_comp_dir + .quad .Lfunc_begin0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .byte 2 # Abbrev [2] 0x2a:0x15 DW_TAG_variable + .long .Linfo_string3 # DW_AT_name + .long 63 # DW_AT_type + .byte 1 # DW_AT_decl_file +# .byte 1 # DW_AT_decl_line + .short 1 # DW_AT_decl_line +# .ascii "\321\242\204\200\300\311\244\315\355\001" # DW_AT_const_value + .ascii "\321\242\204\200\300\311\244\315m" # DW_AT_const_value - sdata + .byte 3 # Abbrev [3] 0x3f:0x5 DW_TAG_const_type + .long 68 # DW_AT_type + .byte 4 # Abbrev [4] 0x44:0x7 DW_TAG_base_type + .long .Linfo_string4 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 8 # DW_AT_byte_size + .byte 5 # Abbrev [5] 0x4b:0x19 DW_TAG_subprogram + .quad .Lfunc_begin0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 87 + # DW_AT_GNU_all_call_sites + .long .Linfo_string5 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 2 # DW_AT_decl_line + # DW_AT_prototyped + .long 100 # DW_AT_type + # DW_AT_external + .byte 4 # Abbrev [4] 0x64:0x7 DW_TAG_base_type + .long .Linfo_string6 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 0 # End Of Children Mark +.Ldebug_info_end0: + .ident "clang version 10.0.0 (Fedora 10.0.0-1.fc32)" + .section ".note.GNU-stack","",@progbits + .addrsig + .section .debug_line,"",@progbits +.Lline_table_start0: Index: lldb/source/Utility/DataExtractor.cpp =================================================================== --- lldb/source/Utility/DataExtractor.cpp +++ lldb/source/Utility/DataExtractor.cpp @@ -931,7 +931,7 @@ // Sign bit of byte is 2nd high order bit (0x40) if (shift < size && (byte & 0x40)) - result |= -(1 << shift); + result |= -(static_cast<int64_t>(1) << shift); *offset_ptr += bytecount; return result;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits