Quiet ptrace error ESRCH in regsets_fetch_inferior_registers
authorYao Qi <yao.qi@linaro.org>
Thu, 4 Aug 2016 09:44:18 +0000 (10:44 +0100)
committerYao Qi <yao.qi@linaro.org>
Thu, 4 Aug 2016 09:44:18 +0000 (10:44 +0100)
When I run process-dies-while-detaching.exp with GDBserver, I see many
warnings printed by GDBserver,

ptrace(regsets_fetch_inferior_registers) PID=26183: No such process
ptrace(regsets_fetch_inferior_registers) PID=26183: No such process
ptrace(regsets_fetch_inferior_registers) PID=26184: No such process
ptrace(regsets_fetch_inferior_registers) PID=26184: No such process

regsets_fetch_inferior_registers is called when GDBserver resumes each
lwp.

 #2  0x0000000000428260 in regsets_fetch_inferior_registers (regsets_info=0x4690d0 <aarch64_regsets_info>, regcache=0x31832020)
    at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:5412
 #3  0x00000000004070e8 in get_thread_regcache (thread=0x31832940, fetch=fetch@entry=1) at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/regcache.c:58
 #4  0x0000000000429c40 in linux_resume_one_lwp_throw (info=<optimized out>, signal=0, step=0, lwp=0x31832830)
    at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4463
 #5  linux_resume_one_lwp (lwp=0x31832830, step=<optimized out>, signal=<optimized out>, info=<optimized out>)
    at /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/linux-low.c:4573

The is the case that threads are disappeared when GDB/GDBserver resumes
them.  We check errno for ESRCH, and don't print error messages, like
what we are doing in regsets_store_inferior_registers.

gdb/gdbserver:

2016-08-04  Yao Qi  <yao.qi@linaro.org>

* linux-low.c (regsets_fetch_inferior_registers): Check
errno is ESRCH or not.

gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-low.c

index f4523f70416c3e5c04702621b015133aaf2db492..a0722c1f7d741ab26976e75a6f9a3ebf2f7bf646 100644 (file)
@@ -1,3 +1,8 @@
+2016-08-04  Yao Qi  <yao.qi@linaro.org>
+
+       * linux-low.c (regsets_fetch_inferior_registers): Check
+       errno is ESRCH or not.
+
 2016-08-02  Yao Qi  <yao.qi@linaro.org>
 
        * thread-db.c (struct thread_db) <td_ta_event_getmsg_p>: Remove.
index e251ac453dac5939b588a8f2b15185d491bf2549..1839f998aff2d34e20eddfd5785c50d823650374 100644 (file)
@@ -5405,6 +5405,12 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info,
                 not "active".  This can happen in normal operation,
                 so suppress the warning in this case.  */
            }
+         else if (errno == ESRCH)
+           {
+             /* At this point, ESRCH should mean the process is
+                already gone, in which case we simply ignore attempts
+                to read its registers.  */
+           }
          else
            {
              char s[256];
This page took 0.034158 seconds and 4 git commands to generate.