public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch] Fix for newer kernels with: t (tracing stop)
@ 2016-06-04 12:29 Jan Kratochvil
  2016-07-22 15:35 ` Pedro Alves
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kratochvil @ 2016-06-04 12:29 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1075 bytes --]

Hi,

I did provide wrong ptrace data which should fail on their write.
	error (_("Unexpected error setting hardware debug registers"));
But GDB did not print that error, only inferior did hang, because the data was
not written.

It is because this error/exception gets suppressed by:
linux_resume_one_lwp():
1578          if (!check_ptrace_stopped_lwp_gone (lp))
1579            throw_exception (ex);

Which happens because check_ptrace_stopped_lwp_gone()
expects 'T (tracing stop)' while recent Linux kernels
provide 't (tracing stop)' instad.
	What does lowercase t means in ps state code
	http://stackoverflow.com/questions/35895886/what-does-lowercase-t-means-in-ps-state-code

Found it on:
	kernel-4.4.6-301.fc23.aarch64
by:
	gdb/nat/aarch64-linux-hw-point.c
	-  ctrl |= ((1 << len) - 1) << 5;
	+  ctrl |= (((1 << len) - 1)&~1) << 5;

It does not change testsuite results on that F-23.aarch64 machine.
I see no real regessions on rawhide.x86_64 machine (with F-23 kernel) although
there were some fuzzy results I will need to check more.

OK for check-in?


Thanks,
Jan

[-- Attachment #2: tracestop.patch --]
[-- Type: text/plain, Size: 2465 bytes --]

gdb/ChangeLog
2016-06-04  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* nat/linux-procfs.c (linux_proc_pid_has_state): Add parameter state2.
	(linux_proc_pid_is_stopped): Update caller.
	(linux_proc_pid_is_trace_stopped_nowarn): Add 't (tracing stop)'.
	(linux_proc_pid_is_zombie_maybe_warn): Update caller.

--- a/gdb/nat/linux-procfs.c
+++ b/gdb/nat/linux-procfs.c
@@ -129,17 +129,20 @@ linux_proc_pid_is_gone (pid_t pid)
     }
 }
 
-/* Return non-zero if 'State' of /proc/PID/status contains STATE.  If
-   WARN, warn on failure to open the /proc file.  */
+/* Return non-zero if 'State' of /proc/PID/status contains STATE or STATE2.
+   STATE2 can be NULL.  If WARN, warn on failure to open the /proc file.  */
 
 static int
-linux_proc_pid_has_state (pid_t pid, const char *state, int warn)
+linux_proc_pid_has_state (pid_t pid, const char *state, const char *state2,
+			  int warn)
 {
   char buffer[100];
   int have_state;
 
   have_state = linux_proc_pid_get_state (pid, buffer, sizeof buffer, warn);
-  return (have_state > 0 && strstr (buffer, state) != NULL);
+  return (have_state > 0
+	  && (strstr (buffer, state) != NULL
+	      || (state2 != NULL && strstr (buffer, state2) != NULL)));
 }
 
 /* Detect `T (stopped)' in `/proc/PID/status'.
@@ -148,16 +151,18 @@ linux_proc_pid_has_state (pid_t pid, const char *state, int warn)
 int
 linux_proc_pid_is_stopped (pid_t pid)
 {
-  return linux_proc_pid_has_state (pid, "T (stopped)", 1);
+  return linux_proc_pid_has_state (pid, "T (stopped)", NULL, 1);
 }
 
-/* Detect `T (tracing stop)' in `/proc/PID/status'.
-   Other states including `T (stopped)' are reported as false.  */
+/* Detect `t (tracing stop)'  or `T (tracing stop)' (present in older
+   kernels) in `/proc/PID/status'.  Other states including `T (stopped)'
+   are reported as false.  */
 
 int
 linux_proc_pid_is_trace_stopped_nowarn (pid_t pid)
 {
-  return linux_proc_pid_has_state (pid, "T (tracing stop)", 1);
+  return linux_proc_pid_has_state (pid, "t (tracing stop)", "T (tracing stop)",
+                                   1);
 }
 
 /* Return non-zero if PID is a zombie.  If WARN, warn on failure to
@@ -166,7 +171,7 @@ linux_proc_pid_is_trace_stopped_nowarn (pid_t pid)
 static int
 linux_proc_pid_is_zombie_maybe_warn (pid_t pid, int warn)
 {
-  return linux_proc_pid_has_state (pid, "Z (zombie)", warn);
+  return linux_proc_pid_has_state (pid, "Z (zombie)", NULL, warn);
 }
 
 /* See linux-procfs.h declaration.  */

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

end of thread, other threads:[~2016-07-25 12:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-04 12:29 [patch] Fix for newer kernels with: t (tracing stop) Jan Kratochvil
2016-07-22 15:35 ` Pedro Alves
2016-07-22 16:04   ` Pedro Alves
2016-07-24 20:08     ` Jan Kratochvil
2016-07-25 12:02       ` [pushed 1/2] linux-procfs: Introduce enum proc_state Pedro Alves
2016-07-25 12:02       ` [pushed 2/2] linux-procfs: Handle lowercase "t (tracing stop)" state Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).