aboutsummaryrefslogtreecommitdiff
path: root/src/common/dwarf
diff options
context:
space:
mode:
authorjimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-01-28 22:56:28 +0000
committerjimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-01-28 22:56:28 +0000
commit1ac84da26d72cc3fb85af124d91b17cdecb17499 (patch)
tree654b9e60633aa320d0498cbd703693aaf26579af /src/common/dwarf
parentBreakpad processor: Fix function and public symbol lookup. (diff)
downloadbreakpad-1ac84da26d72cc3fb85af124d91b17cdecb17499.tar.xz
Breakpad DWARF parser: Add method to read DWARF "Initial length".
This patch moves the ReadInitialFunction from dwarf2reader.cc, where it was a static function, to being a member function of google_breakpad::ByteReader. a=jimblandy, r=nealsid git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@504 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/common/dwarf')
-rw-r--r--src/common/dwarf/bytereader.cc19
-rw-r--r--src/common/dwarf/bytereader.h10
-rw-r--r--src/common/dwarf/dwarf2reader.cc29
3 files changed, 31 insertions, 27 deletions
diff --git a/src/common/dwarf/bytereader.cc b/src/common/dwarf/bytereader.cc
index 7ef68eb0..0089701d 100644
--- a/src/common/dwarf/bytereader.cc
+++ b/src/common/dwarf/bytereader.cc
@@ -1,4 +1,4 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+// Copyright 2010 Google Inc. All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -60,4 +60,21 @@ void ByteReader::SetAddressSize(uint8 size) {
}
}
+uint64 ByteReader::ReadInitialLength(const char* start, size_t* len) {
+ const uint64 initial_length = ReadFourBytes(start);
+ start += 4;
+
+ // In DWARF2/3, if the initial length is all 1 bits, then the offset
+ // size is 8 and we need to read the next 8 bytes for the real length.
+ if (initial_length == 0xffffffff) {
+ SetOffsetSize(8);
+ *len = 12;
+ return ReadOffset(start);
+ } else {
+ SetOffsetSize(4);
+ *len = 4;
+ }
+ return initial_length;
+}
+
} // namespace dwarf2reader
diff --git a/src/common/dwarf/bytereader.h b/src/common/dwarf/bytereader.h
index 72dbb4cf..881f20b4 100644
--- a/src/common/dwarf/bytereader.h
+++ b/src/common/dwarf/bytereader.h
@@ -1,4 +1,6 @@
-// Copyright 2006 Google Inc. All Rights Reserved.
+// -*- mode: C++ -*-
+
+// Copyright 2010 Google Inc. All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -104,6 +106,12 @@ class ByteReader {
// and will CHECK on anything else.
uint64 ReadAddress(const char* buffer) const;
+ // Read a DWARF2/3 initial length field from START, and report the
+ // length of the length field in LEN. Return the value of the length
+ // field. Set this reader's offset size as indicated by the length
+ // field's encoding.
+ uint64 ReadInitialLength(const char* start, size_t* len);
+
private:
// Function pointer type for our address and offset readers.
diff --git a/src/common/dwarf/dwarf2reader.cc b/src/common/dwarf/dwarf2reader.cc
index 6e3561ad..54224390 100644
--- a/src/common/dwarf/dwarf2reader.cc
+++ b/src/common/dwarf/dwarf2reader.cc
@@ -40,27 +40,6 @@
namespace dwarf2reader {
-// Read a DWARF2/3 initial length field from START, using READER, and
-// report the length in LEN. Return the actual initial length.
-
-static uint64 ReadInitialLength(const char* start,
- ByteReader* reader, size_t* len) {
- const uint64 initial_length = reader->ReadFourBytes(start);
- start += 4;
-
- // In DWARF2/3, if the initial length is all 1 bits, then the offset
- // size is 8 and we need to read the next 8 bytes for the real length.
- if (initial_length == 0xffffffff) {
- reader->SetOffsetSize(8);
- *len = 12;
- return reader->ReadOffset(start);
- } else {
- reader->SetOffsetSize(4);
- *len = 4;
- }
- return initial_length;
-}
-
CompilationUnit::CompilationUnit(const SectionMap& sections, uint64 offset,
ByteReader* reader, Dwarf2Handler* handler)
: offset_from_section_start_(offset), reader_(reader),
@@ -243,8 +222,8 @@ void CompilationUnit::ReadHeader() {
size_t initial_length_size;
assert(headerptr + 4 < buffer_ + buffer_length_);
- const uint64 initial_length = ReadInitialLength(headerptr, reader_,
- &initial_length_size);
+ const uint64 initial_length
+ = reader_->ReadInitialLength(headerptr, &initial_length_size);
headerptr += initial_length_size;
header_.length = initial_length;
@@ -563,8 +542,8 @@ void LineInfo::ReadHeader() {
const char* lineptr = buffer_;
size_t initial_length_size;
- const uint64 initial_length = ReadInitialLength(lineptr, reader_,
- &initial_length_size);
+ const uint64 initial_length
+ = reader_->ReadInitialLength(lineptr, &initial_length_size);
lineptr += initial_length_size;
header_.total_length = initial_length;