com.cmpware.elf
Class Dwarf2LineInfo

java.lang.Object
  extended by com.cmpware.elf.Dwarf2LineInfo

public class Dwarf2LineInfo
extends java.lang.Object

This describes an ELF / DWARF2 line numbering information. Each compilation unit should have one of these objects.

Copyright (c) 2004 Cmpware, Inc. All Rights Reserved.

Author:
SAG

Field Summary
static java.lang.String copyright
          Copyright string
 
Constructor Summary
Dwarf2LineInfo()
           
 
Method Summary
 int getAddr(java.lang.String dirName, java.lang.String fileName, int lineNumber)
          This method returns the memory address of a source code line given the directory and file names and the line number.
 java.lang.String getDirName(int addr)
          This method returns the source file directory name associated with thw address.
 java.util.Vector getErrorList()
          This method returns the list of errors.
 java.lang.String getFileName(int addr)
          This method returns the source file name associated with address.
 int getLineNumber(int addr)
          This method returns the line number in the source file associated with address.
 java.lang.String lineEntries()
          This returs a string representation of the address / line number / filename data.
 void load(byte[] debug_line, int offset, boolean swapBytes, int addrSize)
          This method loads up the line number information for a compilation unit.
 void setCompDirName(java.lang.String compDirName)
          This method sets the current working directory.
 void setErrorList(java.util.Vector errorList)
          This method sets the error list vector.
 java.lang.String toString(boolean swapBytes)
          This method retuns a string representation of the Line number data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

copyright

public static final java.lang.String copyright
Copyright string

See Also:
Constant Field Values
Constructor Detail

Dwarf2LineInfo

public Dwarf2LineInfo()
Method Detail

load

public void load(byte[] debug_line,
                 int offset,
                 boolean swapBytes,
                 int addrSize)
This method loads up the line number information for a compilation unit.

Parameters:
debug_line - the .debug_line Elf section.
offset - The offset into the .debug_line Elf section containing the line number information for this Compilation Unit.
swapBytes - This is the endian flag from the Elf file indicating if byte swapping is necessary.
addrSize - the number of bytes in an address. currently only 4 and 8 are supported.

getLineNumber

public int getLineNumber(int addr)
This method returns the line number in the source file associated with address.

Parameters:
addr - The address to me mapped to a source file line number.
Returns:
This method returns the line number in the source file associated with address.

getFileName

public java.lang.String getFileName(int addr)
This method returns the source file name associated with address. An empty string ("") is returned if the address does not match a source file.

Parameters:
addr - The address to me mapped to a source file.
Returns:
This method returns the source file name associated with address. An empty string ("") is returned if the address does not match a source file.

getDirName

public java.lang.String getDirName(int addr)
This method returns the source file directory name associated with thw address. An empty string ("") is returned if the address does not match a source file.

Parameters:
addr - The address to me mapped to a source file.
Returns:
This method returns the source file directory name associated with address. An empty string ("") is returned if the address does not match a source file.

getAddr

public int getAddr(java.lang.String dirName,
                   java.lang.String fileName,
                   int lineNumber)
This method returns the memory address of a source code line given the directory and file names and the line number. -1 is returned if there is no such file.

Parameters:
dirName - The directory name where the file resides. This is the name from the ELF file, not necessarily the filesystem.
fileName - The source code file name. This is the name as it is in the ELF file, not necessarily any file name that will retreive the file from the file system.
lineNumber - The line number in the file. The top of the file is line 1.
Returns:
This method returns the memory address of a source code line given the directory and file names and the line number. Zero is returned if there is no such file.

getErrorList

public java.util.Vector getErrorList()
This method returns the list of errors.

Returns:
This method returns the list of errors.

setErrorList

public void setErrorList(java.util.Vector errorList)
This method sets the error list vector. This permits errors to easily be gathered in one place.

Parameters:
errorList - The error list vector.

setCompDirName

public void setCompDirName(java.lang.String compDirName)
This method sets the current working directory. This is typically from the Compilation Unit header. Note that this should be set before load() is called for this value to be included in the line number info tables.

Parameters:
compDirName - The Current Working Directory.

toString

public java.lang.String toString(boolean swapBytes)
This method retuns a string representation of the Line number data.

Parameters:
swapBytes - The flag indicating if byte swapping is performed on the original data from the .line_info section. This is required by the disassembler.

lineEntries

public java.lang.String lineEntries()
This returs a string representation of the address / line number / filename data. Note that this should be called after the Statement Program is executed.

Returns:
This returs a string representation of the address / line number / filename data.