Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v2] Skip vDSO when reading SO list (PR 8882)
@ 2013-09-24 17:47 Andreas Arnez
  2013-09-24 18:08 ` Jan Kratochvil
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Arnez @ 2013-09-24 17:47 UTC (permalink / raw)
  To: gdb-patches; +Cc: Ulrich Weigand, jan.kratochvil

Suppress the warning when the vDSO's pathname from the SO list in a core
file can not be accessed.  The glibc's dynamic loader uses empty-string
literals for both the executable as well as the vDSO, and the compiler
collates both of them to a single string literal.  Thus the vDSO's
l_name address matches the main executable's.  This property is used as
a criteria for identifying and silently skipping the vDSO.

This version includes a small test case and follows Jan's proposal of
moving the suppression logic after the pathname read has already failed.

OK to apply?


ChangeLog:
2013-09-24  Andreas Arnez  <arnez@linux.vnet.ibm.com>

	* solib-svr4.c (svr4_read_so_list): Skip the vDSO when reading
	link map entries.

testsuite/ChangeLog:
2013-09-24  Andreas Arnez  <arnez@linux.vnet.ibm.com>

	* gdb.base/corefile.exp: Add a check to assure warning-free
	core-file load.

Index: gdb/gdb/solib-svr4.c
===================================================================
--- gdb.orig/gdb/solib-svr4.c
+++ gdb/gdb/solib-svr4.c
@@ -1310,6 +1310,7 @@ static int
 svr4_read_so_list (CORE_ADDR lm, CORE_ADDR prev_lm,
 		   struct so_list ***link_ptr_ptr, int ignore_first)
 {
+  struct so_list *first = NULL;
   CORE_ADDR next_lm;
 
   for (; lm != 0; prev_lm = lm, lm = next_lm)
@@ -1349,6 +1350,7 @@ svr4_read_so_list (CORE_ADDR lm, CORE_AD
 	{
 	  struct svr4_info *info = get_svr4_info ();
 
+	  first = new;
 	  info->main_lm_addr = new->lm_info->lm_addr;
 	  do_cleanups (old_chain);
 	  continue;
@@ -1359,8 +1361,16 @@ svr4_read_so_list (CORE_ADDR lm, CORE_AD
 			  SO_NAME_MAX_PATH_SIZE - 1, &errcode);
       if (errcode != 0)
 	{
-	  warning (_("Can't read pathname for load map: %s."),
-		   safe_strerror (errcode));
+	  /* If this entry's l_name address matches that of the
+	     inferior executable, then this is not a normal shared
+	     object, but (most likely) a vDSO.  In this case, silently
+	     skip it; otherwise emit a warning. */
+	  if (! (first != NULL
+		 && new->lm_info->l_name == first->lm_info->l_name))
+	    {
+	      warning (_("Can't read pathname for load map: %s."),
+		       safe_strerror (errcode));
+	    }
 	  do_cleanups (old_chain);
 	  continue;
 	}
Index: gdb/gdb/testsuite/gdb.base/corefile.exp
===================================================================
--- gdb.orig/gdb/testsuite/gdb.base/corefile.exp
+++ gdb/gdb/testsuite/gdb.base/corefile.exp
@@ -255,3 +255,19 @@ if ![is_remote target] {
 
     gdb_exit
 }
+
+# Test warning-free core file load.  E.g., a Linux vDSO used to
+# trigger this warning:
+#     warning: Can't read pathname for load map: Input/output error.
+
+clean_restart ${testfile}
+
+set test "core-file warning-free"
+gdb_test_multiple "core-file $corefile" $test {
+    -re "warning: .*\r\n.*\r\n$gdb_prompt $" {
+	fail $test
+    }
+    -re "\r\n$gdb_prompt $" {
+	pass $test
+    }
+}


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Skip vDSO when reading SO list (PR 8882)
  2013-09-24 17:47 [PATCH v2] Skip vDSO when reading SO list (PR 8882) Andreas Arnez
@ 2013-09-24 18:08 ` Jan Kratochvil
  2013-09-25  8:55   ` Andreas Arnez
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2013-09-24 18:08 UTC (permalink / raw)
  To: Andreas Arnez; +Cc: gdb-patches, Ulrich Weigand

On Tue, 24 Sep 2013 19:47:09 +0200, Andreas Arnez wrote:
> ChangeLog:
> 2013-09-24  Andreas Arnez  <arnez@linux.vnet.ibm.com>
> 

Add here line:
	PR shlibs/8882
> 	* solib-svr4.c (svr4_read_so_list): Skip the vDSO when reading
> 	link map entries.
> 
> testsuite/ChangeLog:
> 2013-09-24  Andreas Arnez  <arnez@linux.vnet.ibm.com>
> 

Add here line:
	PR shlibs/8882
> 	* gdb.base/corefile.exp: Add a check to assure warning-free
> 	core-file load.

OK to check it in with a little update below:


> @@ -1359,8 +1361,16 @@ svr4_read_so_list (CORE_ADDR lm, CORE_AD
>  			  SO_NAME_MAX_PATH_SIZE - 1, &errcode);
>        if (errcode != 0)
>  	{
> -	  warning (_("Can't read pathname for load map: %s."),
> -		   safe_strerror (errcode));
> +	  /* If this entry's l_name address matches that of the
> +	     inferior executable, then this is not a normal shared
> +	     object, but (most likely) a vDSO.  In this case, silently
> +	     skip it; otherwise emit a warning. */
> +	  if (! (first != NULL
> +		 && new->lm_info->l_name == first->lm_info->l_name))

Nested negations were not accepted for GDB before, therefore:
	  if (first == NULL
	      || new->lm_info->l_name != first->lm_info->l_name)

(I agree it had some logic but this was a general GDB list consensus.)


> +	    {

Excessive curly braces.


> +	      warning (_("Can't read pathname for load map: %s."),
> +		       safe_strerror (errcode));
> +	    }
>  	  do_cleanups (old_chain);
>  	  continue;
>  	}


Thanks,
Jan


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Skip vDSO when reading SO list (PR 8882)
  2013-09-24 18:08 ` Jan Kratochvil
