public class Ip2SourceMapper
extends java.lang.Object
An example use of this class is:
long[] IPs = {0x080483d4, 0x080483e3, 0x08048417};
Ip2SourceMapEntry[] result = null;
String filename1 = "./srcmap";
try {
Ip2SourceMapper mapper = new Ip2SourceMapper (filename1);
mapper.map (IPs);
result = mapper.getResult();
mapper.close();
} catch (FileNotFoundException e) {
System.out.println ("file " + filename1 + " is not found: " + e);
... (more exception handling)
} catch (IOException e) {
System.out.println ("Error in executing 'addr2line' program: " + e);
... (more exception handling)
}
if (result != null) {
for (int i = 0; i < result.length; i++) {
System.out.println (result[i]);
... (other handling)
}
}
Constructor and Description |
---|
Ip2SourceMapper(java.lang.String binaryFileName,
long offset)
Constructor to create an Ip2SourceMapper object.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
If open succeeded,
closes the bfd file and releases associated system resources.
|
protected void |
finalize()
Ensures that the
close method of this object is called
when there are no more references to it. |
java.lang.String |
getMapper()
Returns the mapper which was used to perform source code mapping,
one of "psjbfd" or "binutils".
|
int |
getOpenReturnCode()
Returns the return code of underlying C function call
_ps_bfd_open inside JNI,
with 0 meaning success;
this method is intended for debugging. |
Ip2SourceMapEntry[] |
getResult()
Returns the mapping result.
|
static boolean |
libpsxInitOk()
Returns true if libpsx is successfully
initialized -- indicating that libbfd is available,
false otherwise.
|
void |
map(long[] ips)
Maps the given array of IPs into corresponding arrays of objects
of type
Ip2SourceMapEntry , which can be obtained
by calling the getResult method. |
static void |
setStyle(java.lang.String style) |
java.lang.String |
toString()
Returns a string representation of the object.
|
public Ip2SourceMapper(java.lang.String binaryFileName, long offset) throws java.io.FileNotFoundException
java.lang.IllegalArgumentException
- if the given binaryFileName
is null
.java.io.FileNotFoundException
- if the named file does not exist,
is a directory rather than a regular file,
or for some other reason cannot be opened for reading.java.lang.RuntimeException
- if the file exists, but can not be opened for reading,
or if there is I/O error when it is closed.public static void setStyle(java.lang.String style)
public int getOpenReturnCode()
_ps_bfd_open
inside JNI,
with 0 meaning success;
this method is intended for debugging.public void map(long[] ips) throws java.io.IOException
Ip2SourceMapEntry
, which can be obtained
by calling the getResult
method.
If libbfd is unavailable, then the program "addr2line"
is executed to do the mapping. While executing the program,
it is possible that an IOException
is thrown.
java.lang.IllegalArgumentException
- if the given ips
is null
.java.io.IOException
- if there is I/O error in executing "addr2line" program.public Ip2SourceMapEntry[] getResult()
public java.lang.String getMapper()
public void close()
protected void finalize() throws java.lang.Throwable
close
method of this object is called
when there are no more references to it.finalize
in class java.lang.Object
java.lang.Throwable
public java.lang.String toString()
toString
in class java.lang.Object
public static boolean libpsxInitOk()