Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 29693 Details for
Bug 115804
Enable thread name display
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Implements CLIInfoThreadsInfo
DisplayThreadNames-01.diff (text/plain), 4.73 KB, created by
Norbert Plött
on 2005-11-10 08:24:08 EST
(
hide
)
Description:
Implements CLIInfoThreadsInfo
Filename:
MIME Type:
Creator:
Norbert Plött
Created:
2005-11-10 08:24:08 EST
Size:
4.73 KB
patch
obsolete
>Index: D:/Projekt/RTP/Work3.1/org.eclipse.cdt.debug.mi.core/src-cdtmicore/org/eclipse/cdt/debug/mi/core/output/CLIInfoThreadsInfo.java >=================================================================== >--- D:/Projekt/RTP/Work3.1/org.eclipse.cdt.debug.mi.core/src-cdtmicore/org/eclipse/cdt/debug/mi/core/output/CLIInfoThreadsInfo.java (revision 110) >+++ D:/Projekt/RTP/Work3.1/org.eclipse.cdt.debug.mi.core/src-cdtmicore/org/eclipse/cdt/debug/mi/core/output/CLIInfoThreadsInfo.java (working copy) >@@ -12,18 +12,22 @@ > > import java.util.ArrayList; > import java.util.Arrays; >+import java.util.Comparator; > import java.util.List; > > /** > * GDB/MI thread list parsing. >-~"\n" >-~" 2 Thread 2049 (LWP 29354) " >-~"* 1 Thread 1024 (LWP 29353) " >+~" 5 Thread 8 ( Name: TIMERThread, State: sleeping, Priority: 14 ) " >+~" 4 Thread 3 ( Name: Network support, State: sleeping, Priority: 7 ) " >+~" 3 Thread 2 ( Name: Network alarm support, State: sleeping, Priority: 6 ) " >+~" 2 Thread 1 ( Name: Idle Thread, State: ready, Priority:31 ) " >+~"* 1 Thread 9 ( Name: pthread.00000800, State: running, Priority: 15 ) " > > */ > public class CLIInfoThreadsInfo extends MIInfo { > > protected int[] threadIds; >+ protected String[] threadNames ; > protected int currentThreadId; > > public CLIInfoThreadsInfo(MIOutput out) { >@@ -36,7 +40,7 @@ > } > > public String[] getThreadNames() { >- return null; >+ return threadNames ; > } > > public int getCurrentThread() { >@@ -44,7 +48,8 @@ > } > > protected void parse() { >- List aList = new ArrayList(); >+ List infoList = new ArrayList(); >+ // Compile thread list information > if (isDone()) { > MIOutput out = getMIOutput(); > MIOOBRecord[] oobs = out.getMIOOBRecords(); >@@ -53,19 +58,30 @@ > MIStreamRecord cons = (MIStreamRecord) oobs[i]; > String str = cons.getString(); > // We are interested in finding the current thread >- parseThreadInfo(str.trim(), aList); >+ parseThreadInfo(str.trim(), infoList); > } > } > } >- threadIds = new int[aList.size()]; >- for (int i = 0; i < aList.size(); i++) { >- threadIds[i] = ((Integer) aList.get(i)).intValue(); >+ // Sort information >+ ThreadInfo[] infos = (ThreadInfo[]) infoList.toArray(new ThreadInfo[infoList.size()]); >+ Arrays.sort(infos, new ThreadInfoComparator()); >+ // Extract information for quick reference >+ threadIds = new int[infos.length]; >+ threadNames = new String[infos.length]; >+ for (int i = 0; i < infos.length; i++) { >+ threadIds[i] = infos[i].threadId ; >+ threadNames[i] = infos[i].threadName ; > } >- Arrays.sort(threadIds); > } > >- protected void parseThreadInfo(String str, List aList) { >+ /** >+ * Make this method private because a private internal class is passed through the List >+ * @param str The string with the thread information >+ * @param infoList The list of ThreadInfo objects parsed. Another info object will be appended! >+ */ >+ private void parseThreadInfo(String str, List infoList) { > if (str.length() > 0) { >+ ThreadInfo info = new ThreadInfo(); > boolean isCurrentThread = false; > // Discover the current thread > if (str.charAt(0) == '*') { >@@ -81,13 +97,55 @@ > String number = str.substring(0, i); > try { > Integer num = Integer.valueOf(number); >- aList.add(num); >+ info.threadId = num.intValue(); > if (isCurrentThread) { >- currentThreadId = num.intValue(); >+ currentThreadId = info.threadId; > } > } catch (NumberFormatException e) { > } > } >+ // Probe for name >+ // When no name is given we have the default empty string >+ int nameFieldStartIndex = str.indexOf("Name: "); >+ if (nameFieldStartIndex>0) { >+ int nameStartIndex = nameFieldStartIndex + "Name: ".length(); >+ int nameEndIndex = str.indexOf(",", nameStartIndex); >+ info.threadName = str.substring(nameStartIndex, nameEndIndex); >+ } >+ infoList.add(info); > } > } >+ >+ /** >+ * This is a minimal capsule class for thread related information >+ */ >+ private class ThreadInfo { >+ public ThreadInfo() { >+ threadName = "" ; // avoid null pointer problems >+ } >+ public int threadId ; >+ public String threadName ; >+ } >+ >+ /** >+ * Sort ThreadInfo objects by thread id, ascending >+ */ >+ private class ThreadInfoComparator implements Comparator { >+ >+ /* (non-Javadoc) >+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) >+ */ >+ public int compare(Object arg0, Object arg1) { >+ if (!(arg0 instanceof ThreadInfo) || !(arg1 instanceof ThreadInfo)) { >+ IllegalArgumentException iae = new IllegalArgumentException("Illegal type (or null) for ThreadInfoComparator.compare()!"); >+ iae.fillInStackTrace(); >+ throw iae ; >+ } >+ ThreadInfo info0 = (ThreadInfo) arg0 ; >+ ThreadInfo info1 = (ThreadInfo) arg1 ; >+ >+ return info0.threadId - info1.threadId ; >+ } >+ >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
cdtdoug
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 115804
: 29693