2010-01-29 Doug Kwan <dougkwan@google.com>
[deliverable/binutils-gdb.git] / gold / dwarf_reader.h
index 9c6b175839d24a2c1232db337d6beec880d884b4..e2b8aa0e3cec60eac3112b7ee9d6e3581128ab38 100644 (file)
@@ -1,6 +1,6 @@
 // dwarf_reader.h -- parse dwarf2/3 debug information for gold  -*- C++ -*-
 
-// Copyright 2007, 2008 Free Software Foundation, Inc.
+// Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -72,12 +72,20 @@ class Dwarf_line_info
   addr2line(unsigned int shndx, off_t offset)
   { return do_addr2line(shndx, offset); }
 
-  // A helper function for a single addr2line lookup.  It uses
-  // parameters() to figure out the size and endianness.  This is less
-  // efficient than using the templatized size and endianness, so only
-  // call this from an un-templatized context.
+  // A helper function for a single addr2line lookup.  It also keeps a
+  // cache of the last CACHE_SIZE Dwarf_line_info objects it created;
+  // set to 0 not to cache at all.  The larger CACHE_SIZE is, the more
+  // chance this routine won't have to re-create a Dwarf_line_info
+  // object for its addr2line computation; such creations are slow.
+  // NOTE: Not thread-safe, so only call from one thread at a time.
   static std::string
-  one_addr2line(Object* object, unsigned int shndx, off_t offset);
+  one_addr2line(Object* object, unsigned int shndx, off_t offset,
+                size_t cache_size);
+
+  // This reclaims all the memory that one_addr2line may have cached.
+  // Use this when you know you will not be calling one_addr2line again.
+  static void
+  clear_addr2line_cache();
 
  private:
   virtual std::string
@@ -91,7 +99,7 @@ class Sized_dwarf_line_info : public Dwarf_line_info
   // Initializes a .debug_line reader for a given object file.
   // If SHNDX is specified and non-negative, only read the debug
   // information that pertains to the specified section.
-  Sized_dwarf_line_info(Object* object, off_t read_shndx = -1U);
+  Sized_dwarf_line_info(Object* object, unsigned int read_shndx = -1U);
 
  private:
   std::string
@@ -101,7 +109,7 @@ class Sized_dwarf_line_info : public Dwarf_line_info
   // If SHNDX is non-negative, only store debug information that
   // pertains to the specified section.
   void
-  read_line_mappings(Object*, off_t shndx);
+  read_line_mappings(Object*, unsigned int shndx);
 
   // Reads the relocation section associated with .debug_line and
   // stores relocation information in reloc_map_.
@@ -126,7 +134,7 @@ class Sized_dwarf_line_info : public Dwarf_line_info
   // discard all line information that doesn't pertain to the given
   // section.
   const unsigned char*
-  read_lines(const unsigned char* lineptr, off_t shndx);
+  read_lines(const unsigned char* lineptr, unsigned int shndx);
 
   // Process a single line info opcode at START using the state
   // machine at LSM.  Return true if we should define a line using the
This page took 0.023594 seconds and 4 git commands to generate.