From 22b835c2774b1e009183e5dd01b151224953254d Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Tue, 19 Nov 2002 22:55:00 +0000 Subject: [PATCH] Partial fix for bug 25956. Filter out the instructions that do not belong to the current function. --- debug/org.eclipse.cdt.debug.core/ChangeLog | 4 ++ .../core/sourcelookup/DisassemblyManager.java | 37 ++++++++++++++++--- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 6bd01851916..5e6a983ebe7 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,7 @@ +2002-11-15 Mikhail Khodjaiants + Partial fix for bug 25956. + * DisassemblyManager.java: Filter out the instructions that do not belong to the function. + 2002-11-15 Mikhail Khodjaiants If the backtrace is very deep the debugger is unable to parse MI output. The limited number of stack frames will be displayed. diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/DisassemblyManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/DisassemblyManager.java index b4d3bc55d84..7910c889821 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/DisassemblyManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/DisassemblyManager.java @@ -6,6 +6,8 @@ package org.eclipse.cdt.debug.internal.core.sourcelookup; +import java.util.ArrayList; + import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.IStackFrameInfo; import org.eclipse.cdt.debug.core.cdi.CDIException; @@ -105,12 +107,15 @@ public class DisassemblyManager String fileName = frameInfo.getFile(); int lineNumber = frameInfo.getFrameLineNumber(); ICDIInstruction[] instructions = new ICDIInstruction[0]; - try - { - instructions = sm.getInstructions( fileName, lineNumber, DISASSEMBLY_MAX_LINE_COUNT ); - } - catch( CDIException e ) + if ( fileName != null && fileName.length() > 0 ) { + try + { + instructions = sm.getInstructions( fileName, lineNumber, DISASSEMBLY_MAX_LINE_COUNT ); + } + catch( CDIException e ) + { + } } if ( instructions.length == 0 ) { @@ -119,7 +124,7 @@ public class DisassemblyManager { try { - instructions = sm.getInstructions( address, address + DISASSEMBLY_BLOCK_SIZE ); + instructions = getFunctionInstructions( sm.getInstructions( address, address + DISASSEMBLY_BLOCK_SIZE ) ); } catch( CDIException e ) { @@ -135,4 +140,24 @@ public class DisassemblyManager } return getDisassemblyStorage(); } + + private ICDIInstruction[] getFunctionInstructions( ICDIInstruction[] rawInstructions ) + { + if ( rawInstructions.length > 0 && + rawInstructions[0].getFuntionName() != null && + rawInstructions[0].getFuntionName().length() > 0 ) + { + ArrayList list = new ArrayList( rawInstructions.length ); + list.add( rawInstructions[0] ); + for ( int i = 1; i < rawInstructions.length; ++i ) + { + if ( rawInstructions[0].getFuntionName().equals( rawInstructions[i].getFuntionName() ) ) + { + list.add( rawInstructions[i] ); + } + } + return (ICDIInstruction[])list.toArray( new ICDIInstruction[list.size()] ); + } + return rawInstructions; + } }