aboutsummaryrefslogtreecommitdiff
path: root/src/common/stabs_reader.h
diff options
context:
space:
mode:
authorjimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-05-05 17:34:19 +0000
committerjimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-05-05 17:34:19 +0000
commit775c6f7640a02841b667fd6300e877bbed574544 (patch)
tree0d0b83bd37a170951f968aafd1daa6d595f00b8b /src/common/stabs_reader.h
parentBreakpad STABS parser: Use a test fixture in StabsReader unit tests. (diff)
downloadbreakpad-775c6f7640a02841b667fd6300e877bbed574544.tar.xz
Breakpad Linux dumper: Handle STABS-in-symbol-table, and line number records outside functions.
This patch addresses two differences between Linux and Macintosh OS X STABS data: - StabsReader assumes that the STABS entries follow the conventions for storing STABS data in object file sections (that is, .stabs and .stabstr), rather than in the object files's linker symbol table. On Mac OS X, STABS entries live in the Mach-O file's LC_SYMTAB load command, along with all the other linker symbols; they are not grouped into units by N_UNDF entries. This patch adds a boolean argument to the StabsReader constructor indicating whether the parser should treat N_UNDF entries as unit boundaries; this argument should be true on Linux, and false on Mac. The patch changes src/common/linux/dump_symbols.cc to pass this new argument. - Mac OS X STABS place SLINE (line number) records immediately before the FUN record for the function to which they belong, and the values of such records are absolute, not relative to the function start. This patch extends the parser to queue up such records and report them to the handler when we do see the FUN record. The meaning of StabsHandler::Line remains unchanged; existing handlers do not need to be adjusted. This patch also adds unit tests for the new parser behaviors. a=jimblandy, r=mark git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@587 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/common/stabs_reader.h')
-rw-r--r--src/common/stabs_reader.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/common/stabs_reader.h b/src/common/stabs_reader.h
index 9f954650..3c28b9ba 100644
--- a/src/common/stabs_reader.h
+++ b/src/common/stabs_reader.h
@@ -52,8 +52,12 @@
#ifdef HAVE_A_OUT_H
#include <a.out.h>
#endif
+#ifdef HAVE_MACH_O_NLIST_H
+#include <mach-o/nlist.h>
+#endif
#include <string>
+#include <vector>
#include "common/byte_cursor.h"
@@ -71,14 +75,22 @@ class StabsReader {
//
// BIG_ENDIAN should be true if the entries in the .stab section are in
// big-endian form, or false if they are in little-endian form.
+ //
// VALUE_SIZE should be either 4 or 8, indicating the size of the 'value'
// field in each entry in bytes.
+ //
+ // UNITIZED should be true if the STABS data is stored in units with
+ // N_UNDF headers. This is usually the case for STABS stored in sections,
+ // like .stab/.stabstr, and usually not the case for STABS stored in the
+ // actual symbol table; UNITIZED should be true when parsing Linux stabs,
+ // false when parsing Mac OS X STABS. For details, see:
+ // http://sourceware.org/gdb/current/onlinedocs/stabs/Stab-Section-Basics.html
//
// Note that, in ELF, the .stabstr section should be found using the
// 'sh_link' field of the .stab section header, not by name.
StabsReader(const uint8_t *stab, size_t stab_size,
const uint8_t *stabstr, size_t stabstr_size,
- bool big_endian, size_t value_size,
+ bool big_endian, size_t value_size, bool unitized,
StabsHandler *handler);
// Process the STABS data, calling the handler's member functions to
@@ -159,6 +171,13 @@ class StabsReader {
Entry entry_;
};
+ // A source line, saved to be reported later.
+ struct Line {
+ uint64_t address;
+ const char *filename;
+ int number;
+ };
+
// Return the name of the current symbol.
const char *SymbolString();
@@ -179,6 +198,10 @@ class StabsReader {
// The iterator walking the STABS entries.
EntryIterator iterator_;
+ // True if the data is "unitized"; see the explanation in the comment for
+ // StabsReader::StabsReader.
+ bool unitized_;
+
StabsHandler *handler_;
// The offset of the current compilation unit's strings within stabstr_.
@@ -190,6 +213,11 @@ class StabsReader {
// The current source file name.
const char *current_source_file_;
+
+ // Mac OS X STABS place SLINE records before functions; we accumulate a
+ // vector of these until we see the FUN record, and then report them
+ // after the StartFunction call.
+ std::vector<Line> queued_lines_;
};
// Consumer-provided callback structure for the STABS reader. Clients