Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kevin Pouget <kevin.pouget@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] PR/12691 Add the inferior to Python exited event
Date: Thu, 15 Sep 2011 12:49:00 -0000	[thread overview]
Message-ID: <CAPftXULswP0tvKYvsizVADC_1RoHeHPCZ3-jysH5+LCzFXon-g@mail.gmail.com> (raw)
In-Reply-To: <CAPftXU+C0ZEgXzzM4=0EZLFMA+M-1Xm1jACA00essRYd1GHqGw@mail.gmail.com>

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

On Thu, Sep 1, 2011 at 1:08 PM, Kevin Pouget <kevin.pouget@gmail.com> wrote:
> On Thu, Sep 1, 2011 at 12:07 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>>> From: Kevin Pouget <kevin.pouget@gmail.com>
>>> Date: Thu, 1 Sep 2011 10:44:39 +0200
>>> Cc: Tom Tromey <tromey@redhat.com>, gdb-patches@sourceware.org
>>>
>>> On Wed, Aug 31, 2011 at 7:56 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>>> >> From: Tom Tromey <tromey@redhat.com>
>>> >> Cc: Kevin Pouget <kevin.pouget@gmail.com>, gdb-patches@sourceware.org
>>> >> Date: Wed, 31 Aug 2011 11:53:21 -0600
>>> >>
>>> >> >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
>>> >>
>>> >> Eli> I'd still like to hear from someone "in the know" how is it possible
>>> >> Eli> that the exit code won't be available, but let's not block the commit
>>> >> Eli> on that behalf.
>>> >>
>>> >> It can happen at least on detach.
>>> >
>>> > Right, thanks.  Perhaps we should mention that in parentheses.
>>> >
>>>
>>> do you want it to appear in my patch, something like
>>>
>>> > Optional, will exist only in the case that the inferior exited with some status---i.e., not detached)
>>>
>>> along with
>>>
>>> >> +An integer representing the exit code which the inferior has returned.
>>> > I think we would be better off without that "has" word.
>>>
>>> ?
>>
>> No, I meant something like
>>
>>  An integer representing the exit code, if available, which the
>>  inferior has returned.  (The exit code could be unavailable if, for
>>  example, @value{GDBN} detaches from the inferior.)
>>
>
> right, I've updated the patch, is it fine for you ?
>
>
> thanks,
>
> Kevin
>
> 2011-09-20  Kevin Pouget  <kevin.pouget@st.com>
>
>        PR python/12691: Add the inferior to Python exited event
>        * python/py-exitedevent.c (create_exited_event_object): Add inferior
>        to exited_event.
>        * python/py-event.h (emit_exited_event): Likewise
>        * python/-inferior.c (python_inferior_exit): Likewise
>
>  2011-09-01  Kevin Pouget  <kevin.pouget@st.com>
>
>        PR python/12691: Add the inferior to Python exited event
>        * gdb.python/py-events.exp: Test the inferior attribute of exited
>        event with a fork.
>        * gdb.python/py-events.py: Print inferior number on exit.
>        * gdb.python/py-events.c: Fork the inferior.
>
>  2011-09-01  Kevin Pouget  <kevin.pouget@st.com>
>
>        PR python/12691: Add the inferior to Python exited event
>        * gdb.texinfo (Events In Python): Describe exited inferior attribute.
>

ping

Eli, could you confirm that you agree with the last version of the
documentation?

Thanks,

Kevin

[-- Attachment #2: 0001-PR-12691-Add-the-inferior-to-Python-exited-event.patch --]
[-- Type: text/x-patch, Size: 3687 bytes --]

From 4d6bbef65231e37144b6b17ecd4c76bf629cf111 Mon Sep 17 00:00:00 2001
From: Kevin Pouget <kevin.pouget@st.com>
Date: Wed, 31 Aug 2011 16:32:45 +0200
Subject: [PATCH] PR/12691 Add the inferior to Python exited event

---
 gdb/doc/gdb.texinfo                    |   11 +++++++----
 gdb/python/py-exitedevent.c            |    6 ++++++
 gdb/testsuite/gdb.python/py-events.c   |    1 +
 gdb/testsuite/gdb.python/py-events.exp |   11 ++++++++++-
 gdb/testsuite/gdb.python/py-events.py  |    1 +
 5 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 23b2a98..795334d 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -22285,12 +22285,15 @@ inherited attribute refer to @code{gdb.ThreadEvent} above.
 
 @item events.exited
 Emits @code{events.ExitedEvent} which indicates that the inferior has exited.
-@code{events.ExitedEvent} has one optional attribute.  This attribute
-will exist only in the case that the inferior exited with some
-status.
+@code{events.ExitedEvent} has two attributes:
 @table @code
 @defivar ExitedEvent exit_code
-An integer representing the exit code which the inferior has returned.
+An integer representing the exit code, if available, which the inferior 
+has returned.  (The exit code could be unavailable if, for example,
+@value{GDBN} detaches from the inferior.)
+@end defivar
+@defivar ExitedEvent inferior
+A reference to the inferior which triggered the @{exited} event.
 @end defivar
 @end table
 
diff --git a/gdb/python/py-exitedevent.c b/gdb/python/py-exitedevent.c
index 08150e5..5ee6eb8 100644
--- a/gdb/python/py-exitedevent.c
+++ b/gdb/python/py-exitedevent.c
@@ -37,6 +37,12 @@ create_exited_event_object (const LONGEST *exit_code)
 			     PyLong_FromLongLong (*exit_code)) < 0)
     goto fail;
 