@ 2013-09-25  8:55   ` Andreas Arnez
  2013-09-25 11:53     ` Ulrich Weigand
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Arnez @ 2013-09-25  8:55 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Ulrich Weigand

Jan Kratochvil <jan.kratochvil@redhat.com> writes:

> Nested negations were not accepted for GDB before, therefore:
> 	  if (first == NULL
> 	      || new->lm_info->l_name != first->lm_info->l_name)
>
> (I agree it had some logic but this was a general GDB list consensus.)

Sure.  This is one of the few cases where I wish C had an "unless"
conditional :-)

--
Andreas


ChangeLog:
2013-09-25  Andreas Arnez  <arnez@linux.vnet.ibm.com>

	PR shlibs/8882
	* solib-svr4.c (svr4_read_so_list): Skip the vDSO when reading
	link map entries.

testsuite/ChangeLog:
2013-09-25  Andreas Arnez  <arnez@linux.vnet.ibm.com>

	PR shlibs/8882
	* gdb.base/corefile.exp: Add a check to assure warning-free
	core-file load.

Index: gdb/gdb/solib-svr4.c
===================================================================
--- gdb.orig/gdb/solib-svr4.c
+++ gdb/gdb/solib-svr4.c
@@ -1310,6 +1310,7 @@ static int
 svr4_read_so_list (CORE_ADDR lm, CORE_ADDR prev_lm,
 		   struct so_list ***link_ptr_ptr, int ignore_first)
 {
+  struct so_list *first = NULL;
   CORE_ADDR next_lm;
 
   for (; lm != 0; prev_lm = lm, lm = next_lm)
@@ -1349,6 +1350,7 @@ svr4_read_so_list (CORE_ADDR lm, CORE_AD
 	{
 	  struct svr4_info *info = get_svr4_info ();
 
+	  first = new;
 	  info->main_lm_addr = new->lm_info->lm_addr;
 	  do_cleanups (old_chain);
 	  continue;
@@ -1359,8 +1361,14 @@ svr4_read_so_list (CORE_ADDR lm, CORE_AD
 			  SO_NAME_MAX_PATH_SIZE - 1, &errcode);
       if (errcode != 0)
 	{
-	  warning (_("Can't read pathname for load map: %s."),
-		   safe_strerror (errcode));
+	  /* If this entry's l_name address matches that of the
+	     inferior executable, then this is not a normal shared
+	     object, but (most likely) a vDSO.  In this case, silently
+	     skip it; otherwise emit a warning. */
+	  if (first == NULL
+	      || new->lm_info->l_name != first->lm_info->l_name)
+	    warning (_("Can't read pathname for load map: %s."),
+		     safe_strerror (errcode));
 	  do_cleanups (old_chain);
 	  continue;
 	}
Index: gdb/gdb/testsuite/gdb.base/corefile.exp
===================================================================
--- gdb.orig/gdb/testsuite/gdb.base/corefile.exp
+++ gdb/gdb/testsuite/gdb.base/corefile.exp
@@ -255,3 +255,19 @@ if ![is_remote target] {
 
     gdb_exit
 }
+
+# Test warning-free core file load.  E.g., a Linux vDSO used to
+# trigger this warning:
+#     warning: Can't read pathname for load map: Input/output error.
+
+clean_restart ${testfile}
+
+set test "core-file warning-free"
+gdb_test_multiple "core-file $corefile" $test {
+    -re "warning: .*\r\n.*\r\n$gdb_prompt $" {
+	fail $test
+    }
+    -re "\r\n$gdb_prompt $" {
+	pass $test
+    }
+}


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Skip vDSO when reading SO list (PR 8882)
  2013-09-25  8:55   ` Andreas Arnez
@ 2013-09-25 11:53     ` Ulrich Weigand
  0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Weigand @ 2013-09-25 11:53 UTC (permalink / raw)
  To: Andreas Arnez; +Cc: Jan Kratochvil, gdb-patches

Andreas Arnez wrote:

> ChangeLog:
> 2013-09-25  Andreas Arnez  <arnez@linux.vnet.ibm.com>
> 
> 	PR shlibs/8882
> 	* solib-svr4.c (svr4_read_so_list): Skip the vDSO when reading
> 	link map entries.
> 
> testsuite/ChangeLog:
> 2013-09-25  Andreas Arnez  <arnez@linux.vnet.ibm.com>
> 
> 	PR shlibs/8882
> 	* gdb.base/corefile.exp: Add a check to assure warning-free
> 	core-file load.

I've checked this in now.

Thanks,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-09-25 11:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-24 17:47 [PATCH v2] Skip vDSO when reading SO list (PR 8882) Andreas Arnez
2013-09-24 18:08 ` Jan Kratochvil
2013-09-25  8:55   ` Andreas Arnez
2013-09-25 11:53     ` Ulrich Weigand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox