stacktrace.cc revision 14020:c9bf7a011602
12SN/A/* 21762SN/A * Copyright (c) 2005 The Regents of The University of Michigan 32SN/A * All rights reserved. 42SN/A * 52SN/A * Redistribution and use in source and binary forms, with or without 62SN/A * modification, are permitted provided that the following conditions are 72SN/A * met: redistributions of source code must retain the above copyright 82SN/A * notice, this list of conditions and the following disclaimer; 92SN/A * redistributions in binary form must reproduce the above copyright 102SN/A * notice, this list of conditions and the following disclaimer in the 112SN/A * documentation and/or other materials provided with the distribution; 122SN/A * neither the name of the copyright holders nor the names of its 132SN/A * contributors may be used to endorse or promote products derived from 142SN/A * this software without specific prior written permission. 152SN/A * 162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Nathan Binkert 292665Ssaidi@eecs.umich.edu */ 302SN/A 312SN/A#include "arch/arm/stacktrace.hh" 322SN/A 332SN/A#include <string> 342SN/A 352520SN/A#include "arch/arm/isa_traits.hh" 362207SN/A#include "arch/arm/vtophys.hh" 372207SN/A#include "base/bitfield.hh" 3811389Sbrandon.potter@amd.com#include "base/trace.hh" 396214Snate@binkert.org#include "cpu/base.hh" 402SN/A#include "cpu/thread_context.hh" 418706Sandreas.hansson@arm.com#include "mem/fs_translating_port_proxy.hh" 422SN/A#include "sim/system.hh" 432SN/A 442SN/Anamespace ArmISA 452SN/A{ 46360SN/A 47360SN/Astatic int32_t 48360SN/AreadSymbol(ThreadContext *tc, const std::string name) 49360SN/A{ 502207SN/A PortProxy &vp = tc->getVirtProxy(); 514111Sgblack@eecs.umich.edu SymbolTable *symtab = tc->getSystemPtr()->kernelSymtab; 524111Sgblack@eecs.umich.edu 534155Sgblack@eecs.umich.edu Addr addr; 545874Sgblack@eecs.umich.edu if (!symtab->findAddress(name, addr)) 555874Sgblack@eecs.umich.edu panic("thread info not compiled into kernel\n"); 5610037SARM gem5 Developers 576691Stjones1@inf.ed.ac.uk return vp.read<int32_t>(addr, GuestByteOrder); 587095Sgblack@eecs.umich.edu} 596691Stjones1@inf.ed.ac.uk 60360SN/AProcessInfo::ProcessInfo(ThreadContext *_tc) : tc(_tc) 61360SN/A{ 62360SN/A thread_info_size = readSymbol(tc, "thread_info_size"); 63360SN/A task_struct_size = readSymbol(tc, "task_struct_size"); 64360SN/A task_off = readSymbol(tc, "thread_info_task"); 652207SN/A pid_off = readSymbol(tc, "task_struct_pid"); 666392Ssaidi@eecs.umich.edu name_off = readSymbol(tc, "task_struct_comm"); 6710810Sbr@bsdpad.com} 6810810Sbr@bsdpad.com 69360SN/AAddr 70360SN/AProcessInfo::task(Addr ksp) const 712SN/A{ 7212SN/A Addr base = ksp & ~0x1fff; 7312SN/A if (base == ULL(0xffffffffc0000000)) 742SN/A return 0; 752SN/A 76360SN/A Addr tsk; 77360SN/A 78360SN/A PortProxy &vp = tc->getVirtProxy(); 7910880SCurtis.Dunham@arm.com tsk = vp.read<Addr>(base + task_off, GuestByteOrder); 80360SN/A 8112SN/A return tsk; 822SN/A} 832SN/A 842SN/Aint 852SN/AProcessInfo::pid(Addr ksp) const 862SN/A{ 878852Sandreas.hansson@arm.com Addr task = this->task(ksp); 8810037SARM gem5 Developers if (!task) 8910037SARM gem5 Developers return -1; 903812Ssaidi@eecs.umich.edu 913812Ssaidi@eecs.umich.edu uint16_t pd; 923812Ssaidi@eecs.umich.edu 933812Ssaidi@eecs.umich.edu PortProxy &vp = tc->getVirtProxy(); 949641Sguodeyuan@tsinghua.org.cn pd = vp.read<uint16_t>(task + pid_off, GuestByteOrder); 959641Sguodeyuan@tsinghua.org.cn 969641Sguodeyuan@tsinghua.org.cn return pd; 972SN/A} 9811389Sbrandon.potter@amd.com 9911389Sbrandon.potter@amd.comstd::string 10011389Sbrandon.potter@amd.comProcessInfo::name(Addr ksp) const 10111389Sbrandon.potter@amd.com{ 10211389Sbrandon.potter@amd.com Addr task = this->task(ksp); 10311389Sbrandon.potter@amd.com if (!task) 10411389Sbrandon.potter@amd.com return "unknown"; 10511389Sbrandon.potter@amd.com 1065070Ssaidi@eecs.umich.edu char comm[256]; 1073917Ssaidi@eecs.umich.edu tc->getVirtProxy().readString(comm, task + name_off, sizeof(comm)); 108360SN/A if (!comm[0]) 109360SN/A return "startup"; 110360SN/A 1112SN/A return comm; 1122SN/A} 11312SN/A 1142420SN/AStackTrace::StackTrace() 1152420SN/A : tc(0), stack(64) 1162420SN/A{ 11712SN/A} 11812SN/A 11912SN/AStackTrace::StackTrace(ThreadContext *_tc, const StaticInstPtr &inst) 12012SN/A : tc(0), stack(64) 12112SN/A{ 12212SN/A trace(_tc, inst); 12312SN/A} 12412SN/A 1252SN/AStackTrace::~StackTrace() 12610037SARM gem5 Developers{ 12710037SARM gem5 Developers} 1282472SN/A 1292420SN/Avoid 1302SN/AStackTrace::trace(ThreadContext *_tc, bool is_call) 13112SN/A{ 1322472SN/A} 13312SN/A 1342SN/Abool 13512SN/AStackTrace::isEntry(Addr addr) 13612SN/A{ 13712SN/A return false; 13812SN/A} 13912SN/A 14012SN/Abool 14112SN/AStackTrace::decodeStack(MachInst inst, int &disp) 1423584Ssaidi@eecs.umich.edu{ 1439261Sdam.sunwoo@arm.com return false; 1449261Sdam.sunwoo@arm.com} 1459261Sdam.sunwoo@arm.com 1469261Sdam.sunwoo@arm.combool 1479261Sdam.sunwoo@arm.comStackTrace::decodeSave(MachInst inst, int ®, int &disp) 1483584Ssaidi@eecs.umich.edu{ 1492SN/A return false; 1502SN/A} 1513584Ssaidi@eecs.umich.edu 1522SN/A/* 1532SN/A * Decode the function prologue for the function we're in, and note 1542SN/A * which registers are stored where, and how large the stack frame is. 155 */ 156bool 157StackTrace::decodePrologue(Addr sp, Addr callpc, Addr func, 158 int &size, Addr &ra) 159{ 160 return false; 161} 162 163#if TRACING_ON 164void 165StackTrace::dump() 166{ 167 DPRINTFN("------ Stack ------\n"); 168 169 DPRINTFN(" Not implemented\n"); 170} 171#endif 172} 173