Correctly handle non-C-style arrays in c_get_string
authorTom Tromey <tromey@adacore.com>
Thu, 25 Apr 2019 18:14:58 +0000 (12:14 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 8 May 2019 16:20:06 +0000 (10:20 -0600)
commit80e55b132940813fa454da2592a31db6c8af85f1
treeebb1b1c183fa1bcec144be4479fd601864131352
parent9d3421afbb9f3cfc8e67366ba75ea12ed8f732a3
Correctly handle non-C-style arrays in c_get_string

A user here noticed that the Python Value.string method did not work
for Ada arrays.  I tracked this down to an oddity in value_as_address
-- namely, it calls coerce_array, but that function will not force
array coercion when the language has c_style_arrays=false, as Ada
does.

This patch fixes the problem by changing c_get_string so that arrays
take the "in GDB's memory" branch.  The actual patch is somewhat more
complicated than you might think, because the caller can request more
array elements than the type allows.  This is normal when the type is
using the C struct hack.

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-05-08  Tom Tromey  <tromey@adacore.com>

* c-lang.c (c_get_string): Handle non-C-style arrays.

gdb/testsuite/ChangeLog
2019-05-08  Tom Tromey  <tromey@adacore.com>

* gdb.python/py-value.exp (test_value_in_inferior): Add Ada test.
gdb/ChangeLog
gdb/c-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-value.exp
This page took 0.027572 seconds and 4 git commands to generate.