stacktrace.cc revision 8706
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
518706Sandreas.hansson@arm.com        FSTranslatingPortProxy* vp;
523558SN/A
538706Sandreas.hansson@arm.com        vp = tc->getVirtProxy();
543558SN/A
553570SN/A        if (!tc->getSystemPtr()->kernelSymtab->findAddress("thread_info_size", addr))
563570SN/A            panic("thread info not compiled into kernel\n");
573570SN/A        thread_info_size = vp->readGtoH<int32_t>(addr);
583558SN/A
593570SN/A        if (!tc->getSystemPtr()->kernelSymtab->findAddress("task_struct_size", addr))
603570SN/A            panic("thread info not compiled into kernel\n");
613570SN/A        task_struct_size = vp->readGtoH<int32_t>(addr);
623558SN/A
633570SN/A        if (!tc->getSystemPtr()->kernelSymtab->findAddress("thread_info_task", addr))
643570SN/A            panic("thread info not compiled into kernel\n");
653570SN/A        task_off = vp->readGtoH<int32_t>(addr);
663558SN/A
673570SN/A        if (!tc->getSystemPtr()->kernelSymtab->findAddress("task_struct_pid", addr))
683570SN/A            panic("thread info not compiled into kernel\n");
693570SN/A        pid_off = vp->readGtoH<int32_t>(addr);
703558SN/A
713570SN/A        if (!tc->getSystemPtr()->kernelSymtab->findAddress("task_struct_comm", addr))
723570SN/A            panic("thread info not compiled into kernel\n");
733570SN/A        name_off = vp->readGtoH<int32_t>(addr);
743558SN/A    }
753558SN/A
763570SN/A    Addr
773570SN/A    ProcessInfo::task(Addr ksp) const
783570SN/A    {
796757SAli.Saidi@ARM.com        return 0;
803558SN/A    }
813558SN/A
823570SN/A    int
833570SN/A    ProcessInfo::pid(Addr ksp) const
843570SN/A    {
856757SAli.Saidi@ARM.com        return -1;
863558SN/A    }
873558SN/A
883570SN/A    string
893570SN/A    ProcessInfo::name(Addr ksp) const
903570SN/A    {
916757SAli.Saidi@ARM.com        return "Implement me";
923570SN/A    }
933558SN/A
943570SN/A    StackTrace::StackTrace()
953570SN/A        : tc(0), stack(64)
963570SN/A    {
973570SN/A    }
983570SN/A
993570SN/A    StackTrace::StackTrace(ThreadContext *_tc, StaticInstPtr inst)
1003570SN/A        : tc(0), stack(64)
1013570SN/A    {
1023570SN/A        trace(_tc, inst);
1033570SN/A    }
1043570SN/A
1053570SN/A    StackTrace::~StackTrace()
1063570SN/A    {
1073570SN/A    }
1083570SN/A
1093570SN/A    void
1103570SN/A    StackTrace::trace(ThreadContext *_tc, bool is_call)
1113570SN/A    {
1123558SN/A    }
1133558SN/A
1143570SN/A    bool
1153570SN/A    StackTrace::isEntry(Addr addr)
1163570SN/A    {
1173558SN/A        return false;
1183558SN/A    }
1193558SN/A
1203570SN/A    bool
1213570SN/A    StackTrace::decodeStack(MachInst inst, int &disp)
1223570SN/A    {
1236757SAli.Saidi@ARM.com        return false;
1243570SN/A    }
1253570SN/A
1263570SN/A    bool
1273570SN/A    StackTrace::decodeSave(MachInst inst, int &reg, int &disp)
1283570SN/A    {
1296757SAli.Saidi@ARM.com        return false;
1303570SN/A    }
1313570SN/A
1323570SN/A    /*
1333570SN/A     * Decode the function prologue for the function we're in, and note
1343570SN/A     * which registers are stored where, and how large the stack frame is.
1353570SN/A     */
1363570SN/A    bool
1373570SN/A    StackTrace::decodePrologue(Addr sp, Addr callpc, Addr func,
1383570SN/A                               int &size, Addr &ra)
1393570SN/A    {
1406757SAli.Saidi@ARM.com        return false;
1413558SN/A    }
1423558SN/A
1433570SN/A#if TRACING_ON
1443570SN/A    void
1453570SN/A    StackTrace::dump()
1463570SN/A    {
1473570SN/A        DPRINTFN("------ Stack ------\n");
1486757SAli.Saidi@ARM.com
1496757SAli.Saidi@ARM.com        DPRINTFN(" Not implemented\n");
1503570SN/A    }
1513570SN/A#endif
1523558SN/A}
153