aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/dwarf/dwarf2reader.cc43
-rw-r--r--src/common/dwarf/dwarf2reader.h15
-rw-r--r--src/common/dwarf/functioninfo.cc4
-rw-r--r--src/common/dwarf/functioninfo.h16
4 files changed, 50 insertions, 28 deletions
diff --git a/src/common/dwarf/dwarf2reader.cc b/src/common/dwarf/dwarf2reader.cc
index 357029c2..6e3561ad 100644
--- a/src/common/dwarf/dwarf2reader.cc
+++ b/src/common/dwarf/dwarf2reader.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
@@ -844,18 +844,39 @@ void LineInfo::ReadLines() {
lengthstart += 4;
const char* lineptr = after_header_;
+ lsm.Reset(header_.default_is_stmt);
+
+ // The LineInfoHandler interface expects each line's length along
+ // with its address, but DWARF only provides addresses (sans
+ // length), and an end-of-sequence address; one infers the length
+ // from the next address. So we report a line only when we get the
+ // next line's address, or the end-of-sequence address.
+ bool have_pending_line = false;
+ uint64 pending_address = 0;
+ uint32 pending_file_num = 0, pending_line_num = 0, pending_column_num = 0;
+
while (lineptr < lengthstart + header_.total_length) {
- lsm.Reset(header_.default_is_stmt);
- while (!lsm.end_sequence) {
- size_t oplength;
- bool add_line = ProcessOneOpcode(reader_, handler_, header_,
- lineptr, &lsm, &oplength, (uintptr)-1,
- NULL);
- if (add_line)
- handler_->AddLine(lsm.address, lsm.file_num, lsm.line_num,
- lsm.column_num);
- lineptr += oplength;
+ size_t oplength;
+ bool add_row = ProcessOneOpcode(reader_, handler_, header_,
+ lineptr, &lsm, &oplength, (uintptr)-1,
+ NULL);
+ if (add_row) {
+ if (have_pending_line)
+ handler_->AddLine(pending_address, lsm.address - pending_address,
+ pending_file_num, pending_line_num,
+ pending_column_num);
+ if (lsm.end_sequence) {
+ lsm.Reset(header_.default_is_stmt);
+ have_pending_line = false;
+ } else {
+ pending_address = lsm.address;
+ pending_file_num = lsm.file_num;
+ pending_line_num = lsm.line_num;
+ pending_column_num = lsm.column_num;
+ have_pending_line = true;
+ }
}
+ lineptr += oplength;
}
after_header_ = lengthstart + header_.total_length;
diff --git a/src/common/dwarf/dwarf2reader.h b/src/common/dwarf/dwarf2reader.h
index 57667563..9f89ca8e 100644
--- a/src/common/dwarf/dwarf2reader.h
+++ b/src/common/dwarf/dwarf2reader.h
@@ -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
@@ -167,12 +167,13 @@ class LineInfoHandler {
uint64 length) { }
// Called when the line info reader has a new line, address pair
- // ready for us. ADDRESS is the address of the code, FILE_NUM is
- // the file number containing the code, LINE_NUM is the line number in
- // that file for the code, and COLUMN_NUM is the column number the code
- // starts at, if we know it (0 otherwise).
- virtual void AddLine(uint64 address, uint32 file_num, uint32 line_num,
- uint32 column_num) { }
+ // ready for us. ADDRESS is the address of the code, LENGTH is the
+ // length of its machine code in bytes, FILE_NUM is the file number
+ // containing the code, LINE_NUM is the line number in that file for
+ // the code, and COLUMN_NUM is the column number the code starts at,
+ // if we know it (0 otherwise).
+ virtual void AddLine(uint64 address, uint64 length,
+ uint32 file_num, uint32 line_num, uint32 column_num) { }
};
// The base of DWARF2/3 debug info is a DIE (Debugging Information
diff --git a/src/common/dwarf/functioninfo.cc b/src/common/dwarf/functioninfo.cc
index 09aa01fd..f4582a49 100644
--- a/src/common/dwarf/functioninfo.cc
+++ b/src/common/dwarf/functioninfo.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
@@ -89,7 +89,7 @@ void CULineInfoHandler::DefineFile(const string& name,
}
}
-void CULineInfoHandler::AddLine(uint64 address, uint32 file_num,
+void CULineInfoHandler::AddLine(uint64 address, uint64 length, uint32 file_num,
uint32 line_num, uint32 column_num) {
if (file_num < files_->size()) {
linemap_->insert(make_pair(address, make_pair(files_->at(file_num).name.c_str(),
diff --git a/src/common/dwarf/functioninfo.h b/src/common/dwarf/functioninfo.h
index 3351c67c..d941ec0d 100644
--- a/src/common/dwarf/functioninfo.h
+++ b/src/common/dwarf/functioninfo.h
@@ -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
@@ -92,13 +92,13 @@ class CULineInfoHandler: public LineInfoHandler {
// Called when the line info reader has a new line, address pair
- // ready for us. ADDRESS is the address of the code, FILE_NUM is
- // the file number containing the code, LINE_NUM is the line number
- // in that file for the code, and COLUMN_NUM is the column number
- // the code starts at, if we know it (0 otherwise).
- virtual void AddLine(uint64 address, uint32 file_num, uint32 line_num,
- uint32 column_num);
-
+ // ready for us. ADDRESS is the address of the code, LENGTH is the
+ // length of its machine code in bytes, FILE_NUM is the file number
+ // containing the code, LINE_NUM is the line number in that file for
+ // the code, and COLUMN_NUM is the column number the code starts at,
+ // if we know it (0 otherwise).
+ virtual void AddLine(uint64 address, uint64 length,
+ uint32 file_num, uint32 line_num, uint32 column_num);
private:
LineMap* linemap_;