Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 337493 - [EDC] clean up API for getting next code line for setting breakpoint
Summary: [EDC] clean up API for getting next code line for setting breakpoint
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-edc (show other bugs)
Version: 7.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Ling Wang CLA
QA Contact: Ken Ryall CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-17 17:18 EST by Ling Wang CLA
Modified: 2011-05-13 11:06 EDT (History)
1 user (show)

See Also:


Attachments
patch of implementing the new API in EDC (30.18 KB, patch)
2011-03-01 00:44 EST, Ling Wang CLA
no flags Details | Diff
Implement the API in EDC (30.31 KB, patch)
2011-03-01 01:04 EST, Ling Wang CLA
cdtdoug: iplog-
Details | Diff
unit test for EDC implementation (70.29 KB, patch)
2011-03-01 12:33 EST, Ling Wang CLA
cdtdoug: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ling Wang CLA 2011-02-17 17:18:51 EST
When to set a source line breakpoint, EDC check if the line has code (i.e. it's not a blank line, comment line, etc) by looking up symbol data. If not, it will ask symbol for the next code line and set breakpoint there, namely automatically move the breakpoint to the next line (see bug 323457). That's totally fine. The problem is it uses the API Modules.calcAddressInfo() to get the next code line, which is not designed for the purpose. We need to clean that up by adding new API.
Comment 1 Ling Wang CLA 2011-02-28 16:52:02 EST
Here's the new API I have. The idea is that when trying to set a breakpoint at a line, if the line has no code then try to set the breakpoint at  a line in the close neighborhood (a few lines above and below the line in question) that has code.

	/**
	 * Given a source line (let's call it anchor), find the line closest to the
	 * anchor in the neighborhood (including the anchor itself) that has machine
	 * code. If the anchor itself has code, it's returned. Otherwise neighbor
	 * lines both above and below the anchor will be checked. If the closest
	 * line above the anchor and the closest line below the anchor have the same
	 * distance from the anchor, the one below will be selected.
	 * 
	 * This is mainly used in setting breakpoint at anchor line.
	 * 
	 * @param symCtx
	 *            the symbol context in which to perform the lookup. It can be
	 *            an execution context (e.g. a process), or a module (exe or
	 *            dll) in a process.
	 * @param file
	 *            the file that contains the source lines in question.
	 * @param anchor
	 *            line number of the anchor source line.
	 * @param neighbor_limit
	 *            specify the limit of the neighborhood: up to this number of
	 *            lines above the anchor and up to this number of lines below
	 *            the anchor will be checked if needed. But the check will never
	 *            go beyond the source file. When the limit is zero, no neighbor
	 *            lines will be checked. If the limit has value of -1, it means
	 *            the actual limit is the source file.
	 * @param rm
	 *            contains an object of {@link ILineAddresses} if the line with
	 *            code is found. And addresses in it are runtime addresses. The
	 *            RM will contain error status otherwise.
	 */
	public void findClosestLineWithCode(ISymbolDMContext symCtx, String file, int anchor, int neighbor_limit,
			DataRequestMonitor<ILineAddresses> rm)
Comment 2 Ling Wang CLA 2011-03-01 00:44:38 EST
Created attachment 190014 [details]
patch of implementing the new API in EDC

This patch implements the new API in EDC Modules service and in EDC dwarf reader. We may promote the API to DSF in the future if so desired by other DSF debuggers.
Comment 3 Ling Wang CLA 2011-03-01 01:04:24 EST
Created attachment 190017 [details]
Implement the API in EDC

Oops, previous patch has a small build error against Indigo and CDT head. Fixed here. 
Also, the patch moves the breakpoint marker accordingly when the breakpoint is moved to another line in the neighborhood.
Comment 4 Ling Wang CLA 2011-03-01 12:33:39 EST
Created attachment 190063 [details]
unit test for EDC implementation
Comment 5 Ling Wang CLA 2011-03-01 15:12:23 EST
Committed the patches to EDC head.
For test cases, please see bug 323457.
Comment 6 CDT Genie CLA 2011-03-01 15:23:35 EST
*** cdt cvs genie on behalf of lwang ***
Bug 337493 & Bug 323457: new and more complete support of moving breakpoint from no-code line to nearby code line.

[*] Modules.java 1.29 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/edc/org.eclipse.cdt.debug.edc/src/org/eclipse/cdt/debug/edc/internal/services/dsf/Modules.java?root=Tools_Project&r1=1.28&r2=1.29
[*] BreakpointAttributeTranslator.java 1.14 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/edc/org.eclipse.cdt.debug.edc/src/org/eclipse/cdt/debug/edc/internal/services/dsf/BreakpointAttributeTranslator.java?root=Tools_Project&r1=1.13&r2=1.14

[*] FileLineEntryProvider.java 1.2 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/edc/org.eclipse.cdt.debug.edc/src/org/eclipse/cdt/debug/edc/internal/symbols/FileLineEntryProvider.java?root=Tools_Project&r1=1.1&r2=1.2
[*] ModuleLineEntryProvider.java 1.20 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/edc/org.eclipse.cdt.debug.edc/src/org/eclipse/cdt/debug/edc/internal/symbols/ModuleLineEntryProvider.java?root=Tools_Project&r1=1.19&r2=1.20

[*] IModuleLineEntryProvider.java 1.3 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/edc/org.eclipse.cdt.debug.edc/src/org/eclipse/cdt/debug/edc/symbols/IModuleLineEntryProvider.java?root=Tools_Project&r1=1.2&r2=1.3
[*] ILineEntryProvider.java 1.5 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/edc/org.eclipse.cdt.debug.edc/src/org/eclipse/cdt/debug/edc/symbols/ILineEntryProvider.java?root=Tools_Project&r1=1.4&r2=1.5

[+] .project  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/edc/org.eclipse.cdt.debug.edc.tests/resources/Projects/inlineFunction/.project?root=Tools_Project&revision=1.1&view=markup
[+] Readme.txt  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/edc/org.eclipse.cdt.debug.edc.tests/resources/Projects/inlineFunction/Readme.txt?root=Tools_Project&revision=1.1&view=markup
[+] .cproject  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/edc/org.eclipse.cdt.debug.edc.tests/resources/Projects/inlineFunction/.cproject?root=Tools_Project&revision=1.1&view=markup

[*] AllEDCTests.java 1.12 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/edc/org.eclipse.cdt.debug.edc.tests/src/org/eclipse/cdt/debug/edc/tests/AllEDCTests.java?root=Tools_Project&r1=1.11&r2=1.12
[+] TestFindCodeLine.java  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/edc/org.eclipse.cdt.debug.edc.tests/src/org/eclipse/cdt/debug/edc/tests/TestFindCodeLine.java?root=Tools_Project&revision=1.1&view=markup

[+] inlineFunction.exe  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/edc/org.eclipse.cdt.debug.edc.tests/resources/SymbolFiles/inlineFunction.exe?root=Tools_Project&revision=1.1&view=markup

[+] org.eclipse.cdt.managedbuilder.core.prefs  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/edc/org.eclipse.cdt.debug.edc.tests/resources/Projects/inlineFunction/.settings/org.eclipse.cdt.managedbuilder.core.prefs?root=Tools_Project&revision=1.1&view=markup