aboutsummaryrefslogtreecommitdiff
path: root/libjava/stacktrace.cc
diff options
context:
space:
mode:
authorbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>2006-07-06 23:26:24 +0000
committerbryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4>2006-07-06 23:26:24 +0000
commit986a6e5b9e58b7b8acc937a295d21dce2cf626b7 (patch)
tree69d4b922ffd2f4030815c9177b5f466624841a86 /libjava/stacktrace.cc
parent108cf1776caa5e59c4cb1ab3dedcdcf5c5ba5ef5 (diff)
2006-07-06 Bryce McKinlay <mckinlay@redhat.com>
* stacktrace.cc (ClassForFrame): Remove commented-out code. (UnwindTraceFn): Use _Unwind_GetIPInfo and adjust IP only when needed. (getLineNumberForFrame): Don't adjust IP here. * testsuite/libjava.lang/StackTrace.java: New test case. * testsuite/libjava.lang/StackTrace.out: Ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@115235 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/stacktrace.cc')
-rw-r--r--libjava/stacktrace.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/libjava/stacktrace.cc b/libjava/stacktrace.cc
index 06a4dfadb98..2ace9abc232 100644
--- a/libjava/stacktrace.cc
+++ b/libjava/stacktrace.cc
@@ -79,8 +79,6 @@ _Jv_StackTrace::ClassForFrame (_Jv_StackFrame *frame)
{
JvAssert (frame->type == frame_native);
jclass klass = NULL;
- // use _Unwind_FindEnclosingFunction to find start of method
- //void *entryPoint = _Unwind_FindEnclosingFunction (ip);
// look it up in ncodeMap
if (frame->start_ip)
@@ -124,13 +122,20 @@ _Jv_StackTrace::UnwindTraceFn (struct _Unwind_Context *context, void *state_ptr)
else
#endif
{
+ _Unwind_Ptr ip;
+ int ip_before_insn = 0;
+ ip = _Unwind_GetIPInfo (context, &ip_before_insn);
+
+ // If the unwinder gave us a 'return' address, roll it back a little
+ // to ensure we get the correct line number for the call itself.
+ if (! ip_before_insn)
+ --ip;
+
state->frames[pos].type = frame_native;
- state->frames[pos].ip = (void *) _Unwind_GetIP (context);
+ state->frames[pos].ip = (void *) ip;
state->frames[pos].start_ip = func_addr;
}
- //printf ("unwind ip: %p\n", _Unwind_GetIP (context));
-
_Unwind_Reason_Code result = _URC_NO_REASON;
if (state->trace_function != NULL)
result = (state->trace_function) (state);
@@ -207,10 +212,6 @@ _Jv_StackTrace::getLineNumberForFrame(_Jv_StackFrame *frame, NameFinder *finder,
else
offset = (_Unwind_Ptr) ip - (_Unwind_Ptr) info.base;
- // The unwinder gives us the return address. In order to get the right
- // line number for the stack trace, roll it back a little.
- offset -= 1;
-
finder->lookup (binaryName, (jlong) offset);
*sourceFileName = finder->getSourceFile();
*lineNum = finder->getLineNum();