stacktrace.cc revision 13888
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 4713888Sgabeblack@google.comstatic int32_t 4813888Sgabeblack@google.comreadSymbol(ThreadContext *tc, const std::string name) 4913887Sgabeblack@google.com{ 5013888Sgabeblack@google.com FSTranslatingPortProxy &vp = tc->getVirtProxy(); 5113888Sgabeblack@google.com SymbolTable *symtab = tc->getSystemPtr()->kernelSymtab; 523558SN/A 5313888Sgabeblack@google.com Addr addr; 5413888Sgabeblack@google.com if (!symtab->findAddress(name, addr)) 5513888Sgabeblack@google.com panic("thread info not compiled into kernel\n"); 563558SN/A 5713888Sgabeblack@google.com return vp.readGtoH<int32_t>(addr); 5813888Sgabeblack@google.com} 593558SN/A 6013888Sgabeblack@google.comProcessInfo::ProcessInfo(ThreadContext *_tc) : tc(_tc) 6113888Sgabeblack@google.com{ 6213888Sgabeblack@google.com thread_info_size = readSymbol(tc, "thread_info_size"); 6313888Sgabeblack@google.com task_struct_size = readSymbol(tc, "task_struct_size"); 6413888Sgabeblack@google.com task_off = readSymbol(tc, "thread_info_task"); 6513888Sgabeblack@google.com pid_off = readSymbol(tc, "task_struct_pid"); 6613888Sgabeblack@google.com name_off = readSymbol(tc, "task_struct_comm"); 6713887Sgabeblack@google.com} 689069Satgutier@umich.edu 6913887Sgabeblack@google.comAddr 7013887Sgabeblack@google.comProcessInfo::task(Addr ksp) const 7113887Sgabeblack@google.com{ 7213887Sgabeblack@google.com Addr base = ksp & ~0x1fff; 7313887Sgabeblack@google.com if (base == ULL(0xffffffffc0000000)) 7413887Sgabeblack@google.com return 0; 759069Satgutier@umich.edu 7613887Sgabeblack@google.com Addr tsk; 779069Satgutier@umich.edu 7813887Sgabeblack@google.com FSTranslatingPortProxy &vp = tc->getVirtProxy(); 7913887Sgabeblack@google.com tsk = vp.readGtoH<Addr>(base + task_off); 803558SN/A 8113887Sgabeblack@google.com return tsk; 8213887Sgabeblack@google.com} 839069Satgutier@umich.edu 8413887Sgabeblack@google.comint 8513887Sgabeblack@google.comProcessInfo::pid(Addr ksp) const 8613887Sgabeblack@google.com{ 8713887Sgabeblack@google.com Addr task = this->task(ksp); 8813887Sgabeblack@google.com if (!task) 8913887Sgabeblack@google.com return -1; 909069Satgutier@umich.edu 9113887Sgabeblack@google.com uint16_t pd; 929069Satgutier@umich.edu 9313887Sgabeblack@google.com FSTranslatingPortProxy &vp = tc->getVirtProxy(); 9413887Sgabeblack@google.com pd = vp.readGtoH<uint16_t>(task + pid_off); 953558SN/A 9613887Sgabeblack@google.com return pd; 9713887Sgabeblack@google.com} 989069Satgutier@umich.edu 9913887Sgabeblack@google.comstd::string 10013887Sgabeblack@google.comProcessInfo::name(Addr ksp) const 10113887Sgabeblack@google.com{ 10213887Sgabeblack@google.com Addr task = this->task(ksp); 10313887Sgabeblack@google.com if (!task) 10413887Sgabeblack@google.com return "unknown"; 1059069Satgutier@umich.edu 10613887Sgabeblack@google.com char comm[256]; 10713887Sgabeblack@google.com CopyStringOut(tc, comm, task + name_off, sizeof(comm)); 10813887Sgabeblack@google.com if (!comm[0]) 10913887Sgabeblack@google.com return "startup"; 1103558SN/A 11113887Sgabeblack@google.com return comm; 11213887Sgabeblack@google.com} 1133570SN/A 11413887Sgabeblack@google.comStackTrace::StackTrace() 11513887Sgabeblack@google.com : tc(0), stack(64) 11613887Sgabeblack@google.com{ 11713887Sgabeblack@google.com} 1183570SN/A 11913887Sgabeblack@google.comStackTrace::StackTrace(ThreadContext *_tc, const StaticInstPtr &inst) 12013887Sgabeblack@google.com : tc(0), stack(64) 12113887Sgabeblack@google.com{ 12213887Sgabeblack@google.com trace(_tc, inst); 12313887Sgabeblack@google.com} 1243570SN/A 12513887Sgabeblack@google.comStackTrace::~StackTrace() 12613887Sgabeblack@google.com{ 12713887Sgabeblack@google.com} 1283558SN/A 12913887Sgabeblack@google.comvoid 13013887Sgabeblack@google.comStackTrace::trace(ThreadContext *_tc, bool is_call) 13113887Sgabeblack@google.com{ 13213887Sgabeblack@google.com} 1333558SN/A 13413887Sgabeblack@google.combool 13513887Sgabeblack@google.comStackTrace::isEntry(Addr addr) 13613887Sgabeblack@google.com{ 13713887Sgabeblack@google.com return false; 13813887Sgabeblack@google.com} 1393570SN/A 14013887Sgabeblack@google.combool 14113887Sgabeblack@google.comStackTrace::decodeStack(MachInst inst, int &disp) 14213887Sgabeblack@google.com{ 14313887Sgabeblack@google.com return false; 14413887Sgabeblack@google.com} 1453570SN/A 14613887Sgabeblack@google.combool 14713887Sgabeblack@google.comStackTrace::decodeSave(MachInst inst, int ®, int &disp) 14813887Sgabeblack@google.com{ 14913887Sgabeblack@google.com return false; 15013887Sgabeblack@google.com} 15113887Sgabeblack@google.com 15213887Sgabeblack@google.com/* 15313887Sgabeblack@google.com * Decode the function prologue for the function we're in, and note 15413887Sgabeblack@google.com * which registers are stored where, and how large the stack frame is. 15513887Sgabeblack@google.com */ 15613887Sgabeblack@google.combool 15713887Sgabeblack@google.comStackTrace::decodePrologue(Addr sp, Addr callpc, Addr func, 15813887Sgabeblack@google.com int &size, Addr &ra) 15913887Sgabeblack@google.com{ 16013887Sgabeblack@google.com return false; 16113887Sgabeblack@google.com} 1623558SN/A 1633570SN/A#if TRACING_ON 16413887Sgabeblack@google.comvoid 16513887Sgabeblack@google.comStackTrace::dump() 16613887Sgabeblack@google.com{ 16713887Sgabeblack@google.com DPRINTFN("------ Stack ------\n"); 16811320Ssteve.reinhardt@amd.com 16913887Sgabeblack@google.com DPRINTFN(" Not implemented\n"); 17013887Sgabeblack@google.com} 1713570SN/A#endif 1723558SN/A} 173