# HG changeset patch # User Alexander Simon # Date 1444928492 -10800 # Thu Oct 15 20:01:32 2015 +0300 # Node ID 65a119f19951f6187fd7ac4dbe94e2ebebe8d002 # Parent 5829037521bd48c967bb14d61a9243fc0e5182c6 fixed Bug #255956 User can't add thread number into "Thread" field in "New Breakpoint" if number has more then 31 bits diff --git a/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/values/AId.java b/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/values/AId.java --- a/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/values/AId.java +++ b/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/values/AId.java @@ -44,6 +44,8 @@ package org.netbeans.modules.cnd.debugger.common2.values; +import java.math.BigInteger; + /** * thread and lwps are collectively known as "active entities" * so their Id's are AId's. @@ -68,6 +70,24 @@ return true; } + private static boolean isLongDecimalNumber(String s) { + try { + // we don't like negative numbers either + if (s.startsWith("-")) {// NOI18N + return false; + } + BigInteger bi = new BigInteger(s); + if (bi.bitLength() > 64) { + // cannot be represented by java long + return false; + } + } catch(NumberFormatException x) { + return false; + } + + return true; + } + /** * Validate & interpret 'text' per the additional flags. * An invalid value will have 'errorMessage != null' @@ -117,11 +137,19 @@ } else { numberPart = text; } - if (!isDecimalNumber(numberPart)) { + if (!isLongDecimalNumber(numberPart)) { errorMessage = Catalog.get("MSG_AId_MalformedThread"); // NOI18N return; } - id = "t@" + Long.parseLong(numberPart); // NOI18N + BigInteger big = new BigInteger(numberPart); + long lid = big.longValue(); + if (lid < 0) { + BigInteger max = BigInteger.ONE.shiftLeft(64); + BigInteger bi = BigInteger.valueOf(lid); + id = "t@" + bi.add(max).toString(); // NOI18N + } else { + id = "t@" + Long.toString(lid); // NOI18N + } } else { // Java thread names are strings so can by _anything_ id = text;