1/* 2 * Copyright (c) 2010-2013, 2016 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 222 unchanged lines hidden (view full) --- 231{ 232 return new LinuxArmSystem(this); 233} 234 235void 236LinuxArmSystem::startup() 237{ 238 if (enableContextSwitchStatsDump) { |
239 if (!highestELIs64()) { 240 dumpStatsPCEvent = 241 addKernelFuncEvent<DumpStatsPCEvent>("__switch_to"); 242 } else { 243 dumpStatsPCEvent = 244 addKernelFuncEvent<DumpStatsPCEvent64>("__switch_to"); 245 } 246 |
247 if (!dumpStatsPCEvent) 248 panic("dumpStatsPCEvent not created!"); 249 250 std::string task_filename = "tasks.txt"; 251 taskFile = simout.create(name() + "." + task_filename); 252 253 for (int i = 0; i < _numContexts; i++) { 254 ThreadContext *tc = threadContexts[i]; --- 23 unchanged lines hidden (view full) --- 278} 279 280void 281LinuxArmSystem::dumpDmesg() 282{ 283 Linux::dumpDmesg(getThreadContext(0), std::cout); 284} 285 |
286/** 287 * Extracts the information used by the DumpStatsPCEvent by reading the 288 * thread_info pointer passed to __switch_to() in 32 bit ARM Linux |
289 * 290 * r0 = task_struct of the previously running process |
291 * r1 = thread_info of the previously running process 292 * r2 = thread_info of the next process to run |
293 */ 294void |
295DumpStatsPCEvent::getTaskDetails(ThreadContext *tc, uint32_t &pid, 296 uint32_t &tgid, std::string &next_task_str, int32_t &mm) { 297 |
298 Linux::ThreadInfo ti(tc); 299 Addr task_descriptor = tc->readIntReg(2); |
300 pid = ti.curTaskPID(task_descriptor); 301 tgid = ti.curTaskTGID(task_descriptor); 302 next_task_str = ti.curTaskName(task_descriptor); |
303 304 // Streamline treats pid == -1 as the kernel process. 305 // Also pid == 0 implies idle process (except during Linux boot) |
306 mm = ti.curTaskMm(task_descriptor); 307} 308 309/** 310 * Extracts the information used by the DumpStatsPCEvent64 by reading the 311 * task_struct pointer passed to __switch_to() in 64 bit ARM Linux 312 * 313 * r0 = task_struct of the previously running process 314 * r1 = task_struct of next process to run 315 */ 316void 317DumpStatsPCEvent64::getTaskDetails(ThreadContext *tc, uint32_t &pid, 318 uint32_t &tgid, std::string &next_task_str, int32_t &mm) { 319 320 Linux::ThreadInfo ti(tc); 321 Addr task_struct = tc->readIntReg(1); 322 pid = ti.curTaskPIDFromTaskStruct(task_struct); 323 tgid = ti.curTaskTGIDFromTaskStruct(task_struct); 324 next_task_str = ti.curTaskNameFromTaskStruct(task_struct); 325 326 // Streamline treats pid == -1 as the kernel process. 327 // Also pid == 0 implies idle process (except during Linux boot) 328 mm = ti.curTaskMmFromTaskStruct(task_struct); 329} 330 331/** This function is called whenever the the kernel function 332 * "__switch_to" is called to change running tasks. 333 */ 334void 335DumpStatsPCEvent::process(ThreadContext *tc) 336{ 337 uint32_t pid = 0; 338 uint32_t tgid = 0; 339 std::string next_task_str; 340 int32_t mm = 0; 341 342 getTaskDetails(tc, pid, tgid, next_task_str, mm); 343 |
344 bool is_kernel = (mm == 0); 345 if (is_kernel && (pid != 0)) { 346 pid = -1; 347 tgid = -1; 348 next_task_str = "kernel"; 349 } 350 351 LinuxArmSystem* sys = dynamic_cast<LinuxArmSystem *>(tc->getSystemPtr()); --- 26 unchanged lines hidden --- |