Re: Asking help with (dwarf) exception hacking on mipsel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Ian and others,

> I can't answer that question until you answer my questions.

Sorry for the misunderstandings. It was my fault, not reading enough
before asking.

I could make the dwarf2 exceptions work, however, my patch is a hack.
The run-time, virtual address space is at 0x23000000+the link time
addresses of the text segments for a process.

For me, this hack is ok for my particular purpose, but if there are
suggestions how to make it more better or fixing the root cause of
these problems, welcome.

Csaba
diff -ur gcc-4.1.2.orig/gcc/unwind-dw2.c gcc-4.1.2/gcc/unwind-dw2.c
--- gcc-4.1.2.orig/gcc/unwind-dw2.c	2005-11-18 03:19:10.000000000 +0200
+++ gcc-4.1.2/gcc/unwind-dw2.c	2010-10-09 22:41:39.000000000 +0300
@@ -1014,6 +1014,8 @@
       _Unwind_Ptr lsda;
       
       aug = read_encoded_value (context, fs->lsda_encoding, aug, &lsda);
+      if (lsda && lsda < 0x23000000)
+        lsda += 0x23000000;
       context->lsda = (void *) lsda;
     }
 
diff -ur gcc-4.1.2.orig/gcc/unwind-dw2-fde.c gcc-4.1.2/gcc/unwind-dw2-fde.c
--- gcc-4.1.2.orig/gcc/unwind-dw2-fde.c	2005-06-25 05:02:01.000000000 +0300
+++ gcc-4.1.2/gcc/unwind-dw2-fde.c	2010-10-09 22:43:47.000000000 +0300
@@ -838,6 +838,7 @@
 static inline const fde *
 binary_search_unencoded_fdes (struct object *ob, void *pc)
 {
+  void* pc2 = pc-0x23000000;
   struct fde_vector *vec = ob->u.sort;
   size_t lo, hi;
 
@@ -851,9 +852,9 @@
       pc_begin = ((void **) f->pc_begin)[0];
       pc_range = ((uaddr *) f->pc_begin)[1];
 
-      if (pc < pc_begin)
+      if (pc2 < pc_begin)
 	hi = i;
-      else if (pc >= pc_begin + pc_range)
+      else if (pc2 >= pc_begin + pc_range)
 	lo = i + 1;
       else
 	return f;
diff -ur gcc-4.1.2.orig/gcc/unwind.inc gcc-4.1.2/gcc/unwind.inc
--- gcc-4.1.2.orig/gcc/unwind.inc	2005-11-17 00:10:39.000000000 +0200
+++ gcc-4.1.2/gcc/unwind.inc	2010-10-09 22:46:15.000000000 +0300
@@ -63,7 +63,7 @@
       /* Unwind successful.  Run the personality routine, if any.  */
       if (fs.personality)
 	{
-	  code = (*fs.personality) (1, _UA_CLEANUP_PHASE | match_handler,
+	  code = (*(0x23000000+fs.personality)) (1, _UA_CLEANUP_PHASE | match_handler,
 				    exc->exception_class, exc, context);
 	  if (code == _URC_INSTALL_CONTEXT)
 	    break;
@@ -114,7 +114,7 @@
       /* Unwind successful.  Run the personality routine, if any.  */
       if (fs.personality)
 	{
-	  code = (*fs.personality) (1, _UA_SEARCH_PHASE, exc->exception_class,
+	  code = (*(0x23000000+fs.personality)) (1, _UA_SEARCH_PHASE, exc->exception_class,
 				    exc, &cur_context);
 	  if (code == _URC_HANDLER_FOUND)
 	    break;
@@ -176,7 +176,7 @@
 	
       if (fs.personality)
 	{
-	  code = (*fs.personality) (1, _UA_FORCE_UNWIND | _UA_CLEANUP_PHASE,
+	  code = (*(0x23000000+fs.personality)) (1, _UA_FORCE_UNWIND | _UA_CLEANUP_PHASE,
 				    exc->exception_class, exc, context);
 	  if (code == _URC_INSTALL_CONTEXT)
 	    break;
diff -ur gcc-4.1.2.orig/libstdc++-v3/libsupc++/eh_personality.cc gcc-4.1.2/libstdc++-v3/libsupc++/eh_personality.cc
--- gcc-4.1.2.orig/libstdc++-v3/libsupc++/eh_personality.cc	2006-01-18 18:31:50.000000000 +0200
+++ gcc-4.1.2/libstdc++-v3/libsupc++/eh_personality.cc	2010-10-09 22:55:01.000000000 +0300
@@ -431,7 +431,7 @@
   // Parse the LSDA header.
   p = parse_lsda_header (context, language_specific_data, &info);
   info.ttype_base = base_of_encoded_value (info.ttype_encoding, context);
-  ip = _Unwind_GetIP (context) - 1;
+  ip = _Unwind_GetIP (context) - 1-0x23000000;
   landing_pad = 0;
   action_record = 0;
   handler_switch_value = 0;
@@ -483,9 +483,17 @@
       else if (ip < info.Start + cs_start + cs_len)
 	{
 	  if (cs_lp)
-	    landing_pad = info.LPStart + cs_lp;
+	    {
+	      landing_pad = info.LPStart + cs_lp;
+	      if (landing_pad && landing_pad < 0x23000000)
+	        landing_pad += 0x23000000;
+	    }
 	  if (cs_action)
-	    action_record = info.action_table + cs_action - 1;
+	    {
+	      action_record = info.action_table + cs_action - 1;
+	      if (action_record && (int)action_record < 0x23000000)
+	        action_record += 0x23000000;
+	    }
 	  goto found_something;
 	}
     }
@@ -550,12 +558,13 @@
 	    {
 	      // Positive filter values are handlers.
 	      catch_type = get_ttype_entry (&info, ar_filter);
+	      std::type_info* catch_type2 = (std::type_info*)((int)catch_type+0x23000000);
 
 	      // Null catch type is a catch-all handler; we can catch foreign
 	      // exceptions with this.  Otherwise we must match types.
 	      if (! catch_type
 		  || (throw_type
-		      && get_adjusted_ptr (catch_type, throw_type,
+		      && get_adjusted_ptr (catch_type2, throw_type,
 					   &thrown_ptr)))
 		{
 		  saw_handler = true;

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux