Re: [PATCH] Make target_read_alloc & al return vectors

Pedro Alves
2018-04-16T20:04:20Z

Hi Simon,

I noticed this recent regression:

PASS: gdb.threads/gcore-stale-thread.exp: successfully compiled posix threads test case
PASS: gdb.threads/gcore-stale-thread.exp: set non-stop on
PASS: gdb.threads/gcore-stale-thread.exp: continue to breakpoint: break-here
-PASS: gdb.threads/gcore-stale-thread.exp: save a corefile
+UNSUPPORTED: gdb.threads/gcore-stale-thread.exp: save a corefile
PASS: gdb.threads/gcore-stale-thread.exp: exited thread is current due to non-stop

and bisection points at:
9018be22e02 ("Make target_read_alloc & al return vectors")

diff of gdb.log shows:

gcore gdb/testsuite/outputs/gdb.threads/gcore-stale-thread/gcore-stale-thread.core
-Saved corefile gdb/testsuite/outputs/gdb.threads/gcore-stale-thread/gcore-stale-thread.core
-(gdb) PASS: gdb.threads/gcore-stale-thread.exp: save a corefile
+Target does not support core file generation.
+(gdb) UNSUPPORTED: gdb.threads/gcore-stale-thread.exp: save a corefile

Thanks,
Pedro Alves

On 03/22/2018 04:03 AM, Simon Marchi wrote:
> This patch started by changing target_read_alloc_1 to return a
> byte_vector, to avoid manual memory management (in target_read_alloc_1
> and in the callers). To communicate failures to the callers, it
> actually returns a gdb::optional<gdb::byte_vector>.
>
> Adjusting target_read_stralloc was a bit more tricky, since it wants to
> return a buffer of char, and not gdb_byte. Since you can't just cast a
> gdb::byte_vector into a gdb::def_vector<char>, I made
> target_read_alloc_1 templated, so both versions (that return vectors of
> gdb_byte and char) are generated. Since target_read_stralloc now
> returns a gdb::char_vector instead of a gdb::unique_xmalloc_ptr<char>, a
> few callers need to be adjusted.