From 125213c8bef11cd1babf9d48c0a1fcc6c2dfab82 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Tue, 20 Apr 2004 16:03:27 +0000 Subject: [PATCH] The "getCFileGlobals" method of "IExecFileInfo" throws "DebugException". --- debug/org.eclipse.cdt.debug.core/ChangeLog | 8 +++++ .../cdt/debug/core/model/IExecFileInfo.java | 27 ++++++++------- .../internal/core/model/CDebugTarget.java | 14 +++++--- .../core/model/CoreModelMessages.java | 33 +++++++++++++++++++ .../core/model/CoreModelMessages.properties | 3 ++ .../internal/core/model/Disassembly.java | 4 +-- 6 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CoreModelMessages.java create mode 100644 debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CoreModelMessages.properties diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index e58d5d98362..d86c5413758 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,11 @@ +2004-04-20 Mikhail Khodjaiants + The "getCFileGlobals" method of "IExecFileInfo" throws "DebugException". + * IExecFileInfo.java + * CoreModelMessages.properties + * CDebugTarget.java + * CoreModelMessages.java + * Disassembly.java + 2004-04-19 Alain Magloire CoreModel throws Exception. diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IExecFileInfo.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IExecFileInfo.java index 185200fbbe7..677f4f41ac9 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IExecFileInfo.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IExecFileInfo.java @@ -1,23 +1,26 @@ -/* - *(c) Copyright QNX Software Systems Ltd. 2002. - * All Rights Reserved. +/********************************************************************** + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html * - */ - + * Contributors: + * QNX Software Systems - Initial API and implementation + ***********************************************************************/ package org.eclipse.cdt.debug.core.model; import org.eclipse.core.resources.IFile; +import org.eclipse.debug.core.DebugException; /** * Provides access to executable file information. - * - * @since: Nov 1, 2002 */ -public interface IExecFileInfo -{ +public interface IExecFileInfo { + public IFile getExecFile(); public boolean isLittleEndian(); - - public IGlobalVariable[] getGlobals(); -} + + public IGlobalVariable[] getGlobals() throws DebugException; +} \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java index c3145795c51..7324df41895 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java @@ -2011,7 +2011,7 @@ public class CDebugTarget extends CDebugElement /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.IExecFileInfo#getGlobals() */ - public IGlobalVariable[] getGlobals() + public IGlobalVariable[] getGlobals() throws DebugException { ArrayList list = new ArrayList(); if ( getExecFile() != null && CoreModel.getDefault().isBinary( getExecFile() ) ) @@ -2025,10 +2025,11 @@ public class CDebugTarget extends CDebugElement return (IGlobalVariable[])list.toArray( new IGlobalVariable[list.size()] ); } - private List getCFileGlobals( IParent file ) + private List getCFileGlobals( IParent file ) throws DebugException { ArrayList list = new ArrayList(); - try { + try + { ICElement[] elements = file.getChildren(); for ( int i = 0; i < elements.length; ++i ) { @@ -2041,7 +2042,10 @@ public class CDebugTarget extends CDebugElement list.addAll( getCFileGlobals( (org.eclipse.cdt.core.model.IParent)elements[i] ) ); } } - } catch (CModelException e) { + } + catch( CModelException e ) + { + requestFailed( CoreModelMessages.getString( "CDebugTarget.Unable_to_get_globals_1" ) + e.getMessage(), e ); //$NON-NLS-1$ } return list; } @@ -2057,7 +2061,7 @@ public class CDebugTarget extends CDebugElement public IPath getPath() { - IPath path = new Path(""); //$NON-NLS-1$ + IPath path = new Path( "" ); //$NON-NLS-1$ ICElement parent = var.getParent(); if ( parent instanceof IBinaryModule ) { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CoreModelMessages.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CoreModelMessages.java new file mode 100644 index 00000000000..b109caa0e35 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CoreModelMessages.java @@ -0,0 +1,33 @@ +/********************************************************************** + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.debug.internal.core.model; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class CoreModelMessages { + + private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.core.model.CoreModelMessages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + + private CoreModelMessages() { + } + + public static String getString( String key ) { + try { + return RESOURCE_BUNDLE.getString( key ); + } + catch( MissingResourceException e ) { + return '!' + key + '!'; + } + } +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CoreModelMessages.properties b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CoreModelMessages.properties new file mode 100644 index 00000000000..027757694c3 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CoreModelMessages.properties @@ -0,0 +1,3 @@ +CDebugTarget.Unable_to_get_globals_1=Unable to get globals. Reason: +Disassembly.Unable_to_get_disassembly_instructions_1=Unable to get disassembly instructions. +Disassembly.Unable_to_get_disassembly_instructions_2=Unable to get disassembly instructions. diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/Disassembly.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/Disassembly.java index 0a6f4e9262a..6de16be6ed4 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/Disassembly.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/Disassembly.java @@ -95,7 +95,7 @@ public class Disassembly extends CDebugElement implements IDisassembly { CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_MAX_NUMBER_OF_INSTRUCTIONS ) ); } catch( CDIException e ) { - targetRequestFailed( "Unable to get disassembly instructions.", e ); + targetRequestFailed( CoreModelMessages.getString( "Disassembly.Unable_to_get_disassembly_instructions_1" ), e ); //$NON-NLS-1$ } } if ( instructions.length == 0 || @@ -106,7 +106,7 @@ public class Disassembly extends CDebugElement implements IDisassembly { instructions = getFunctionInstructions( sm.getInstructions( address, address + DISASSEMBLY_BLOCK_SIZE ) ); } catch( CDIException e ) { - targetRequestFailed( "Unable to get disassembly instructions.", e ); + targetRequestFailed( CoreModelMessages.getString( "Disassembly.Unable_to_get_disassembly_instructions_2" ), e ); //$NON-NLS-1$ } } }