Bug 407340 - [debug view] Keep showing in the debug view a process that has properly exited (and show its exit code)
Summary: [debug view] Keep showing in the debug view a process that has properly exite...
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: 8.2   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: 8.7.0   Edit
Assignee: Marc Khouzam CLA
QA Contact: Marc Khouzam CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-06 17:58 EDT by Marc Khouzam CLA
Modified: 2015-05-01 16:00 EDT (History)
6 users (show)

See Also:


Attachments
Screenshot showing exited processes (62.83 KB, image/png)
2015-04-30 10:42 EDT, Marc Khouzam CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Khouzam CLA 2013-05-06 17:58:41 EDT
From Bug 402054 comment #6:

> An exit code only happens when a process terminates on its own.  Currently,
> in such a case, the process will simply disappear from the debug session (or
> the session will terminate if the correct preference is enabled).  I think
> it would be more user-friendly to let the user know the process has
> terminated.

The idea is not simply to show the exit code of the process, but also to indicate to the user that a process terminated on its own.  Currently, having the process simply disappear can cause confusion.  When a user presses terminate or detach, they expect the process to disappear, but when there is no user action and the process disappears, it does not feel user-friendly.

The other aspect of this is to allow the user to remove the exited process from the debug view once they are aware that it terminated.  I first thought of using the platform's "Remove all terminated launches" but that action is not re-targettable, so changes would be required in platform.

Other options would be to add a new button.  But maybe re-using the terminate and/or disconnect buttons when the exited process is selected would make sense to the user.

Beyond showing the exited process and its exit code, it may be nice to show the time at which it exited.  I believe CDI does this.

If the process is terminated or disconnected from by the user, we should not keep it in the debug view; we should only keep processes that exit on their own.
Comment 1 Eclipse Genie CLA 2015-04-01 16:21:08 EDT
New Gerrit change created: https://git.eclipse.org/r/45070
Comment 2 Marc Khouzam CLA 2015-04-01 16:32:50 EDT
(In reply to Eclipse Genie from comment #1)
> New Gerrit change created: https://git.eclipse.org/r/45070

This patch allows to keep showing exited processes in the DV.  To easily try it, you should allow GDB to continue running after the process terminates (unselect preferences->C/C++->Debug->GDB->"Terminate GDB when last process exits").

1- works for GDB >= 7.0
2- shows terminated processes of any kind (exited on their own, user clicked "terminate", user clicked "disconnect").
3- with GDB 7.9, exit code is shown when process exited on its own
4- allows to restart an exited process (I thought that was cool)
5- works with multi-process
6- currently no way to remove those entries

Todo:

1- test with all launch configuration types
2- support removing exited entries
3- add JUnit tests
4- should we only show processes that exited on their own, or also terminated processes?  Probably shouldn't show processes that we disconnected from
5- should we show date and time of exit as CDI does?
6- should the label say "terminated" instead of "exited" (I just noticed this)
7- is this feature desirable? If so, do we want a pref to turn it off?

Comments welcomed.
Comment 3 Marc Khouzam CLA 2015-04-28 14:03:11 EDT
(In reply to Marc Khouzam from comment #2)
> > New Gerrit change created: https://git.eclipse.org/r/45070

I pushed patchset 4 which I believe is complete, except for JUnit tests.

I'm hoping that we can commit this before feature freeze next Monday.

> This patch allows to keep showing exited processes in the DV.  To easily try
> it, you should allow GDB to continue running after the process terminates
> (unselect preferences->C/C++->Debug->GDB->"Terminate GDB when last process
> exits").
 
1- works for GDB >= 7.0
2- shows terminated processes that exited on their own and once for which the user clicked "terminate" (if the user clicked "disconnect", we don't show them).
3- with GDB 7.9, exit code is shown when process exited on its own
4- allows to restart an exited process (I thought that was cool)
5- works with multi-process
6- user can press terminate or disconnect on "exited processes" to remove them from the Debug view.  Multi-select works.

I tried to align the "exited process" entry with the one shown when doing a Run and the process terminates.  That means the label is like Run and the icon used too.

I think the only thing left, besides getting it reviewed, is for me to add JUnit tests.
Comment 4 Marc Khouzam CLA 2015-04-29 15:15:24 EDT
As described in the review, Alvaro testing with a program that uses fork() and we noticed that in those cases, GDB automatically cleans up old inferiors.  My original solution was counting on GDB always providing the exit code of exited processes through -list-thread-groups, but if GDB cleans those up, then we lose access to the exit code.

My first thought was to simply cache the exit code.  This may be sufficient, but I'm wondering if we could face a race condition if GDB were to cleanup the old inferior before CDT sent the -list-thread-groups command.  A better option would be to use the exit code from the event =thread-group-exited.  I'll try that out.

Now, GDB decided to cleanup old inferiors in the case they were created using fork(); this is surely because in that case, _many_ inferiors could be created.  This is true for CDT also, where the exited processes would accumulate in the debug view.  We could add a preference to disable showing the exited processes, but I prefer not adding yet another preference.  Instead, I suggest limiting the number of exited processes shown to 5.  It won't overcrowd the view, will still allow the user to notice a process has exited, and will avoid the accumulation of too many exited processes.  If this turns to be too limiting for someone, we can revisit.
Comment 5 Marc Khouzam CLA 2015-04-30 10:42:31 EDT
Created attachment 252966 [details]
Screenshot showing exited processes

Here is what the changes looks like in the Debug view when there are processes that exited.
Comment 7 Marc Khouzam CLA 2015-05-01 16:00:25 EDT
Committed to master.
Thanks Alvaro for the quick review.

I'll update the N&N