symtab.hh revision 1158
12SN/A/* 21762SN/A * Copyright (c) 2002-2004 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 292665Ssaidi@eecs.umich.edu#ifndef __SYMTAB_HH__ 302SN/A#define __SYMTAB_HH__ 312SN/A 322SN/A#include <map> 332SN/A#include "targetarch/isa_traits.hh" // for Addr 342SN/A 351984SN/Aclass SymbolTable 36857SN/A{ 375952Ssaidi@eecs.umich.edu private: 381984SN/A typedef std::map<Addr, std::string> ATable; 396214Snate@binkert.org typedef std::map<std::string, Addr> STable; 4010905Sandreas.sandberg@arm.com 412SN/A ATable addrTable; 422SN/A STable symbolTable; 432SN/A 441912SN/A public: 452130SN/A SymbolTable() {} 46857SN/A SymbolTable(const std::string &file) { load(file); } 472SN/A ~SymbolTable() {} 481912SN/A 492SN/A bool insert(Addr address, std::string symbol); 502SN/A bool load(const std::string &file); 512SN/A 521912SN/A /// Find the nearest symbol equal to or less than the supplied 531912SN/A /// address (e.g., the label for the enclosing function). 541912SN/A /// @param address The address to look up. 551912SN/A /// @param symbol Return reference for symbol string. 561912SN/A /// @param sym_address Return reference for symbol address. 571912SN/A /// @param next_sym_address Address of following symbol (for 581912SN/A /// determining valid range of symbol). 591912SN/A /// @retval True if a symbol was found. 601912SN/A bool findNearestSymbol(Addr address, std::string &symbol, 611912SN/A Addr &sym_address, Addr &next_sym_address) const; 621912SN/A 631912SN/A /// Overload for findNearestSymbol() for callers who don't care 641912SN/A /// about next_sym_address. 651912SN/A bool findNearestSymbol(Addr address, std::string &symbol, 662SN/A Addr &sym_address) const 672SN/A { 682SN/A Addr dummy; 692SN/A return findNearestSymbol(address, symbol, sym_address, dummy); 702SN/A } 711984SN/A 722SN/A 732SN/A bool findSymbol(Addr address, std::string &symbol) const; 742SN/A bool findAddress(const std::string &symbol, Addr &address) const; 751912SN/A 761912SN/A std::string find(Addr addr) const; 771912SN/A Addr find(const std::string &symbol) const; 781912SN/A}; 7910905Sandreas.sandberg@arm.com 8010905Sandreas.sandberg@arm.com/// Global unified debugging symbol table (for target). Conceptually 811984SN/A/// there should be one of these per System object for full system, 821984SN/A/// and per Process object for non-full-system, but so far one big 831912SN/A/// global one has worked well enough. 841912SN/Aextern SymbolTable *debugSymbolTable; 851912SN/A 861912SN/A#endif // __SYMTAB_HH__ 871912SN/A