]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Fix gdb.base/corefile2.exp regression when running Docker/AUFS
authorLuis Machado <luis.machado@linaro.org>
Wed, 14 Oct 2020 22:11:09 +0000 (19:11 -0300)
committerLuis Machado <luis.machado@linaro.org>
Thu, 22 Oct 2020 13:59:25 +0000 (10:59 -0300)
commit1bd57575dcb693d7fbda49bee44e81c20d1be7bf
tree8a854c43b2d80104cce3d5970e35638a227178f1
parentc6d47bff77db79b1ad99cd7911f7e1807874be55
Fix gdb.base/corefile2.exp regression when running Docker/AUFS

The following failures started showing up after commit
bb2a67773c - "Use a std::vector in target_section_table":

FAIL: gdb.base/corefile2.exp: renamed binfile: print/x mbuf_ro[0]@4
FAIL: gdb.base/corefile2.exp: renamed binfile: print/x mbuf_ro[pagesize-4]@4
FAIL: gdb.base/corefile2.exp: renamed binfile: print/x mbuf_ro[-3]@6
FAIL: gdb.base/corefile2.exp: renamed binfile: print/x mbuf_rw[pagesize-3]@6
FAIL: gdb.base/corefile2.exp: renamed binfile: print/x mbuf_ro[pagesize-3]@6

I tracked it down to a problem in core_target::xfer_partial, at this point:

if (!m_core_file_mappings.empty ())
  xfer_status = xfer_memory_via_mappings (readbuf, writebuf, offset,
  len, xfered_len);
else
  xfer_status = this->beneath ()->xfer_partial (object, annex, readbuf,
writebuf, offset, len,
xfered_len);

It seems commit bb2a67773c uncovered a latent bug when handling a particular
case where things are running within a Docker container using the AUFS storage
driver.

When building the file mappings for a core file, we call
gdbarch_read_core_file_mappings, which in turn passes a couple lambda
callbacks. One pre-loop and one in-loop.

The catch is that commit bb2a67773c reworked the pre-loop lambda and
made it do nothing. Before that commit, we always allocated
m_core_file_mappings in that lambda.

Now, when calling the in-loop lambda, we don't touch m_core_file_mappings
because the bfd is nullptr (given Docker leaks the host system path, and that
file doesn't exist within the container itself).

So, instead, we add an entry to the m_core_unavailable_mappings vector.

When we reach core_target::xfer_partial, we're only checking for an empty
m_core_file_mappings. Given it is now empty, we take the path of reading
the contents from the file, not the core file. This reads back unexpected
results.

The following patch fixes this by also checking for
m_core_unavailable_mappings, given core_target::xfer_memory_via_mappings
already handles the Docker/AUFS situation.

gdb/ChangeLog:

2020-10-22  Luis Machado  <luis.machado@linaro.org>

* corelow.c (core_target::xfer_partial): Also check for an empty
m_core_unavailable_mappings vector.
gdb/ChangeLog
gdb/corelow.c