stacktrace.cc revision 8852
13558SN/A/* 23558SN/A * Copyright (c) 2005 The Regents of The University of Michigan 33558SN/A * All rights reserved. 43558SN/A * 53558SN/A * Redistribution and use in source and binary forms, with or without 63558SN/A * modification, are permitted provided that the following conditions are 73558SN/A * met: redistributions of source code must retain the above copyright 83558SN/A * notice, this list of conditions and the following disclaimer; 93558SN/A * redistributions in binary form must reproduce the above copyright 103558SN/A * notice, this list of conditions and the following disclaimer in the 113558SN/A * documentation and/or other materials provided with the distribution; 123558SN/A * neither the name of the copyright holders nor the names of its 133558SN/A * contributors may be used to endorse or promote products derived from 143558SN/A * this software without specific prior written permission. 153558SN/A * 163558SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 173558SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 183558SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 193558SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 203558SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 213558SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 223558SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 233558SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 243558SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 253558SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 263558SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 273558SN/A * 283558SN/A * Authors: Nathan Binkert 293558SN/A */ 303558SN/A 313558SN/A#include <string> 323558SN/A 336757SAli.Saidi@ARM.com#include "arch/arm/isa_traits.hh" 346757SAli.Saidi@ARM.com#include "arch/arm/stacktrace.hh" 356757SAli.Saidi@ARM.com#include "arch/arm/vtophys.hh" 363558SN/A#include "base/bitfield.hh" 373558SN/A#include "base/trace.hh" 383558SN/A#include "cpu/base.hh" 393558SN/A#include "cpu/thread_context.hh" 408706Sandreas.hansson@arm.com#include "mem/fs_translating_port_proxy.hh" 413558SN/A#include "sim/system.hh" 423558SN/A 433558SN/Ausing namespace std; 446757SAli.Saidi@ARM.comnamespace ArmISA 453570SN/A{ 463570SN/A ProcessInfo::ProcessInfo(ThreadContext *_tc) 473570SN/A : tc(_tc) 483570SN/A { 493570SN/A Addr addr = 0; 503558SN/A 518852Sandreas.hansson@arm.com FSTranslatingPortProxy &vp = tc->getVirtProxy(); 523558SN/A 533570SN/A if (!tc->getSystemPtr()->kernelSymtab->findAddress("thread_info_size", addr)) 543570SN/A panic("thread info not compiled into kernel\n"); 558852Sandreas.hansson@arm.com thread_info_size = vp.readGtoH<int32_t>(addr); 563558SN/A 573570SN/A if (!tc->getSystemPtr()->kernelSymtab->findAddress("task_struct_size", addr)) 583570SN/A panic("thread info not compiled into kernel\n"); 598852Sandreas.hansson@arm.com task_struct_size = vp.readGtoH<int32_t>(addr); 603558SN/A 613570SN/A if (!tc->getSystemPtr()->kernelSymtab->findAddress("thread_info_task", addr)) 623570SN/A panic("thread info not compiled into kernel\n"); 638852Sandreas.hansson@arm.com task_off = vp.readGtoH<int32_t>(addr); 643558SN/A 653570SN/A if (!tc->getSystemPtr()->kernelSymtab->findAddress("task_struct_pid", addr)) 663570SN/A panic("thread info not compiled into kernel\n"); 678852Sandreas.hansson@arm.com pid_off = vp.readGtoH<int32_t>(addr); 683558SN/A 693570SN/A if (!tc->getSystemPtr()->kernelSymtab->findAddress("task_struct_comm", addr)) 703570SN/A panic("thread info not compiled into kernel\n"); 718852Sandreas.hansson@arm.com name_off = vp.readGtoH<int32_t>(addr); 723558SN/A } 733558SN/A 743570SN/A Addr 753570SN/A ProcessInfo::task(Addr ksp) const 763570SN/A { 776757SAli.Saidi@ARM.com return 0; 783558SN/A } 793558SN/A 803570SN/A int 813570SN/A ProcessInfo::pid(Addr ksp) const 823570SN/A { 836757SAli.Saidi@ARM.com return -1; 843558SN/A } 853558SN/A 863570SN/A string 873570SN/A ProcessInfo::name(Addr ksp) const 883570SN/A { 896757SAli.Saidi@ARM.com return "Implement me"; 903570SN/A } 913558SN/A 923570SN/A StackTrace::StackTrace() 933570SN/A : tc(0), stack(64) 943570SN/A { 953570SN/A } 963570SN/A 973570SN/A StackTrace::StackTrace(ThreadContext *_tc, StaticInstPtr inst) 983570SN/A : tc(0), stack(64) 993570SN/A { 1003570SN/A trace(_tc, inst); 1013570SN/A } 1023570SN/A 1033570SN/A StackTrace::~StackTrace() 1043570SN/A { 1053570SN/A } 1063570SN/A 1073570SN/A void 1083570SN/A StackTrace::trace(ThreadContext *_tc, bool is_call) 1093570SN/A { 1103558SN/A } 1113558SN/A 1123570SN/A bool 1133570SN/A StackTrace::isEntry(Addr addr) 1143570SN/A { 1153558SN/A return false; 1163558SN/A } 1173558SN/A 1183570SN/A bool 1193570SN/A StackTrace::decodeStack(MachInst inst, int &disp) 1203570SN/A { 1216757SAli.Saidi@ARM.com return false; 1223570SN/A } 1233570SN/A 1243570SN/A bool 1253570SN/A StackTrace::decodeSave(MachInst inst, int ®, int &disp) 1263570SN/A { 1276757SAli.Saidi@ARM.com return false; 1283570SN/A } 1293570SN/A 1303570SN/A /* 1313570SN/A * Decode the function prologue for the function we're in, and note 1323570SN/A * which registers are stored where, and how large the stack frame is. 1333570SN/A */ 1343570SN/A bool 1353570SN/A StackTrace::decodePrologue(Addr sp, Addr callpc, Addr func, 1363570SN/A int &size, Addr &ra) 1373570SN/A { 1386757SAli.Saidi@ARM.com return false; 1393558SN/A } 1403558SN/A 1413570SN/A#if TRACING_ON 1423570SN/A void 1433570SN/A StackTrace::dump() 1443570SN/A { 1453570SN/A DPRINTFN("------ Stack ------\n"); 1466757SAli.Saidi@ARM.com 1476757SAli.Saidi@ARM.com DPRINTFN(" Not implemented\n"); 1483570SN/A } 1493570SN/A#endif 1503558SN/A} 151