From: Joel Brobecker Date: Thu, 3 Mar 2011 03:55:31 +0000 (+0000) Subject: py-inferior.exp: Avoid searching pattern beyond buffer X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c171f8549ca05c866ec967d76e7f4575a0465643;p=binutils-gdb.git py-inferior.exp: Avoid searching pattern beyond buffer gdb/testsuite/ChangeLog: * gdb.python/py-inferior.exp: Avoid searching pattern beyond end of buffer. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index ac9bd0e13ff..bce369f580b 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-03-03 Joel Brobecker + + * gdb.python/py-inferior.exp: Avoid searching pattern beyond + end of buffer. + 2011-03-02 Joel Brobecker * gdb.python/py-inferior.exp: Use gdb_test_no_output instead of diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp index c219117f11f..138c0fb19d2 100644 --- a/gdb/testsuite/gdb.python/py-inferior.exp +++ b/gdb/testsuite/gdb.python/py-inferior.exp @@ -171,15 +171,15 @@ set CHUNK_SIZE 16000 ; gdb_test_no_output "set *(int32_t*) &search_buf\[0*${CHUNK_SIZE}+100\] = 0x12345678" gdb_test_no_output "set *(int32_t*) &search_buf\[1*${CHUNK_SIZE}+100\] = 0x12345678" gdb_test_no_output "py start_addr = gdb.selected_frame ().read_var ('search_buf')" -gdb_test_no_output "py length = gdb.selected_frame ().read_var ('search_buf_size')" +gdb_test_no_output "py end_addr = start_addr + gdb.selected_frame ().read_var ('search_buf_size')" gdb_test_no_output "py pattern = pack('${python_pack_char}I', 0x12345678)" -gdb_test_no_output "py first = gdb.inferiors()\[0\].search_memory (start_addr,length, pattern)" +gdb_test_no_output "py first = gdb.inferiors()\[0\].search_memory (start_addr,end_addr - start_addr, pattern)" gdb_test "py print first" "${one_pattern_found}" "search spanning large range 1st result" gdb_test_no_output "py start_addr = first + 1" -gdb_test_no_output "py second = gdb.inferiors()\[0\].search_memory (start_addr, length, pattern)" +gdb_test_no_output "py second = gdb.inferiors()\[0\].search_memory (start_addr, end_addr - start_addr, pattern)" gdb_test "py print second" "${one_pattern_found}" "search spanning large range 2nd result" gdb_test_no_output "py start_addr = second + 1" -gdb_test_no_output "py third = gdb.inferiors()\[0\].search_memory (start_addr, length, pattern)" +gdb_test_no_output "py third = gdb.inferiors()\[0\].search_memory (start_addr, end_addr - start_addr, pattern)" gdb_test "py print third" "${pattern_not_found}" "search spanning large range 3rd result" # For native targets, test a pattern straddling a chunk boundary. @@ -188,6 +188,6 @@ if [isnative] { gdb_test_no_output "set *(int32_t*) &search_buf\[${CHUNK_SIZE}-1\] = 0xfdb97531" gdb_test_no_output "py pattern = pack('${python_pack_char}I', 0xfdb97531)" gdb_test_no_output "py start_addr = gdb.selected_frame ().read_var ('search_buf')" - gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, length, pattern)" \ + gdb_test "py print gdb.inferiors()\[0\].search_memory (start_addr, end_addr - start_addr, pattern)" \ "${one_pattern_found}" "find pattern straddling chunk boundary" }