Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 353605 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.cdt.debug.edc/src/org/eclipse/cdt/debug/edc/internal/symbols/Scope.java (-7 / +56 lines)
Lines 13-18 package org.eclipse.cdt.debug.edc.internal.symbols; Link Here
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.Collection;
14
import java.util.Collection;
15
import java.util.Collections;
15
import java.util.Collections;
16
import java.util.Iterator;
16
import java.util.List;
17
import java.util.List;
17
import java.util.SortedMap;
18
import java.util.SortedMap;
18
import java.util.TreeMap;
19
import java.util.TreeMap;
Lines 69-75 public abstract class Scope implements IScope { Link Here
69
		return (lowAddress == null || highAddress == null)
70
		return (lowAddress == null || highAddress == null)
70
		|| (lowAddress.isZero() && highAddress.isZero())
71
		|| (lowAddress.isZero() && highAddress.isZero())
71
		|| (lowAddress.getValue().longValue() == -1 && highAddress.isZero()); // TODO: remove this case
72
		|| (lowAddress.getValue().longValue() == -1 && highAddress.isZero()); // TODO: remove this case
72
	}
73
	}//FIXME: looks like a bug: no test that lowAddress.equals(highAddress)
73
74
74
	/**
75
	/**
75
	 * Return the list of non-contiguous ranges for this scope.
76
	 * Return the list of non-contiguous ranges for this scope.
Lines 287-294 public abstract class Scope implements IScope { Link Here
287
			{
288
			{
288
				if (rangeList != null) {
289
				if (rangeList != null) {
289
					if (scope.getRangeList() != null) {
290
					if (scope.getRangeList() != null) {
290
						// TODO: merge properly
291
						rangeList = mergeRangeLists(rangeList,scope.getRangeList());
291
						rangeList = null;
292
					} else {
292
					} else {
293
						((RangeList)rangeList).addLowRange(scope.getLowAddress().getValue().longValue());
293
						((RangeList)rangeList).addLowRange(scope.getLowAddress().getValue().longValue());
294
					}
294
					}
Lines 298-305 public abstract class Scope implements IScope { Link Here
298
			if (scope.getHighAddress() != null && scope.getHighAddress().compareTo(highAddress) > 0) {
298
			if (scope.getHighAddress() != null && scope.getHighAddress().compareTo(highAddress) > 0) {
299
				if (rangeList != null) {
299
				if (rangeList != null) {
300
					if (scope.getRangeList() != null) {
300
					if (scope.getRangeList() != null) {
301
						// TODO: merge properly
301
						rangeList = mergeRangeLists(rangeList,scope.getRangeList());
302
						rangeList = null;
303
					} else {
302
					} else {
304
						((RangeList)rangeList).addHighRange(scope.getHighAddress().getValue().longValue());
303
						((RangeList)rangeList).addHighRange(scope.getHighAddress().getValue().longValue());
305
					}
304
					}
Lines 308-313 public abstract class Scope implements IScope { Link Here
308
			}	
307
			}	
309
		}
308
		}
310
	}
309
	}
310
	protected IRangeList mergeRangeLists(IRangeList first, IRangeList second){
311
		Iterator<IRangeList.Entry> firstIterator = first.iterator();
312
		Iterator<IRangeList.Entry> secondIterator = second.iterator();
313
		RangeList answer = new RangeList();
314
		IRangeList.Entry firstHead = null;
315
		IRangeList.Entry secondHead = null;
316
		while (firstIterator.hasNext() || secondIterator.hasNext()
317
				|| firstHead != null || secondHead != null){
318
			if (firstHead == null && firstIterator.hasNext()){
319
				firstHead = firstIterator.next();
320
			}
321
			if (secondHead == null && secondIterator.hasNext()){
322
				secondHead = secondIterator.next();
323
			}
324
			if (firstHead == null){
325
				if (secondHead != null){
326
					answer.addRange(secondHead.low, secondHead.high);
327
					secondHead = null;
328
				}// else we have no more work to do and will exit at the end of the loop
329
			} else {
330
				if (secondHead == null){
331
					answer.addRange(firstHead.low,firstHead.high);
332
					firstHead = null;
333
				} else {// both not null so work to do
334
					long low,high;
335
					if (firstHead.low <= secondHead.low){
336
						low = firstHead.low;
337
						if (firstHead.high < secondHead.low){// we are just using firstHead
338
							high = firstHead.high;
339
							firstHead = null;
340
						} else {// overlap so use both
341
							high = Math.max(firstHead.high, secondHead.high);
342
							firstHead = null;
343
							secondHead = null;
344
						}
345
					} else {
346
						low = secondHead.low;
347
						if (secondHead.high < firstHead.low){// just using secondHead
348
							high = secondHead.high;
349
							secondHead = null;
350
						} else { // overlap so use both
351
							high = Math.max(firstHead.high, secondHead.high);
352
							firstHead = null;
353
							secondHead = null;
354
						}
355
					}
356
					answer.addRange(low,high);
357
				}
358
			}
359
		}
360
		return answer;
361
	}
311
	
362
	
312
	protected void addLineInfoToParent(IScope scope) {
363
	protected void addLineInfoToParent(IScope scope) {
313
		IScope cu = parent;
364
		IScope cu = parent;
314
- 
315
--
316
.../cdt/debug/edc/internal/symbols/Scope.java      |   16 ++++++++++++++--
365
.../cdt/debug/edc/internal/symbols/Scope.java      |   16 ++++++++++++++--
317
1 files changed, 14 insertions(+), 2 deletions(-)
366
1 files changed, 14 insertions(+), 2 deletions(-)
(-)a/org.eclipse.cdt.debug.edc/src/org/eclipse/cdt/debug/edc/internal/symbols/Scope.java (-4 / +14 lines)
Lines 233-238 public abstract class Scope implements IScope { Link Here
233
		// figure it out from the functions
233
		// figure it out from the functions
234
		IAddress newLowAddress = Addr64.MAX;
234
		IAddress newLowAddress = Addr64.MAX;
235
		IAddress newHighAddress = Addr64.ZERO;
235
		IAddress newHighAddress = Addr64.ZERO;
236
		IRangeList newRangeList = new RangeList();
236
		boolean any = false;
237
		boolean any = false;
237
		
238
		
238
		for (IScope kid : getChildren()) {
239
		for (IScope kid : getChildren()) {
Lines 243-250 public abstract class Scope implements IScope { Link Here
243
			if (kid.hasEmptyRange()) {
244
			if (kid.hasEmptyRange()) {
244
				continue;
245
				continue;
245
			}
246
			}
246
			
247
247
			if (kid.getLowAddress().compareTo(baseAddress) > 0) {
248
			if (kid.getLowAddress().compareTo(baseAddress) > 0) {
249
				IRangeList kidRanges = kid.getRangeList();
250
				if (kidRanges == null){// If it didn't have ranges it still has one range
251
					kidRanges = new RangeList();
252
					((RangeList)kidRanges).addRange(kid.getLowAddress().getValue().longValue(),kid.getHighAddress().getValue().longValue());
253
				}
254
				newRangeList = mergeRangeLists(newRangeList,kidRanges);
255
248
				if (kid.getLowAddress().compareTo(newLowAddress) < 0) {
256
				if (kid.getLowAddress().compareTo(newLowAddress) < 0) {
249
					newLowAddress = kid.getLowAddress();
257
					newLowAddress = kid.getLowAddress();
250
					any = true;
258
					any = true;
Lines 261-267 public abstract class Scope implements IScope { Link Here
261
			//System.out.println("Needed to fix up ranges for " + getName());
269
			//System.out.println("Needed to fix up ranges for " + getName());
262
			lowAddress = newLowAddress; 
270
			lowAddress = newLowAddress; 
263
			highAddress = newHighAddress;
271
			highAddress = newHighAddress;
264
			rangeList = null;
272
			int entryCount = 0;
273
			for (@SuppressWarnings("unused") IRangeList.Entry entry : newRangeList){
274
				++entryCount;
275
			}
276
			rangeList = (entryCount > 1) ? newRangeList : null;
265
		} else {
277
		} else {
266
			if (lowAddress == null) {
278
			if (lowAddress == null) {
267
				lowAddress = highAddress = Addr32.ZERO;
279
				lowAddress = highAddress = Addr32.ZERO;
268
- 
269
--
270
.../internal/symbols/dwarf/DwarfInfoReader.java    |    5 ++++-
280
.../internal/symbols/dwarf/DwarfInfoReader.java    |    5 ++++-
271
1 files changed, 4 insertions(+), 1 deletions(-)
281
1 files changed, 4 insertions(+), 1 deletions(-)
(-)a/org.eclipse.cdt.debug.edc/src/org/eclipse/cdt/debug/edc/internal/symbols/dwarf/DwarfInfoReader.java (-2 / +4 lines)
Lines 1915-1920 public class DwarfInfoReader { Link Here
1915
				 */
1915
				 */
1916
	
1916
	
1917
				RangeList list = new RangeList();
1917
				RangeList list = new RangeList();
1918
				//Whether the list actually got anything added - otherwise we should return null
1919
				boolean listAddedTo = false;
1918
	
1920
	
1919
				long base = 0;
1921
				long base = 0;
1920
				long start = data.getInt();
1922
				long start = data.getInt();
Lines 1937-1942 public class DwarfInfoReader { Link Here
1937
						// ignore bogus entries: GCC-E sometimes generates these buggily (for artifical non-inlined functions)
1939
						// ignore bogus entries: GCC-E sometimes generates these buggily (for artifical non-inlined functions)
1938
						if (base + start >= codeRanges.getLowAddress()) {
1940
						if (base + start >= codeRanges.getLowAddress()) {
1939
							list.addRange(base + start, base + end);
1941
							list.addRange(base + start, base + end);
1942
							listAddedTo = true;
1940
						}
1943
						}
1941
					}
1944
					}
1942
					start = data.getInt();
1945
					start = data.getInt();
Lines 1944-1950 public class DwarfInfoReader { Link Here
1944
					
1947
					
1945
				} while (true);
1948
				} while (true);
1946
				
1949
				
1947
				return list;
1950
				return (listAddedTo) ? list : null;
1948
				
1951
				
1949
			} catch (Throwable t) {
1952
			} catch (Throwable t) {
1950
				EDCDebugger.getMessageLogger().logError(DwarfMessages.DwarfInfoReader_RangeReadFailed, t);
1953
				EDCDebugger.getMessageLogger().logError(DwarfMessages.DwarfInfoReader_RangeReadFailed, t);
1951
- 

Return to bug 353605