Author: jmolenda Date: Tue Jan 24 19:41:48 2017 New Revision: 293002 URL: http://llvm.org/viewvc/llvm-project?rev=293002&view=rev Log: Jim unintentionally had the gdb-format specifiers falling through after r276132 so that 'x/4b' would print out a series of 4 8-byte quantities. Fix that, add a test case.
<rdar://problem/29930833> Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp lldb/trunk/source/Interpreter/OptionGroupFormat.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py?rev=293002&r1=293001&r2=293002&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py Tue Jan 24 19:41:48 2017 @@ -118,3 +118,20 @@ class MemoryReadTestCase(TestBase): '16', '18', '20']) + + # the gdb format specifier and the size in characters for + # the returned values including the 0x prefix. + variations = [['b', 4], ['h', 6], ['w', 10], ['g', 18]] + for v in variations: + formatter = v[0] + expected_object_length = v[1] + self.runCmd( + "memory read --gdb-format 4%s &my_uint64s" % formatter) + lines = self.res.GetOutput().splitlines() + objects_read = [] + for l in lines: + objects_read.extend(l.split(':')[1].split()) + # Check that we got back 4 0x0000 etc bytes + for o in objects_read: + self.assertTrue (len(o) == expected_object_length) + self.assertTrue(len(objects_read) == 4) Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp?rev=293002&r1=293001&r2=293002&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp Tue Jan 24 19:41:48 2017 @@ -7,12 +7,14 @@ // //===----------------------------------------------------------------------===// #include <stdio.h> +#include <stdint.h> int main (int argc, char const *argv[]) { char my_string[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 0}; double my_double = 1234.5678; int my_ints[] = {2,4,6,8,10,12,14,16,18,20,22}; + uint64_t my_uint64s[] = {0, 1, 2, 3, 4, 5, 6, 7}; printf("my_string=%s\n", my_string); // Set break point at this line. printf("my_double=%g\n", my_double); return 0; Modified: lldb/trunk/source/Interpreter/OptionGroupFormat.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupFormat.cpp?rev=293002&r1=293001&r2=293002&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupFormat.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupFormat.cpp Tue Jan 24 19:41:48 2017 @@ -235,32 +235,36 @@ bool OptionGroupFormat::ParserGDBFormatL m_prev_gdb_format = format_letter; return true; - // Size isn't used for printing instructions, so if a size is specified, and - // the previous format was - // 'i', then we should reset it to the default ('x'). Otherwise we'll - // continue to print as instructions, - // which isn't expected. case 'b': - byte_size = 1; - LLVM_FALLTHROUGH; case 'h': - byte_size = 2; - LLVM_FALLTHROUGH; case 'w': - byte_size = 4; - LLVM_FALLTHROUGH; case 'g': - byte_size = 8; - - m_prev_gdb_size = format_letter; - if (m_prev_gdb_format == 'i') - m_prev_gdb_format = 'x'; - return true; + { + // Size isn't used for printing instructions, so if a size is specified, and + // the previous format was + // 'i', then we should reset it to the default ('x'). Otherwise we'll + // continue to print as instructions, + // which isn't expected. + if (format_letter == 'b') + byte_size = 1; + else if (format_letter == 'h') + byte_size = 2; + else if (format_letter == 'w') + byte_size = 4; + else if (format_letter == 'g') + byte_size = 8; + m_prev_gdb_size = format_letter; + if (m_prev_gdb_format == 'i') + m_prev_gdb_format = 'x'; + return true; + } break; default: break; } + + return false; } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits