Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 155544 Details for
Bug 298883
[mac] Need infrastructure to properly support Mac's version of GDB for DSF-GDB
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch with extension APIs in MI expressions service.
20100107_298883patch (text/plain), 38.53 KB, created by
Pawel Piech
on 2010-01-07 15:23:35 EST
(
hide
)
Description:
Patch with extension APIs in MI expressions service.
Filename:
MIME Type:
Creator:
Pawel Piech
Created:
2010-01-07 15:23:35 EST
Size:
38.53 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.cdt.dsf.gdb >Index: src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java,v >retrieving revision 1.9 >diff -u -r1.9 GdbLaunchDelegate.java >--- src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java 12 Oct 2009 13:53:53 -0000 1.9 >+++ src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java 7 Jan 2010 20:20:56 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008, 2009 QNX Software Systems and others. >+ * Copyright (c) 2010 QNX Software Systems and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -9,6 +9,7 @@ > * QNX Software Systems - Initial API and implementation > * Windriver and Ericsson - Updated for DSF > * IBM Corporation >+ * Ericsson - Added support for Mac OS > *******************************************************************************/ > package org.eclipse.cdt.dsf.gdb.launching; > >@@ -382,6 +383,11 @@ > } > > private boolean isNonStopSupported(String version) { >+ if (version.startsWith(LaunchUtils.MACOS_GDB_PREFIX)) { >+ // Mac OS's GDB does not support Non-Stop >+ return false; >+ } >+ > if (NON_STOP_FIRST_VERSION.compareTo(version) <= 0) { > return true; > } >@@ -395,12 +401,6 @@ > return new GdbDebugServicesFactoryNS(version); > } > >- if (version.startsWith("6.6") || //$NON-NLS-1$ >- version.startsWith("6.7") || //$NON-NLS-1$ >- version.startsWith("6.8")) { //$NON-NLS-1$ >- return new GdbDebugServicesFactory(version); >- } >- > return new GdbDebugServicesFactory(version); > } > } >Index: src/org/eclipse/cdt/dsf/gdb/launching/LaunchUtils.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchUtils.java,v >retrieving revision 1.6 >diff -u -r1.6 LaunchUtils.java >--- src/org/eclipse/cdt/dsf/gdb/launching/LaunchUtils.java 2 Sep 2009 15:05:18 -0000 1.6 >+++ src/org/eclipse/cdt/dsf/gdb/launching/LaunchUtils.java 7 Jan 2010 20:20:56 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008 Ericsson and others. >+ * Copyright (c) 2010 Ericsson and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * Ericsson - Initial API and implementation >+ * Ericsson - Added support for Mac OS > *******************************************************************************/ > package org.eclipse.cdt.dsf.gdb.launching; > >@@ -43,6 +44,12 @@ > > public class LaunchUtils { > >+ /** >+ * A prefix that we use to indicate that a GDB version is for MAC OS >+ * @since 2.1 >+ */ >+ public static final String MACOS_GDB_PREFIX = "APPLE"; //$NON-NLS-1$ >+ > /** > * Verify the following things about the project: > * - is a valid project name given >@@ -212,7 +219,27 @@ > */ > public static String getGDBVersionFromText(String versionOutput) { > String version = "";//$NON-NLS-1$ >- >+ >+ // First look for the case of Apple's GDB, since the version must be handled differently >+ // The format is: >+ // GNU gdb 6.3.50-20050815 (Apple version gdb-696) (Sat Oct 20 18:20:28 GMT 2007) >+ // GNU gdb 6.3.50-20050815 (Apple version gdb-966) (Tue Mar 10 02:43:13 UTC 2009) >+ // GNU gdb 6.3.50-20050815 (Apple version gdb-1346) (Fri Sep 18 20:40:51 UTC 2009) >+ // Also, it seems the version that changes is the "Apple version" so that is the >+ // one we will extract. The normal GDB version is fixed and won't help us. >+ if (versionOutput.toLowerCase().indexOf("apple") != -1) { //$NON-NLS-1$ >+ // Add a prefix to indicate we are dealing with an Apple GDB >+ version = MACOS_GDB_PREFIX; >+ Pattern pattern = Pattern.compile(" \\(Apple version gdb-(\\d*)\\)", Pattern.MULTILINE); //$NON-NLS-1$ >+ >+ Matcher matcher = pattern.matcher(versionOutput); >+ if (matcher.find()) { >+ version += matcher.group(1); >+ } >+ >+ return version; >+ } >+ > // These are the GDB version patterns I have seen up to now > // The pattern works for all of them extracting the version of 6.8.50.20080730 > // GNU gdb 6.8.50.20080730 >Index: src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java,v >retrieving revision 1.6 >diff -u -r1.6 GdbDebugServicesFactory.java >--- src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java 18 Dec 2009 18:59:42 -0000 1.6 >+++ src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java 7 Jan 2010 20:20:57 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008 Ericsson and others. >+ * Copyright (c) 2010 Ericsson and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,7 +7,8 @@ > * > * Contributors: > * Ericsson - initial API and implementation >- * Nokia - create and use backend service. >+ * Nokia - create and use backend service. >+ * Ericsson - Added support for Mac OS > *******************************************************************************/ > package org.eclipse.cdt.dsf.gdb.service; > >@@ -24,14 +25,16 @@ > import org.eclipse.cdt.dsf.debug.service.ISourceLookup; > import org.eclipse.cdt.dsf.debug.service.IStack; > import org.eclipse.cdt.dsf.debug.service.command.ICommandControl; >+import org.eclipse.cdt.dsf.gdb.launching.LaunchUtils; > import org.eclipse.cdt.dsf.gdb.service.command.GDBControl; > import org.eclipse.cdt.dsf.gdb.service.command.GDBControl_7_0; >+import org.eclipse.cdt.dsf.gdb.service.macos.MacOSGDBExpressions; > import org.eclipse.cdt.dsf.mi.service.CSourceLookup; >-import org.eclipse.cdt.dsf.mi.service.MIExpressions; > import org.eclipse.cdt.dsf.mi.service.IMIBackend; > import org.eclipse.cdt.dsf.mi.service.MIBreakpoints; > import org.eclipse.cdt.dsf.mi.service.MIBreakpointsManager; > import org.eclipse.cdt.dsf.mi.service.MIDisassembly; >+import org.eclipse.cdt.dsf.mi.service.MIExpressions; > import org.eclipse.cdt.dsf.mi.service.MIMemory; > import org.eclipse.cdt.dsf.mi.service.MIModules; > import org.eclipse.cdt.dsf.mi.service.MIRegisters; >@@ -44,10 +47,24 @@ > // This should eventually be "7.0" once GDB 7.0 is released > private static final String GDB_7_0_VERSION = "6.8.50.20090218"; //$NON-NLS-1$ > >+ // Contains the GDB version string such as >+ // 7.0 >+ // 6.8.50.20090218 >+ // For MacOS, it contains the Apple version number, such as >+ // 969 >+ // 1465 > private final String fVersion; > >+ // Indicate if we are dealing with a Mac OS GDB >+ private boolean fIsMacOSGdb = false; >+ > public GdbDebugServicesFactory(String version) { >- fVersion = version; >+ if (version.startsWith(LaunchUtils.MACOS_GDB_PREFIX)) { >+ fIsMacOSGdb = true; >+ fVersion = version.substring(LaunchUtils.MACOS_GDB_PREFIX.length()); >+ } else { >+ fVersion = version; >+ } > } > > public String getVersion() { return fVersion; } >@@ -73,16 +90,22 @@ > } > } > >- > return super.createService(clazz, session); > } > > protected MIBreakpointsManager createBreakpointManagerService(DsfSession session) { >+ if (fIsMacOSGdb) { >+ return new MIBreakpointsManager(session, CDebugCorePlugin.PLUGIN_ID); >+ } > return new MIBreakpointsManager(session, CDebugCorePlugin.PLUGIN_ID); > } > > @Override > protected IBreakpoints createBreakpointService(DsfSession session) { >+ if (fIsMacOSGdb) { >+ return new MIBreakpoints(session); >+ } >+ > if (GDB_7_0_VERSION.compareTo(fVersion) <= 0) { > return new GDBBreakpoints_7_0(session); > } >@@ -90,6 +113,10 @@ > } > > protected ICommandControl createCommandControl(DsfSession session, ILaunchConfiguration config) { >+ if (fIsMacOSGdb) { >+ return new GDBControl(session, config); >+ } >+ > if (GDB_7_0_VERSION.compareTo(fVersion) <= 0) { > return new GDBControl_7_0(session, config); > } >@@ -97,21 +124,37 @@ > } > > protected IMIBackend createBackendGDBService(DsfSession session, ILaunchConfiguration lc) { >+ if (fIsMacOSGdb) { >+ return new GDBBackend(session, lc); >+ } >+ > return new GDBBackend(session, lc); > } > > @Override > protected IDisassembly createDisassemblyService(DsfSession session) { >+ if (fIsMacOSGdb) { >+ return new MIDisassembly(session); >+ } >+ > return new MIDisassembly(session); > } > > @Override > protected IExpressions createExpressionService(DsfSession session) { >+ if (fIsMacOSGdb) { >+ return new MacOSGDBExpressions(session); >+ } >+ > return new MIExpressions(session); > } > > @Override > protected IMemory createMemoryService(DsfSession session) { >+ if (fIsMacOSGdb) { >+ return new MIMemory(session); >+ } >+ > if (GDB_7_0_VERSION.compareTo(fVersion) <= 0) { > return new GDBMemory_7_0(session); > } >@@ -121,11 +164,19 @@ > > @Override > protected IModules createModulesService(DsfSession session) { >+ if (fIsMacOSGdb) { >+ return new MIModules(session); >+ } >+ > return new MIModules(session); > } > > @Override > protected IProcesses createProcessesService(DsfSession session) { >+ if (fIsMacOSGdb) { >+ return new GDBProcesses(session); >+ } >+ > if (GDB_7_0_VERSION.compareTo(fVersion) <= 0) { > return new GDBProcesses_7_0(session); > } >@@ -134,11 +185,19 @@ > > @Override > protected IRegisters createRegistersService(DsfSession session) { >+ if (fIsMacOSGdb) { >+ return new MIRegisters(session); >+ } >+ > return new MIRegisters(session); > } > > @Override > protected IRunControl createRunControlService(DsfSession session) { >+ if (fIsMacOSGdb) { >+ return new GDBRunControl(session); >+ } >+ > if (GDB_7_0_VERSION.compareTo(fVersion) <= 0) { > return new GDBRunControl_7_0(session); > } >@@ -147,11 +206,19 @@ > > @Override > protected ISourceLookup createSourceLookupService(DsfSession session) { >+ if (fIsMacOSGdb) { >+ return new CSourceLookup(session); >+ } >+ > return new CSourceLookup(session); > } > > @Override > protected IStack createStackService(DsfSession session) { >+ if (fIsMacOSGdb) { >+ return new MIStack(session); >+ } >+ > return new MIStack(session); > } > } >Index: src/org/eclipse/cdt/dsf/gdb/service/macos/MacOSGDBExpressions.java >=================================================================== >RCS file: src/org/eclipse/cdt/dsf/gdb/service/macos/MacOSGDBExpressions.java >diff -N src/org/eclipse/cdt/dsf/gdb/service/macos/MacOSGDBExpressions.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/dsf/gdb/service/macos/MacOSGDBExpressions.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 Wind River Systems and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Wind River Systems - initial API and implementation >+ * Ericsson - Modified for handling of multiple execution contexts >+ * Ericsson - Created the MacOS version >+ *******************************************************************************/ >+package org.eclipse.cdt.dsf.gdb.service.macos; >+ >+import org.eclipse.cdt.dsf.mi.service.MIExpressions; >+import org.eclipse.cdt.dsf.mi.service.MIVariableManager; >+import org.eclipse.cdt.dsf.service.DsfSession; >+ >+/** >+ * This class implements a debugger expression evaluator as a DSF service. The >+ * primary interface that clients of this class should use is IExpressions. >+ * >+ * This class used to be name ExpressionService in the 1.1 release. >+ * >+ * @since 2.1 >+ */ >+public class MacOSGDBExpressions extends MIExpressions { >+ >+ public MacOSGDBExpressions(DsfSession session) { >+ super(session); >+ } >+ >+ >+ @Override >+ protected MIVariableManager createMIVariableManager() { >+ return new MacOSGDBVariableManager(getSession(), getServicesTracker()); >+ } >+} >Index: src/org/eclipse/cdt/dsf/gdb/service/macos/MacOSGDBVariableManager.java >=================================================================== >RCS file: src/org/eclipse/cdt/dsf/gdb/service/macos/MacOSGDBVariableManager.java >diff -N src/org/eclipse/cdt/dsf/gdb/service/macos/MacOSGDBVariableManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/dsf/gdb/service/macos/MacOSGDBVariableManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,236 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 Monta Vista and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Monta Vista - initial API and implementation >+ * Ericsson - Modified for handling of multiple execution contexts >+ * Ericsson - Major updates for GDB/MI implementation >+ * Ericsson - Major re-factoring to deal with children >+ * Ericsson - Created the MacOS version >+ *******************************************************************************/ >+package org.eclipse.cdt.dsf.gdb.service.macos; >+ >+import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; >+import org.eclipse.cdt.dsf.mi.service.MIVariableManager; >+import org.eclipse.cdt.dsf.mi.service.command.commands.macos.MacOSMIVarUpdate; >+import org.eclipse.cdt.dsf.mi.service.command.output.MIVarChange; >+import org.eclipse.cdt.dsf.mi.service.command.output.macos.MacOSMIVarUpdateInfo; >+import org.eclipse.cdt.dsf.service.DsfServicesTracker; >+import org.eclipse.cdt.dsf.service.DsfSession; >+ >+/** >+ * Manages a list of variable objects as created through GDB/MI commands. >+ * >+ * This class is passed expression-meta-commands which have their own cache. >+ * Therefore, we don't use the standard MICommandCache in this class. >+ * In fact, we can't even use it, because many variableObject MI commands, >+ * should not be cached as they alter the state of the back-end. >+ * >+ * Design details: >+ * ============== >+ * >+ * GDB variable object information >+ * ------------------------------- >+ * o Variable objects are recursively hierarchical, where children can be created through >+ * the parent. >+ * o A varObject created with -var-create is a ROOT >+ * o A varObject created with -var-list-children, is not a root >+ * o Only varObject with no children or varObjects that are pointers can change values >+ * and therefore >+ * those objects can be used with -var-assign >+ * o After a program stops, a varObject must be 'updated' before used >+ * o Only root varObject can be updated with -var-update, which will trigger all >+ * of the root's descendants to be updated. >+ * o Once updated, a varObject need not be updated until the program resumes again; >+ * this is true even after -var-assign is used (because it does an implicit -var-update) >+ * o -var-update will return the list of all modifiable descendants of the udpated root which >+ * have changed >+ * o -var-update will indicate if a root is out-of-scope (which implies that all >+ * its descendants are out-of-scope) >+ * o if a varObject is out-of-scope, another varObject may be valid for the same >+ * expression as the out-of-scope varObject >+ * o deleting a varObject will delete all its descendants, therefore, it is only >+ * necessary to delete roots >+ * >+ * >+ * Class details >+ * ------------- >+ * - We have an MIVariableObject class which represents a variable object in GDB >+ * >+ * - MIVariableObject includes a buffered value for each allowed format. >+ * >+ * - We have an MIRootVariableObject class inheriting from MIVariableObject to describe >+ * root varObjects created with -var-create. Objects created with -var-list-children >+ * are MIVariableObjects only. The root class will keep track of if the root object >+ * needs to be updated, if the root object is out-of-scope, and of a list of all >+ * modifiable descendants of this root. The list of modifiable descendants is >+ * accessed using the gdb-given name to allow quick updates from the -var-update >+ * result (see below.) >+ * >+ * - we do not use -var-list-children for arrays, but create them manually >+ * >+ * - when the program stops, we should mark all roots as needing to be updated. >+ * To achieve this efficiently, we have a dedicated list of roots that are updated. >+ * When the program stops, we go through this list, remove each element and mark it >+ * as needing to be updated. >+ * >+ * - when a varObject is accessed, if its root must be updated, the var-update >+ * command shall be used. The result of that command will indicate all >+ * modifiable descendants that have changed. We also use --all-values with -var-update >+ * to get the new value (in the current format) for each modified descendant. Using the list of modifiable >+ * descendants of the root, we can quickly update the changed ones to invalidate their buffered >+ * values and store the new current format value. >+ * >+ * - all values of non-modifiable varObjects (except arrays) will be set to {...} >+ * without going to the back-end >+ * >+ * - requesting the value of an array varObject will trigger the creation of a new >+ * varObject for the array's address. Note that we must still use a variable >+ * object and not the command -data-evaluate-expression, because we still need to get >+ * the array address in multiple formats. >+ * >+ * - we keep an LRU (Least Recently Used) structure of all variable objects. This LRU >+ * will be bounded to a maximum allowed number of variable objects. Whenever we get an >+ * object from the LRU cleanup will be done if the maximum size has been reached. >+ * The LRU will not delete a parent varObject until all its children are deleted; this is >+ * achieved by touching each of the parents of an object whenever that object is put or get >+ * >+ * - It may happen that when accessing a varObject we find its root to be >+ * out-of-scope. The expression for which we are trying to access a varObject >+ * could still be valid, and therefore we should try to create a new varObject for >+ * that expression. This can happen for example if two methods use the same name >+ * for a variable. In the case when we find that a varObject is out-of-scope (when >+ * its root is out-of-scope) the following should be done: >+ * - replace the varObject in the LRU with a newly created one in GDB >+ * - if the old object was a root, delete it in GDB. >+ * >+ * - In GDB, -var-update will only report a change if -var-evaluate-expression has >+ * changed -- in the current format--. This means that situations like >+ * double z = 1.2; >+ * z = 1.4; >+ * Will not report a change if the format is anything else than natural. >+ * This is because 1.2 and 1.4 are both printed as 1, 0x1, etc >+ * Since we cache the values of every format, we must know if the value has >+ * change in -any- format, not just the current one. >+ * To solve this, we always keep the display format of variable objects (and their >+ * children) to the natural format; we believe that if the value changes in any >+ * format, it guarantees that it will change in the natural format. >+ * The simplest way to do this is that whenever we change the format >+ * of a variable object, we immediately set it back to natural with a second >+ * var-set-format command. >+ * Note that versions of GDB after 6.7 will allows to issue -var-evaluate-expression >+ * with a specified format, therefore allowing us to never use -var-set-format, and >+ * consequently, to easily keep the display format of all variable objects to natural. >+ * >+ * @since 2.1 >+ */ >+public class MacOSGDBVariableManager extends MIVariableManager { >+ >+ public MacOSGDBVariableManager(DsfSession session, DsfServicesTracker tracker) { >+ super(session, tracker); >+ } >+ >+ private class MacOSGDBRootVariableObject extends MIRootVariableObject { >+ >+ public MacOSGDBRootVariableObject(VariableObjectId id) { >+ super(id); >+ } >+ >+ @Override >+ public void update(final DataRequestMonitor<Boolean> rm) { >+ >+ if (isOutOfScope()) { >+ rm.setData(false); >+ rm.done(); >+ } else if (currentState != STATE_READY) { >+ // Object is not fully created or is being updated >+ // so add RequestMonitor to pending queue >+ updatesPending.add(rm); >+ } else if (isOutOfDate() == false) { >+ rm.setData(false); >+ rm.done(); >+ } else { >+ // Object needs to be updated in the back-end >+ currentState = STATE_UPDATING; >+ >+ // In GDB, var-update will only report a change if -var-evaluate-expression has >+ // changed -- in the current format--. This means that situations like >+ // double z = 1.2; >+ // z = 1.4; >+ // Will not report a change if the format is anything else than natural. >+ // This is because 1.2 and 1.4 are both printed as 1, 0x1, etc >+ // Since we cache the values of every format, we must know if -any- format has >+ // changed, not just the current one. >+ // To solve this, we always do an update in the natural format; I am not aware >+ // of any case where the natural format would stay the same, but another format >+ // would change. However, since a var-update update all children as well, >+ // we must make sure these children are also in the natural format >+ // The simplest way to do this is that whenever we change the format >+ // of a variable object, we immediately set it back to natural with a second >+ // var-set-format command. This is done in the getValue() method >+ getCommandControl().queueCommand( >+ new MacOSMIVarUpdate(getRootToUpdate().getControlDMContext(), getGdbName()), >+ new DataRequestMonitor<MacOSMIVarUpdateInfo>(getSession().getExecutor(), rm) { >+ @Override >+ protected void handleCompleted() { >+ currentState = STATE_READY; >+ >+ if (isSuccess()) { >+ markAsOutOfDate(false); >+ >+ MIVarChange[] changes = getData().getMIVarChanges(); >+ if (changes.length > 0 && changes[0].isInScope() == false) { >+ // Object is out-of-scope >+ outOfScope = true; >+ >+ // We can delete this root in GDB right away. This is safe, even >+ // if the root has children, because they are also out-of-scope. >+ // We -must- also remove this entry from our LRU. If we don't >+ // we can end-up with a race condition that create this object >+ // twice, or have an infinite loop while never re-creating the object. >+ // The can happen if we update a child first then we request >+ // the root later, >+ removeVariable(getInternalId()); >+ >+ rm.setData(true); >+ rm.done(); >+ } else { >+ // The root object is now up-to-date, we must parse the changes, if any. >+ processChanges(changes); >+ >+ // We only mark this root as updated in our list if it is in-scope. >+ // For out-of-scope object, we don't ever need to re-update them so >+ // we don't need to add them to this list. >+ rootVariableUpdated(MacOSGDBRootVariableObject.this); >+ >+ rm.setData(false); >+ rm.done(); >+ } >+ >+ while (updatesPending.size() > 0) { >+ DataRequestMonitor<Boolean> pendingRm = updatesPending.poll(); >+ pendingRm.setData(false); >+ pendingRm.done(); >+ } >+ } else { >+ // We were not able to update for some reason >+ rm.setData(false); >+ rm.done(); >+ >+ while (updatesPending.size() > 0) { >+ DataRequestMonitor<Boolean> pendingRm = updatesPending.poll(); >+ pendingRm.setStatus(getStatus()); >+ pendingRm.done(); >+ } >+ } >+ } >+ }); >+ } >+ } >+ } >+ >+} >Index: src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java,v >retrieving revision 1.5 >diff -u -r1.5 MIExpressions.java >--- src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java 17 Dec 2009 18:44:58 -0000 1.5 >+++ src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java 7 Jan 2010 20:21:00 -0000 >@@ -464,6 +464,16 @@ > } > > /** >+ * Creates the MI variable manager to be used by this expression service. >+ * Overriding classes may override to provide a custom services tracker. >+ * >+ * @since 2.1 >+ */ >+ protected MIVariableManager createMIVariableManager() { >+ return new MIVariableManager(getSession(), getServicesTracker()); >+ } >+ >+ /** > * This method shuts down this service. It unregisters the service, stops > * receiving service events, and calls the superclass shutdown() method to > * finish the shutdown process. >Index: src/org/eclipse/cdt/dsf/mi/service/MIVariableManager.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIVariableManager.java,v >retrieving revision 1.2 >diff -u -r1.2 MIVariableManager.java >--- src/org/eclipse/cdt/dsf/mi/service/MIVariableManager.java 4 Mar 2009 04:09:30 -0000 1.2 >+++ src/org/eclipse/cdt/dsf/mi/service/MIVariableManager.java 7 Jan 2010 20:21:01 -0000 >@@ -697,7 +697,7 @@ > } > > if (childVar == null) { >- childVar = new MIVariableObject(childId, MIVariableObject.this); >+ childVar = createChildVariable(childId, MIVariableObject.this); > childVar.setGdbName(child.getVarName()); > childVar.setExpressionData( > childFullExpression, >@@ -770,6 +770,13 @@ > } > > /** >+ * @since 2.1 >+ */ >+ protected MIVariableObject createChildVariable(VariableObjectId id, MIVariableObject parentObj) { >+ return new MIVariableObject(id, parentObj); >+ } >+ >+ /** > * This method builds a child expression based on its parent's expression. > * It is a fallback solution for when GDB doesn't support the var-info-path-expression. > * >@@ -914,7 +921,10 @@ > } > } > >- private class MIRootVariableObject extends MIVariableObject { >+ /** >+ * @since 2.1 >+ */ >+ public class MIRootVariableObject extends MIVariableObject { > > // Only root variables go through the GDB creation process > protected static final int STATE_NOT_CREATED = 10; >@@ -941,7 +951,15 @@ > > public boolean isUpdating() { return currentState == STATE_UPDATING; } > >- public void markAsOutOfDate() { outOfDate = true; } >+ public void markAsOutOfDate() { >+ markAsOutOfDate(true); >+ } >+ >+ public void markAsOutOfDate(boolean outOfDate) { this.outOfDate = outOfDate; } >+ >+ public boolean isOutOfDate() { >+ return outOfDate; >+ } > > // Remember that we must add ourself as a modifiable descendant if our value can change > public void addModifiableDescendant(String gdbName, MIVariableObject descendant) { >@@ -1033,7 +1051,7 @@ > // Object is not fully created or is being updated > // so add RequestMonitor to pending queue > updatesPending.add(rm); >- } else if (outOfDate == false) { >+ } else if (isOutOfDate() == false) { > rm.setData(false); > rm.done(); > } else { >@@ -1063,7 +1081,7 @@ > currentState = STATE_READY; > > if (isSuccess()) { >- outOfDate = false; >+ markAsOutOfDate(false); > > MIVarChange[] changes = getData().getMIVarChanges(); > if (changes.length > 0 && changes[0].isInScope() == false) { >@@ -1077,7 +1095,7 @@ > // twice, or have an infinite loop while never re-creating the object. > // The can happen if we update a child first then we request > // the root later, >- lruVariableList.remove(getInternalId()); >+ removeVariable(getInternalId()); > > rm.setData(true); > rm.done(); >@@ -1088,7 +1106,7 @@ > // We only mark this root as updated in our list if it is in-scope. > // For out-of-scope object, we don't ever need to re-update them so > // we don't need to add them to this list. >- updatedRootList.add(MIRootVariableObject.this); >+ rootVariableUpdated(MIRootVariableObject.this); > > rm.setData(false); > rm.done(); >@@ -1153,8 +1171,9 @@ > * > * Note that if no frameContext is specified (only Execution, or even only Container), which can > * characterize a global variable for example, we will only use the available information. >+ * @since 2.1 > */ >- private class VariableObjectId { >+ public class VariableObjectId { > // We don't use the expression context because it is not safe to compare them > // See bug 187718. So we store the expression itself, and it's parent execution context. > String fExpression = null; >@@ -1338,6 +1357,41 @@ > fSession.removeServiceEventListener(this); > } > >+ /** >+ * @since 2.1 >+ */ >+ protected DsfSession getSession() { >+ return fSession; >+ } >+ >+ /** >+ * @since 2.1 >+ */ >+ protected ICommandControl getCommandControl() { >+ return fCommandControl; >+ } >+ >+ /** >+ * @since 2.1 >+ */ >+ protected MIRootVariableObject createRootVariableObject(VariableObjectId id) { >+ return new MIRootVariableObject(id); >+ } >+ >+ /** >+ * @since 2.1 >+ */ >+ protected void rootVariableUpdated(MIRootVariableObject rootObj) { >+ updatedRootList.add(rootObj); >+ } >+ >+ /** >+ * @since 2.1 >+ */ >+ protected void removeVariable(VariableObjectId id) { >+ lruVariableList.remove(id); >+ } >+ > /** > * This method returns a variable object based on the specified > * ExpressionDMC, creating it in GDB if it was not created already. >@@ -1443,7 +1497,7 @@ > protected void handleCompleted() { > if (isSuccess()) { > // Also store the object as a varObj that is up-to-date >- updatedRootList.add(newVarObj); >+ rootVariableUpdated(newVarObj); > // VarObj can now be used by others > newVarObj.creationCompleted(true); > >@@ -1625,7 +1679,7 @@ > } > }); > >- } else if (command instanceof MIDataEvaluateExpression) { >+ } else if (command instanceof MIDataEvaluateExpression<?>) { > // This does not use the variable objects but sends the command directly to the back-end > fCommandControl.queueCommand(command, rm); > } else { >@@ -1684,7 +1738,7 @@ > public void markAllOutOfDate() { > MIRootVariableObject root; > while ((root = updatedRootList.poll()) != null) { >- root.markAsOutOfDate(); >+ root.markAsOutOfDate(true); > } > } > >Index: src/org/eclipse/cdt/dsf/mi/service/command/commands/macos/MacOSMIVarUpdate.java >=================================================================== >RCS file: src/org/eclipse/cdt/dsf/mi/service/command/commands/macos/MacOSMIVarUpdate.java >diff -N src/org/eclipse/cdt/dsf/mi/service/command/commands/macos/MacOSMIVarUpdate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/dsf/mi/service/command/commands/macos/MacOSMIVarUpdate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,49 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 QNX Software Systems and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * QNX Software Systems - Initial API and implementation >+ * Wind River Systems - Modified for new DSF Reference Implementation >+ * Ericsson - Modified for handling of frame contexts >+ *******************************************************************************/ >+ >+package org.eclipse.cdt.dsf.mi.service.command.commands.macos; >+ >+import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; >+import org.eclipse.cdt.dsf.mi.service.command.commands.MICommand; >+import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput; >+import org.eclipse.cdt.dsf.mi.service.command.output.macos.MacOSMIVarUpdateInfo; >+ >+/** >+ * >+ * -var-update [print-values] {NAME | "*"} >+ * >+ * Update the value of the variable object NAME by evaluating its >+ * expression after fetching all the new values from memory or registers. >+ * A `*' causes all existing variable objects to be updated. >+ * If print-values has a value for of 0 or --no-values, print only the names of the variables; >+ * if print-values is 1 or --all-values, also print their values; >+ * if it is 2 or --simple-values print the name and value for simple data types and just >+ * the name for arrays, structures and unions. >+ * >+ * It seems that for MacOS, we must use the full string for print-values, such as >+ * --all-values. >+ * >+ * @since 2.1 >+ */ >+public class MacOSMIVarUpdate extends MICommand<MacOSMIVarUpdateInfo> { >+ >+ public MacOSMIVarUpdate(ICommandControlDMContext dmc, String name) { >+ // Must use --all-values instead of 1 for Mac OS >+ super(dmc, "-var-update", new String[] { "--all-values", name }); //$NON-NLS-1$//$NON-NLS-2$ >+ } >+ >+ @Override >+ public MacOSMIVarUpdateInfo getResult(MIOutput out) { >+ return new MacOSMIVarUpdateInfo(out); >+ } >+} >Index: src/org/eclipse/cdt/dsf/mi/service/command/output/macos/MacOSMIVarUpdateInfo.java >=================================================================== >RCS file: src/org/eclipse/cdt/dsf/mi/service/command/output/macos/MacOSMIVarUpdateInfo.java >diff -N src/org/eclipse/cdt/dsf/mi/service/command/output/macos/MacOSMIVarUpdateInfo.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/dsf/mi/service/command/output/macos/MacOSMIVarUpdateInfo.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,123 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 QNX Software Systems and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * QNX Software Systems - Initial API and implementation >+ * Ericsson - Created version for Mac OS >+ *******************************************************************************/ >+package org.eclipse.cdt.dsf.mi.service.command.output.macos; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.cdt.dsf.mi.service.command.output.MIConst; >+import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; >+import org.eclipse.cdt.dsf.mi.service.command.output.MIList; >+import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput; >+import org.eclipse.cdt.dsf.mi.service.command.output.MIResult; >+import org.eclipse.cdt.dsf.mi.service.command.output.MIResultRecord; >+import org.eclipse.cdt.dsf.mi.service.command.output.MITuple; >+import org.eclipse.cdt.dsf.mi.service.command.output.MIValue; >+import org.eclipse.cdt.dsf.mi.service.command.output.MIVarChange; >+ >+/** >+ * GDB/MI var-update for Mac OS. >+ * -var-update * >+ * ^done,changelist=[varobj={name="var1",in_scope="true",type_changed="false"}],time={.....} >+ * >+ * @since 2.1 >+ */ >+public class MacOSMIVarUpdateInfo extends MIInfo { >+ >+ MIVarChange[] changeList; >+ >+ public MacOSMIVarUpdateInfo(MIOutput record) { >+ super(record); >+ List<MIVarChange> aList = new ArrayList<MIVarChange>(); >+ if (isDone()) { >+ MIOutput out = getMIOutput(); >+ MIResultRecord rr = out.getMIResultRecord(); >+ if (rr != null) { >+ MIResult[] results = rr.getMIResults(); >+ for (int i = 0; i < results.length; i++) { >+ String var = results[i].getVariable(); >+ if (var.equals("changelist")) { //$NON-NLS-1$ >+ MIValue value = results[i].getMIValue(); >+ if (value instanceof MITuple) { >+ parseChangeList((MITuple)value, aList); >+ } else if (value instanceof MIList) { >+ parseChangeList((MIList)value, aList); >+ } >+ } >+ } >+ } >+ } >+ changeList = aList.toArray(new MIVarChange[aList.size()]); >+ } >+ >+ public MIVarChange[] getMIVarChanges() { >+ return changeList; >+ } >+ >+ /** >+ * For MI2 the format is now a MIList. >+ * @param tuple >+ * @param aList >+ */ >+ void parseChangeList(MIList miList, List<MIVarChange> aList) { >+ // The MIList in Apple gdb contains MIResults instead of MIValues. It looks like: >+ // ^done,changelist=[varobj={name="var1",in_scope="true",type_changed="false"}],time={.....} >+ // Bug 250037 >+ MIResult[] results = miList.getMIResults(); >+ for (int i = 0; i < results.length; i++) { >+ String var = results[i].getVariable(); >+ if (var.equals("varobj")) { //$NON-NLS-1$ >+ MIValue value = results[i].getMIValue(); >+ if (value instanceof MITuple) { >+ parseChangeList((MITuple)value, aList); >+ } else if (value instanceof MIList) { >+ parseChangeList((MIList)value, aList); >+ } >+ } >+ } >+ } >+ >+ void parseChangeList(MITuple tuple, List<MIVarChange> aList) { >+ MIResult[] results = tuple.getMIResults(); >+ MIVarChange change = null; >+ for (int i = 0; i < results.length; i++) { >+ String var = results[i].getVariable(); >+ MIValue value = results[i].getMIValue(); >+ if (value instanceof MITuple) { >+ parseChangeList((MITuple)value, aList); >+ } >+ else >+ { >+ String str = ""; //$NON-NLS-1$ >+ if (value instanceof MIConst) { >+ str = ((MIConst)value).getString(); >+ } >+ if (var.equals("name")) { //$NON-NLS-1$ >+ change = new MIVarChange(str); >+ aList.add(change); >+ } else if (var.equals("value")) { //$NON-NLS-1$ >+ if (change != null) { >+ change.setValue(str); >+ } >+ } else if (var.equals("in_scope")) { //$NON-NLS-1$ >+ if (change != null) { >+ change.setInScope("true".equals(str)); //$NON-NLS-1$ >+ } >+ } else if (var.equals("type_changed")) { //$NON-NLS-1$ >+ if (change != null) { >+ change.setChanged("true".equals(str)); //$NON-NLS-1$ >+ } >+ } >+ } >+ } >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 298883
:
155504
|
155544
|
155563
|
155564
|
155570
|
155584
|
155648