This is the mail archive of the mailing list for the frysk project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libunwind progress

Yao Qi wrote:
On Wed, Aug 16, 2006 at 10:44:27AM -0400, Adam Jocksch wrote:
I've attached the patch to enable using dwarf_find_proc_info to be applied in frysk-imports. This is how I'd recommend using it:
Hi, Adam,
Where is the patch? I could not find it in this mail. :)
Ooops, here it is. Please find it attached.


dwarf_find_proc_info in libunwind could extract information about
cie/fde, and fill in dwarf_cie_info_t in void*
proc_info_t.unwind_info. In parse_fde(src/dwarf/Gparser.c), proc_info_t.unwind_info is casted to dwarf_cie_info_t to get the start/end address of cie and fde.

1) Build frysk normally
2) Apply the patch to frysk-imports.
3) Comment out the lines in frysk-imports' generated makefile that build fryski and build frysk-imports
4) cd to frysk-core and 'make TestRunner'

You will probably also have to undo the patch that Rick brought in to enable UNW_REMOTE_ONLY. The issue of the linker errors when building
Yes, the first thing I do to make frysk core backtrace is to remove
UNW_REMOTE_ONLY.  libunwind could not work in a remote-only mode,
since information about dwarf/elf is all from local memory.

fryski is something that needs to be addressed at some point. I've not committed this patch because of the issues associated with using it. The bugs for these problems are:


Actually, frysk could do backtrace partially on my desktop with some modifications to libunwind java bindings. (Here are some my thoughts to libunwind, free to correct me if I am wrong.)

One of the most important changes is to implement the functionality of dwarf_find_proc_info in its java binding cni code
(populate_procinfo() StackCallbacks.cxx). As I said above, dwarf_find_proc_info extract information about cie/fde, why don't we do the same thing in our
java binding cni code? I add some code in populate_procinfo() to set start/end address of cie and fde.

Here is a list about the changes I did, for your reference,

1) Set return value of -10(-UNW_ENOINFO) instead of 0 in getDynInfoListAddr().
2) Set proc_info->unwind_info point to dwarf_cie_info_t* instead of
memory image of .debug_frame, and create a new member,
debug_frame_addr, to hold the memory image of .debug_frame.
3) Remove -DUNW_REMOTE_ONLY from CFLAGS in libunwind/
4) Hardwired as(address_space) to unw_local_addr_space in
Index: frysk-imports/libunwind/src/dwarf/Gparser.c
RCS file: /cvs/frysk/frysk-imports/libunwind/src/dwarf/Gparser.c,v
retrieving revision 1.1
diff -u -r1.1 Gparser.c
--- frysk-imports/libunwind/src/dwarf/Gparser.c 31 May 2006 18:22:16 -0000      1.1
+++ frysk-imports/libunwind/src/dwarf/Gparser.c 16 Aug 2006 12:24:06 -0000
@@ -71,7 +71,8 @@
   void *arg;
   int ret;

-  as = c->as;
+  //as = c->as;
+  as = unw_local_addr_space;
   arg = c->as_arg;
   a = unw_get_accessors (as);
   curr_ip = c->pi.start_ip;

The test cases about ptrace in libunwind failed if I do this change,:-(
However, frysk could not do backtrace if I do not do so.  2) and 4)
are relative to Bug#3071, if libunwind could get the right fde/cie address
(done by 2), and access local address space instead of remote address
space (via ptrace) to get dwarf information(done by 4), this bug might
be fixed.

In fact, I am still not very clear about the general picture of
libunwind, and how frysk utilizes it, and sometimes suffered from
DWARF/ELF specification. Any comments or advice is important for us to
understand libunwind, contribute to libunwind community, and to find an reasonable solution to libunwind java bindings. Thanks!

? dwarf_find_info_patch.diff
? libunwind/unwind_info
Index: lib/unwind/cni/StackTraceCreator.cxx
RCS file: /cvs/frysk/frysk-imports/lib/unwind/cni/StackTraceCreator.cxx,v
retrieving revision 1.6
diff -u -r1.6 StackTraceCreator.cxx
--- lib/unwind/cni/StackTraceCreator.cxx	24 Jul 2006 18:04:02 -0000	1.6
+++ lib/unwind/cni/StackTraceCreator.cxx	15 Aug 2006 19:38:48 -0000
@@ -37,9 +37,14 @@
 // version and license this file solely under the GPL without
 // exception.
 #include <libunwind.h>
+extern "C"
+#include <libunwind/include/dwarf.h>
 #include <endian.h>
 #include <stdio.h>
 #include <gcj/cni.h>
+#include <stdlib.h>
 #include "lib/unwind/StackTraceCreator.h"
 #include "lib/unwind/FrameCursor.h"
@@ -59,14 +64,22 @@
 int find_proc_info (::unw_addr_space_t as, ::unw_word_t ip, 
 					::unw_proc_info_t *pip, int need_unwind_info, void *arg)
-	lib::unwind::UnwindCallbacks *cb = (lib::unwind::UnwindCallbacks*) arg;
+  fprintf(stderr, "CALLING PROCINFO\n");
+  int ret = dwarf_find_proc_info(as, ip, pip, need_unwind_info, arg);
+  fprintf(stderr, "DONE WITH PROCINFO\n");
+  return ret;
+//	lib::unwind::UnwindCallbacks *cb = (lib::unwind::UnwindCallbacks*) arg;
 	// delegate to the java interface
-	jboolean retval = cb->findProcInfo ((jlong) pip, (jlong) &as, (jlong) ip, need_unwind_info != 0);
+//  	jboolean retval = cb->findProcInfo ((jlong) pip, (jlong) &as, (jlong) ip, need_unwind_info != 0);
-	if(!retval)
-		return -UNW_ENOINFO;
+//  	if(!retval)
+//  		return -UNW_ENOINFO;
-	return 0;
+//  	return 0;
@@ -207,7 +220,7 @@
 	::unw_addr_space_t addr_space = ::unw_create_addr_space(&accessors, 0);
 	::unw_cursor_t cursor;
 	::unw_init_remote(&cursor, addr_space, (void*) cbs);
-	::unw_set_caching_policy(addr_space, UNW_CACHE_PER_THREAD);
+//	::unw_set_caching_policy(addr_space, UNW_CACHE_PER_THREAD);
 	// Create the frame objects and return the top (most recent one)
 	lib::unwind::FrameCursor *base_frame = new lib::unwind::FrameCursor((jlong) &cursor);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]