+  inf_obj = inferior_to_inferior_object (inf);
+  if (!inf_obj || evpy_add_attribute (exited_event,
+                                      "inferior",
+                                      inf_obj) < 0)
+    goto fail;
+
   return exited_event;
 
   fail:
diff --git a/gdb/testsuite/gdb.python/py-events.c b/gdb/testsuite/gdb.python/py-events.c
index ceb697e..665ca51 100644
--- a/gdb/testsuite/gdb.python/py-events.c
+++ b/gdb/testsuite/gdb.python/py-events.c
@@ -17,6 +17,7 @@
 */
 
 int second(){
+  fork() ;
   return 12;
 }
 
diff --git a/gdb/testsuite/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp
index e5d6daf..cdf4ae6 100644
--- a/gdb/testsuite/gdb.python/py-events.exp
+++ b/gdb/testsuite/gdb.python/py-events.exp
@@ -42,6 +42,8 @@ if ![runto_main ] then {
     return -1
 }
 
+gdb_test_no_output "set detach-on-fork off" "Don't detach on fork"
+
 gdb_test "Test_Events" "Event testers registered."
 
 gdb_breakpoint "first"
@@ -56,4 +58,11 @@ all threads stopped"
 #test exited event.
 gdb_test "continue" ".*event type: continue.*
 .*event type: exit.*
-.*exit code: 12.*"
+.*exit code: 12.*
+.*exit inf: 1.*" "Inferior 1 terminated."
+
+gdb_test "inferior 2" ".*Switching to inferior 2.*"
+gdb_test "continue" ".*event type: continue.*
+.*event type: exit.*
+.*exit code: 12.*
+.*exit inf: 2.*" "Inferior 1 terminated."
diff --git a/gdb/testsuite/gdb.python/py-events.py b/gdb/testsuite/gdb.python/py-events.py
index 9f05b9f..b40f074 100644
--- a/gdb/testsuite/gdb.python/py-events.py
+++ b/gdb/testsuite/gdb.python/py-events.py
@@ -41,6 +41,7 @@ def exit_handler (event):
     if (isinstance (event, gdb.ExitedEvent)):
         print "event type: exit"
     print "exit code: %d" % (event.exit_code)
+    print "exit inf: %d" % (event.inferior.num)
 
 def continue_handler (event):
     if (isinstance (event, gdb.ContinueEvent)):
-- 
1.7.6


  reply	other threads:[~2011-09-15 12:34 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-21  9:19 Kevin Pouget
2011-04-21 10:01 ` Eli Zaretskii
2011-04-25 18:19 ` Tom Tromey
2011-04-26  8:24   ` Kevin Pouget
2011-08-31 14:34     ` Kevin Pouget
2011-08-31 14:46       ` Eli Zaretskii
2011-08-31 14:58         ` Kevin Pouget
2011-08-31 17:27           ` Eli Zaretskii
2011-08-31 17:53             ` Tom Tromey
2011-08-31 17:59               ` Eli Zaretskii
2011-09-01  9:18                 ` Kevin Pouget
2011-09-01  8:45                   ` Kevin Pouget
2011-09-01 10:12                   ` Eli Zaretskii
2011-09-01 11:29                     ` Kevin Pouget
2011-09-15 12:49                       ` Kevin Pouget [this message]
2011-09-15 13:58                         ` Eli Zaretskii
2011-09-15 14:19                         ` Paul_Koning
2011-09-15 15:27                           ` Kevin Pouget
2011-09-15 15:42                           ` Eli Zaretskii
2011-08-31 15:50       ` Tom Tromey
2011-09-19 10:37         ` Kevin Pouget
2011-09-19 10:41           ` Eli Zaretskii
2011-10-03 16:38           ` Tom Tromey
2011-10-04  8:05             ` Kevin Pouget
2011-10-05 12:15               ` Regression (or a new FAIL?): gdb.python/py-events.exp [Re: [PATCH] PR/12691 Add the inferior to Python exited event] Jan Kratochvil
2011-10-05 12:37                 ` Kevin Pouget
2011-10-05 14:16                   ` Jan Kratochvil
2011-10-05 14:56                     ` Kevin Pouget
2011-10-09 18:17                       ` [patch] gdb.python/py-events.exp: Disable multi-inferior for gdbserver [Re: Regression (or a new FAIL?): gdb.python/py-events.exp] Jan Kratochvil
2011-10-26 15:07                         ` Pedro Alves
2011-10-27 10:31                           ` [patch] Forbid "run" etc. for use_gdb_stub targets [Re: [patch] gdb.python/py-events.exp: Disable multi-inferior for gdbserver] Jan Kratochvil
2011-10-27 18:26                             ` Pedro Alves
2011-10-28 17:40                               ` [commit test fixes] " Jan Kratochvil
2011-10-28 17:42                               ` Jan Kratochvil
2011-10-28 18:32                                 ` Pedro Alves
2011-10-29 19:55                                   ` Jan Kratochvil
2011-12-03 18:37                                     ` ping: Re: [patch] Forbid "run" etc. for use_gdb_stub targets Jan Kratochvil
2011-12-03 19:15                                       ` Pedro Alves
2011-12-03 20:22                                         ` [commit] " Jan Kratochvil
2011-12-04  1:02                                       ` ping: " Doug Evans
2011-12-04  1:30                                         ` Jan Kratochvil
2011-12-04  2:55                                           ` Doug Evans
2011-12-05 20:25                                             ` Jan Kratochvil
2011-12-05 21:44                                               ` Doug Evans
2011-12-05 23:36                                                 ` Doug Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPftXULswP0tvKYvsizVADC_1RoHeHPCZ3-jysH5+LCzFXon-g@mail.gmail.com \
    --to=kevin.pouget@gmail.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox