|
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 | 13 ++++++++++++- |
365 |
.../cdt/debug/edc/internal/symbols/Scope.java | 13 ++++++++++++- |
| 317 |
1 files changed, 12 insertions(+), 1 deletions(-) |
366 |
1 files changed, 12 insertions(+), 1 deletions(-) |