symtab.hh revision 857
15124Sgblack@eecs.umich.edu/*
27087Snate@binkert.org * Copyright (c) 2003 The Regents of The University of Michigan
37087Snate@binkert.org * All rights reserved.
47087Snate@binkert.org *
57087Snate@binkert.org * Redistribution and use in source and binary forms, with or without
67087Snate@binkert.org * modification, are permitted provided that the following conditions are
77087Snate@binkert.org * met: redistributions of source code must retain the above copyright
87087Snate@binkert.org * notice, this list of conditions and the following disclaimer;
97087Snate@binkert.org * redistributions in binary form must reproduce the above copyright
107087Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
117087Snate@binkert.org * documentation and/or other materials provided with the distribution;
127087Snate@binkert.org * neither the name of the copyright holders nor the names of its
137087Snate@binkert.org * contributors may be used to endorse or promote products derived from
145124Sgblack@eecs.umich.edu * this software without specific prior written permission.
155124Sgblack@eecs.umich.edu *
165124Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
175124Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
185124Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
195124Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
205124Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
215124Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
225124Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
235124Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
245124Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
255124Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
265124Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
275124Sgblack@eecs.umich.edu */
285124Sgblack@eecs.umich.edu
295124Sgblack@eecs.umich.edu#ifndef __SYMTAB_HH__
305124Sgblack@eecs.umich.edu#define __SYMTAB_HH__
315124Sgblack@eecs.umich.edu
325124Sgblack@eecs.umich.edu#include <map>
335124Sgblack@eecs.umich.edu#include "targetarch/isa_traits.hh"	// for Addr
345124Sgblack@eecs.umich.edu
355124Sgblack@eecs.umich.educlass SymbolTable
365124Sgblack@eecs.umich.edu{
375124Sgblack@eecs.umich.edu  private:
385124Sgblack@eecs.umich.edu    typedef std::map<Addr, std::string> ATable;
395124Sgblack@eecs.umich.edu    typedef std::map<std::string, Addr> STable;
405124Sgblack@eecs.umich.edu
415124Sgblack@eecs.umich.edu    ATable addrTable;
425124Sgblack@eecs.umich.edu    STable symbolTable;
438961Sgblack@eecs.umich.edu
445124Sgblack@eecs.umich.edu  public:
458740Sgblack@eecs.umich.edu    SymbolTable() {}
465124Sgblack@eecs.umich.edu    SymbolTable(const std::string &file) { load(file); }
475124Sgblack@eecs.umich.edu    ~SymbolTable() {}
488232Snate@binkert.org
498740Sgblack@eecs.umich.edu    bool insert(Addr address, std::string symbol);
505124Sgblack@eecs.umich.edu    bool load(const std::string &file);
515124Sgblack@eecs.umich.edu
525124Sgblack@eecs.umich.edu    bool findNearestSymbol(Addr address, std::string &symbol) const;
5310417Sandreas.hansson@arm.com    bool findSymbol(Addr address, std::string &symbol) const;
545124Sgblack@eecs.umich.edu    bool findAddress(const std::string &symbol, Addr &address) const;
558806Sgblack@eecs.umich.edu
568806Sgblack@eecs.umich.edu    std::string find(Addr addr) const;
578806Sgblack@eecs.umich.edu    Addr find(const std::string &symbol) const;
588806Sgblack@eecs.umich.edu};
598806Sgblack@eecs.umich.edu
608806Sgblack@eecs.umich.edu#endif // __SYMTAB_HH__
618806Sgblack@eecs.umich.edu