/* Read MiniDebugInfo data from an objfile.
- Copyright (C) 2012-2015 Free Software Foundation, Inc.
+ Copyright (C) 2012-2019 Free Software Foundation, Inc.
This file is part of GDB.
#include "symfile.h"
#include "objfiles.h"
#include "gdbcore.h"
+#include <algorithm>
#ifdef HAVE_LIBLZMA
static void *
lzma_open (struct bfd *nbfd, void *open_closure)
{
- asection *section = open_closure;
+ asection *section = (asection *) open_closure;
bfd_size_type size, offset;
lzma_stream_flags options;
gdb_byte footer[LZMA_STREAM_HEADER_SIZE];
gdb_byte *indexdata;
lzma_index *index;
- int ret;
uint64_t memlimit = UINT64_MAX;
struct gdb_lzma_stream *lstream;
size_t pos;
lzma_pread (struct bfd *nbfd, void *stream, void *buf, file_ptr nbytes,
file_ptr offset)
{
- struct gdb_lzma_stream *lstream = stream;
+ struct gdb_lzma_stream *lstream = (struct gdb_lzma_stream *) stream;
bfd_size_type chunk_size;
lzma_index_iter iter;
gdb_byte *compressed, *uncompressed;
+ iter.block.uncompressed_size);
}
- chunk_size = min (nbytes, lstream->data_end - offset);
+ chunk_size = std::min (nbytes, (file_ptr) lstream->data_end - offset);
memcpy (buf, lstream->data + offset - lstream->data_start, chunk_size);
buf = (gdb_byte *) buf + chunk_size;
offset += chunk_size;
lzma_close (struct bfd *nbfd,
void *stream)
{
- struct gdb_lzma_stream *lstream = stream;
+ struct gdb_lzma_stream *lstream = (struct gdb_lzma_stream *) stream;
lzma_index_end (lstream->index, &gdb_lzma_allocator);
xfree (lstream->data);
void *stream,
struct stat *sb)
{
- struct gdb_lzma_stream *lstream = stream;
+ struct gdb_lzma_stream *lstream = (struct gdb_lzma_stream *) stream;
memset (sb, 0, sizeof (struct stat));
sb->st_size = lzma_index_uncompressed_size (lstream->index);
If we find one we create a iovec based bfd that decompresses the
object data on demand. If we don't find one, return NULL. */
-bfd *
+gdb_bfd_ref_ptr
find_separate_debug_file_in_section (struct objfile *objfile)
{
asection *section;
- bfd *abfd;
+ gdb_bfd_ref_ptr abfd;
if (objfile->obfd == NULL)
return NULL;
return NULL;
#ifdef HAVE_LIBLZMA
- abfd = gdb_bfd_openr_iovec (objfile_name (objfile), gnutarget, lzma_open,
+ std::string filename = string_printf (_(".gnu_debugdata for %s"),
+ objfile_name (objfile));
+
+ abfd = gdb_bfd_openr_iovec (filename.c_str (), gnutarget, lzma_open,
section, lzma_pread, lzma_close, lzma_stat);
if (abfd == NULL)
return NULL;
- if (!bfd_check_format (abfd, bfd_object))
+ if (!bfd_check_format (abfd.get (), bfd_object))
{
warning (_("Cannot parse .gnu_debugdata section; not a BFD object"));
- gdb_bfd_unref (abfd);
return NULL;
}
#else
warning (_("Cannot parse .gnu_debugdata section; LZMA support was "
"disabled at compile time"));
- abfd = NULL;
#endif /* !HAVE_LIBLZMA */
return abfd;