stacktrace.cc revision 13887
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 3111793Sbrandon.potter@amd.com#include "arch/arm/stacktrace.hh" 3211793Sbrandon.potter@amd.com 333558SN/A#include <string> 343558SN/A 356757SAli.Saidi@ARM.com#include "arch/arm/isa_traits.hh" 366757SAli.Saidi@ARM.com#include "arch/arm/vtophys.hh" 373558SN/A#include "base/bitfield.hh" 383558SN/A#include "base/trace.hh" 393558SN/A#include "cpu/base.hh" 403558SN/A#include "cpu/thread_context.hh" 418706Sandreas.hansson@arm.com#include "mem/fs_translating_port_proxy.hh" 423558SN/A#include "sim/system.hh" 433558SN/A 446757SAli.Saidi@ARM.comnamespace ArmISA 453570SN/A{ 463558SN/A 4713887Sgabeblack@google.comProcessInfo::ProcessInfo(ThreadContext *_tc) 4813887Sgabeblack@google.com : tc(_tc) 4913887Sgabeblack@google.com{ 5013887Sgabeblack@google.com Addr addr = 0; 513558SN/A 5213887Sgabeblack@google.com FSTranslatingPortProxy &vp = tc->getVirtProxy(); 533558SN/A 5413887Sgabeblack@google.com if (!tc->getSystemPtr()->kernelSymtab->findAddress( 5513887Sgabeblack@google.com "thread_info_size", addr)) { 5613887Sgabeblack@google.com panic("thread info not compiled into kernel\n"); 5713887Sgabeblack@google.com } 5813887Sgabeblack@google.com thread_info_size = vp.readGtoH<int32_t>(addr); 593558SN/A 6013887Sgabeblack@google.com if (!tc->getSystemPtr()->kernelSymtab->findAddress( 6113887Sgabeblack@google.com "task_struct_size", addr)) { 6213887Sgabeblack@google.com panic("thread info not compiled into kernel\n"); 6313887Sgabeblack@google.com } 6413887Sgabeblack@google.com task_struct_size = vp.readGtoH<int32_t>(addr); 653558SN/A 6613887Sgabeblack@google.com if (!tc->getSystemPtr()->kernelSymtab->findAddress( 6713887Sgabeblack@google.com "thread_info_task", addr)) { 6813887Sgabeblack@google.com panic("thread info not compiled into kernel\n"); 6913887Sgabeblack@google.com } 7013887Sgabeblack@google.com task_off = vp.readGtoH<int32_t>(addr); 713558SN/A 7213887Sgabeblack@google.com if (!tc->getSystemPtr()->kernelSymtab->findAddress( 7313887Sgabeblack@google.com "task_struct_pid", addr)) { 7413887Sgabeblack@google.com panic("thread info not compiled into kernel\n"); 753558SN/A } 7613887Sgabeblack@google.com pid_off = vp.readGtoH<int32_t>(addr); 773558SN/A 7813887Sgabeblack@google.com if (!tc->getSystemPtr()->kernelSymtab->findAddress( 7913887Sgabeblack@google.com "task_struct_comm", addr)) { 8013887Sgabeblack@google.com panic("thread info not compiled into kernel\n"); 8113887Sgabeblack@google.com } 8213887Sgabeblack@google.com name_off = vp.readGtoH<int32_t>(addr); 8313887Sgabeblack@google.com} 849069Satgutier@umich.edu 8513887Sgabeblack@google.comAddr 8613887Sgabeblack@google.comProcessInfo::task(Addr ksp) const 8713887Sgabeblack@google.com{ 8813887Sgabeblack@google.com Addr base = ksp & ~0x1fff; 8913887Sgabeblack@google.com if (base == ULL(0xffffffffc0000000)) 9013887Sgabeblack@google.com return 0; 919069Satgutier@umich.edu 9213887Sgabeblack@google.com Addr tsk; 939069Satgutier@umich.edu 9413887Sgabeblack@google.com FSTranslatingPortProxy &vp = tc->getVirtProxy(); 9513887Sgabeblack@google.com tsk = vp.readGtoH<Addr>(base + task_off); 963558SN/A 9713887Sgabeblack@google.com return tsk; 9813887Sgabeblack@google.com} 999069Satgutier@umich.edu 10013887Sgabeblack@google.comint 10113887Sgabeblack@google.comProcessInfo::pid(Addr ksp) const 10213887Sgabeblack@google.com{ 10313887Sgabeblack@google.com Addr task = this->task(ksp); 10413887Sgabeblack@google.com if (!task) 10513887Sgabeblack@google.com return -1; 1069069Satgutier@umich.edu 10713887Sgabeblack@google.com uint16_t pd; 1089069Satgutier@umich.edu 10913887Sgabeblack@google.com FSTranslatingPortProxy &vp = tc->getVirtProxy(); 11013887Sgabeblack@google.com pd = vp.readGtoH<uint16_t>(task + pid_off); 1113558SN/A 11213887Sgabeblack@google.com return pd; 11313887Sgabeblack@google.com} 1149069Satgutier@umich.edu 11513887Sgabeblack@google.comstd::string 11613887Sgabeblack@google.comProcessInfo::name(Addr ksp) const 11713887Sgabeblack@google.com{ 11813887Sgabeblack@google.com Addr task = this->task(ksp); 11913887Sgabeblack@google.com if (!task) 12013887Sgabeblack@google.com return "unknown"; 1219069Satgutier@umich.edu 12213887Sgabeblack@google.com char comm[256]; 12313887Sgabeblack@google.com CopyStringOut(tc, comm, task + name_off, sizeof(comm)); 12413887Sgabeblack@google.com if (!comm[0]) 12513887Sgabeblack@google.com return "startup"; 1263558SN/A 12713887Sgabeblack@google.com return comm; 12813887Sgabeblack@google.com} 1293570SN/A 13013887Sgabeblack@google.comStackTrace::StackTrace() 13113887Sgabeblack@google.com : tc(0), stack(64) 13213887Sgabeblack@google.com{ 13313887Sgabeblack@google.com} 1343570SN/A 13513887Sgabeblack@google.comStackTrace::StackTrace(ThreadContext *_tc, const StaticInstPtr &inst) 13613887Sgabeblack@google.com : tc(0), stack(64) 13713887Sgabeblack@google.com{ 13813887Sgabeblack@google.com trace(_tc, inst); 13913887Sgabeblack@google.com} 1403570SN/A 14113887Sgabeblack@google.comStackTrace::~StackTrace() 14213887Sgabeblack@google.com{ 14313887Sgabeblack@google.com} 1443558SN/A 14513887Sgabeblack@google.comvoid 14613887Sgabeblack@google.comStackTrace::trace(ThreadContext *_tc, bool is_call) 14713887Sgabeblack@google.com{ 14813887Sgabeblack@google.com} 1493558SN/A 15013887Sgabeblack@google.combool 15113887Sgabeblack@google.comStackTrace::isEntry(Addr addr) 15213887Sgabeblack@google.com{ 15313887Sgabeblack@google.com return false; 15413887Sgabeblack@google.com} 1553570SN/A 15613887Sgabeblack@google.combool 15713887Sgabeblack@google.comStackTrace::decodeStack(MachInst inst, int &disp) 15813887Sgabeblack@google.com{ 15913887Sgabeblack@google.com return false; 16013887Sgabeblack@google.com} 1613570SN/A 16213887Sgabeblack@google.combool 16313887Sgabeblack@google.comStackTrace::decodeSave(MachInst inst, int ®, int &disp) 16413887Sgabeblack@google.com{ 16513887Sgabeblack@google.com return false; 16613887Sgabeblack@google.com} 16713887Sgabeblack@google.com 16813887Sgabeblack@google.com/* 16913887Sgabeblack@google.com * Decode the function prologue for the function we're in, and note 17013887Sgabeblack@google.com * which registers are stored where, and how large the stack frame is. 17113887Sgabeblack@google.com */ 17213887Sgabeblack@google.combool 17313887Sgabeblack@google.comStackTrace::decodePrologue(Addr sp, Addr callpc, Addr func, 17413887Sgabeblack@google.com int &size, Addr &ra) 17513887Sgabeblack@google.com{ 17613887Sgabeblack@google.com return false; 17713887Sgabeblack@google.com} 1783558SN/A 1793570SN/A#if TRACING_ON 18013887Sgabeblack@google.comvoid 18113887Sgabeblack@google.comStackTrace::dump() 18213887Sgabeblack@google.com{ 18313887Sgabeblack@google.com DPRINTFN("------ Stack ------\n"); 18411320Ssteve.reinhardt@amd.com 18513887Sgabeblack@google.com DPRINTFN(" Not implemented\n"); 18613887Sgabeblack@google.com} 1873570SN/A#endif 1883558SN/A} 189