Changeset bb75b4e
- Timestamp:
- Mar 12, 2020, 5:55:30 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 96df7c9c
- Parents:
- 5c08a1a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/gdb/utils-gdb.py
r5c08a1a rbb75b4e 74 74 return str_addr[:ending_addr_index].strip() 75 75 76 def print_usage(msg): 77 """ 78 Print out usage message 79 @msg: str 80 """ 81 print('Usage: ' + msg) 76 def print_usage(obj): 77 print(obj.__doc__) 82 78 83 79 def parse(args): … … 150 146 151 147 class Clusters(gdb.Command): 152 """Print out the list of available clusters""" 153 usage_msg = 'clusters' 154 str_format = '' 148 """Cforall: Display currently known clusters 149 Usage: 150 info clusters : print out all the clusters 151 """ 155 152 156 153 def __init__(self): 157 super(Clusters, self).__init__(' clusters', gdb.COMMAND_USER)154 super(Clusters, self).__init__('info clusters', gdb.COMMAND_USER) 158 155 159 156 def print_cluster(self, cluster_name, cluster_address): 160 157 print('{:>20} {:>20}'.format(cluster_name, cluster_address)) 161 158 159 #entry point from gdb 162 160 def invoke(self, arg, from_tty): 163 """164 Iterate through a circular linked list of clusters and print out its165 name along with address associated to each cluster166 @arg: str167 @from_tty: bool168 """169 161 if not is_cforall(): 170 162 return 171 163 172 argv = parse(arg)173 if len(argv) != 0:174 print_usage( 'clusters')164 if arg: 165 print("info clusters does not take arguments") 166 print_usage(self) 175 167 return 176 168 … … 192 184 ############ 193 185 class Processors(gdb.Command): 194 """Display a list of all info about all available processors on a particular cluster""" 195 usage_msg = """ 196 processors : print out all the processors in the Main Cluster 197 processors <cluster_name> : print out all processors in a given cluster""" 186 """Cforall: Display currently known processors 187 Usage: 188 info processors : print out all the processors in the Main Cluster 189 info processors <cluster_name> : print out all processors in a given cluster 190 """ 198 191 199 192 def __init__(self): 200 super(Processors, self).__init__(' processors', gdb.COMMAND_USER)193 super(Processors, self).__init__('info processors', gdb.COMMAND_USER) 201 194 202 195 def print_processor(self, name, status, pending, address): 203 print('{:>20} {:> 20} {:>13} {:>20}'.format(name, status, pending, address))204 205 def iterate_procs(self, root ):196 print('{:>20} {:>11} {:>13} {:>20}'.format(name, status, pending, address)) 197 198 def iterate_procs(self, root, active): 206 199 if root == 0x0: 207 print('{:>20}'.format("None"))208 200 return 209 201 210 202 cfa_t = get_cfa_types() 211 212 self.print_processor('Name', 'Termination Status', 'Yield Pending', 'Address')213 203 curr = root 214 204 … … 217 207 should_stop = processor['_X12do_terminateVb_1'] 218 208 stop_count = processor['_X10terminatedS9semaphore_1']['_X5counti_1'] 219 status_str = 'Running' if not should_stop else 'Last Thread' if stop_count >= 0 else 'Terminating' 220 status = '{}({},{})'.format(status_str, should_stop, stop_count) 209 if not should_stop: 210 status = 'Active' if active else 'Idle' 211 else: 212 status_str = 'Last Thread' if stop_count >= 0 else 'Terminating' 213 status = '{}({},{})'.format(status_str, should_stop, stop_count) 221 214 222 215 self.print_processor(processor['_X4namePKc_1'].string(), … … 229 222 break 230 223 231 print() 232 224 #entry point from gdb 233 225 def invoke(self, arg, from_tty): 234 """235 Iterate through a circular linked list of tasks and print out all236 info about each processor in that cluster237 @arg: str238 @from_tty: bool239 """240 226 if not is_cforall(): 241 227 return 242 228 229 cluster = lookup_cluster(arg if arg else None) 230 231 if not cluster: 232 print("No Cluster matching arguments found") 233 return 234 243 235 cfa_t = get_cfa_types() 244 245 argv = parse(arg) 246 if len(argv) > 1: 247 print_usage(self.usage_msg) 248 return 249 250 cluster = lookup_cluster(argv[0] if len(argv) > 0 else None) 251 252 if cluster == 0x0 or cluster == None: 253 print("No Cluster matching arguments found") 254 return 255 256 print('Cluster {}({})'.format(cluster['_X4namePKc_1'].string(), cluster.cast(cfa_t.cluster_ptr))) 236 print('Cluster: "{}"({})'.format(cluster['_X4namePKc_1'].string(), cluster.cast(cfa_t.cluster_ptr))) 257 237 258 238 active_root = cluster.cast(cfa_t.cluster_ptr) \ … … 266 246 .cast(cfa_t.processor_ptr) 267 247 268 print("Active Processors") 269 self.iterate_procs(active_root) 270 271 print("\nIdle Processors") 272 self.iterate_procs(idle_root) 248 if idle_root != 0x0 or active_root != 0x0: 249 self.print_processor('Name', 'Status', 'Pending Yield', 'Address') 250 self.iterate_procs(active_root, True) 251 self.iterate_procs(idle_root, False) 252 else: 253 print("No processors on cluster") 254 255 print() 273 256 274 257 ############ 275 258 class Threads(gdb.Command): 259 def __init__(self): 260 # The first parameter of the line below is the name of the command. You 261 # can call it 'uc++ task' 262 super(Threads, self).__init__('info cfathreads', gdb.COMMAND_USER) 263 264 def print_usage(self): 265 print_usage(""" 266 cfathread : print userCluster tasks, application tasks only 267 cfathread all : print all clusters, all tasks 268 cfathread <clusterName> : print cluster tasks, application tasks only 269 """) 270 271 def invoke(self, arg, from_tty): 272 """ 273 @arg: str 274 @from_tty: bool 275 """ 276 if not is_cforall(): 277 return 278 279 argv = parse(arg) 280 print(argv) 281 if len(argv) == 0: 282 cluster = lookup_cluster() 283 if not cluster: 284 print("Could not find Main Cluster") 285 return 286 287 # only tasks and main 288 self.print_threads_by_cluster(cluster, False) 289 290 elif len(argv) == 1: 291 if argv[0] == 'help': 292 self.print_usage() 293 # print tasks 294 elif argv[0] == 'all': 295 self.print_all_threads() # all tasks, all clusters 296 else: 297 """ 298 Print out all the tasks available in the specified cluster 299 @cluster_name: str 300 """ 301 print("cfathread by name") 302 cluster = lookup_cluster(argv[0]) 303 if not cluster: 304 return 305 306 # all tasks, specified cluster 307 self.print_threads_by_cluster(cluster, True) 308 309 elif len(argv) == 2: 310 # push task 311 self.pushtask_by_id(argv[0], argv[1]) # by id, specified cluster 312 else: 313 print('Invalid arguments') 314 self.print_usage() 315 316 ############ 317 class Thread(gdb.Command): 276 318 def __init__(self): 277 319 # The first parameter of the line below is the name of the command. You
Note: See TracChangeset
for help on using the changeset viewer.