Bug 242699 - Cannot cancel during jtag hardware debugging
Summary: Cannot cancel during jtag hardware debugging
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-cdi-gdb (show other bugs)
Version: 5.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 5.0.1   Edit
Assignee: Elena Laskavaia CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-07-31 08:11 EDT by Peter Vidler CLA
Modified: 2010-05-28 13:46 EDT (History)
2 users (show)

See Also:


Attachments
Patch that solves the problem (16.08 KB, patch)
2008-07-31 08:11 EDT, Peter Vidler CLA
no flags Details | Diff
Same patch, but with inlined exception throwing for cancelations (16.08 KB, patch)
2008-08-01 04:18 EDT, Peter Vidler CLA
cdtdoug: iplog+
Details | Diff
patch with externalized strings (19.23 KB, patch)
2008-08-01 14:06 EDT, Elena Laskavaia CLA
cdtdoug: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Vidler CLA 2008-07-31 08:11:43 EDT
Created attachment 108842 [details]
Patch that solves the problem

Build ID: I20080617-2000

Steps To Reproduce:
1. Create a new "GDB Hardware Debugging" launch configuration
2. Start debugging
3. Try to cancel in the progress monitor (nothing happens)


More information:
There are two parts to this problem -- inability to cancel and inaccurate progress monitors.  Both stem from the lack of any progress monitor usage within the GDBJtagDebugger class (found in org.eclipse.cdt.debug.gdbjtag.core).

Attached should be a patch which does the following:

1. Adds SubMonitors inside doStartSession and doRunSession, with work units roughly proportional to the number of GDB commands typically invoked.
2. Adds a throwOnCancel method that simply checks the monitor for cancellation and throws OperationCanceledException if so.
3. Adds progress monitor support to executeGDBScript, including using subTask to display each command and checking for cancelation.
4. Adds try/catch wrappers around doStartSession and doRunSession which then simply call launch.terminate() to cancel (seems to work fine).
Comment 1 Elena Laskavaia CLA 2008-07-31 10:52:12 EDT
1) What about: // TODO: Externalize strings
2) Personally I would inline throwOnCancel method. It is better to see explicit exception thrown
Comment 2 Peter Vidler CLA 2008-07-31 10:57:51 EDT
This file has many areas that need strings externalized -- I've never done it myself and am not entirely sure how (I'm looking into it).  Probably needs a separate bug report as these are missing from other files as well.

For the throwOnCancel method, I just used it because canceling has to be done in *lots* of places (probably more than I've added to the patch) and it amounts to a large increase in method size (makes things harder to read for me).  I take your point about explicit exceptions though and it wouldn't bother me if they were all inlined.
Comment 3 Peter Vidler CLA 2008-08-01 04:18:11 EDT
Created attachment 108935 [details]
Same patch, but with inlined exception throwing for cancelations

Okay, here's a new patch with the throwOnCancel method inlined into the code.
Comment 4 Elena Laskavaia CLA 2008-08-01 11:40:14 EDT
That was not big deal. I was hoping you will do internationalization.
Did you try right lick on file Source->Externalize String... wizard?
Comment 5 Peter Vidler CLA 2008-08-01 11:59:26 EDT
Looks like one or two of the strings have already been externalized, which I assume is why it doesn't show up in the wizard (unless I'm doing something wrong).  I've left the strings that I added internal because there were a number of others that way already throughout the plugin, which is why I consider it a separate job.
Comment 6 Elena Laskavaia CLA 2008-08-01 14:00:42 EDT
Well mine works... Ok I'll do myself this time only,
btw do you want your contribution mentioned in the header?
Comment 7 Elena Laskavaia CLA 2008-08-01 14:06:04 EDT
Created attachment 108966 [details]
patch with externalized strings
Comment 8 Elena Laskavaia CLA 2008-08-01 14:12:16 EDT
fixed applied on 5.0 branch and head
please re-test because my jtag device is on vacation
Comment 9 Peter Vidler CLA 2008-08-04 04:08:33 EDT
Thanks!  I didn't even know we could do i18n at the package level -- I thought it was the whole plugin or nothing (guess I have more reading to do).

The patch (and CVS version) works and cancels nicely on my JTAG devices.  A mention of my contribution would be nice but isn't necessary -- I have other changes on my list for these files anyway, so I'll be filing more reports before too long :)