1057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// -*- mode: c++ -*- 2057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 383e085b7a331c96237cf8e814f97b3ef4c36a70fjimblandy// Copyright (c) 2010 Google Inc. 4057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// All rights reserved. 5057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// 6057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// Redistribution and use in source and binary forms, with or without 7057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// modification, are permitted provided that the following conditions are 8057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// met: 9057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// 10057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// * Redistributions of source code must retain the above copyright 11057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// notice, this list of conditions and the following disclaimer. 12057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// * Redistributions in binary form must reproduce the above 13057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// copyright notice, this list of conditions and the following disclaimer 14057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// in the documentation and/or other materials provided with the 15057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// distribution. 16057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// * Neither the name of Google Inc. nor the names of its 17057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// contributors may be used to endorse or promote products derived from 18057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// this software without specific prior written permission. 19057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// 20057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 32c50e7c604cd1b12bba9421b0a95357fc942ecd7cjimblandy// Original author: Jim Blandy <jimb@mozilla.com> <jimb@red-bean.com> 33c50e7c604cd1b12bba9421b0a95357fc942ecd7cjimblandy 34c50e7c604cd1b12bba9421b0a95357fc942ecd7cjimblandy// language.h: Define google_breakpad::Language. Instances of 35c50e7c604cd1b12bba9421b0a95357fc942ecd7cjimblandy// subclasses of this class provide language-appropriate operations 36c50e7c604cd1b12bba9421b0a95357fc942ecd7cjimblandy// for the Breakpad symbol dumper. 37057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 38057aa1f6173501e1a62cf91fd08275e7da439166jimblandy#ifndef COMMON_LINUX_LANGUAGE_H__ 39057aa1f6173501e1a62cf91fd08275e7da439166jimblandy#define COMMON_LINUX_LANGUAGE_H__ 40057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 41057aa1f6173501e1a62cf91fd08275e7da439166jimblandy#include <string> 42057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 434e518a4357a2d1c379d4a91df6d4e153ee791101ivan.penkov@gmail.com#include "common/using_std_string.h" 44057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 454e518a4357a2d1c379d4a91df6d4e153ee791101ivan.penkov@gmail.comnamespace google_breakpad { 46057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 47057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// An abstract base class for language-specific operations. We choose 48057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// an instance of a subclass of this when we find the CU's language. 49057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// This class's definitions are appropriate for CUs with no specified 50057aa1f6173501e1a62cf91fd08275e7da439166jimblandy// language. 51057aa1f6173501e1a62cf91fd08275e7da439166jimblandyclass Language { 52057aa1f6173501e1a62cf91fd08275e7da439166jimblandy public: 53b732342313268422c0c0794dfb1a82cd17ce9e05ivan.penkov@gmail.com // A base class destructor should be either public and virtual, 54b732342313268422c0c0794dfb1a82cd17ce9e05ivan.penkov@gmail.com // or protected and nonvirtual. 55b732342313268422c0c0794dfb1a82cd17ce9e05ivan.penkov@gmail.com virtual ~Language() {} 56b732342313268422c0c0794dfb1a82cd17ce9e05ivan.penkov@gmail.com 57057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Return true if this language has functions to which we can assign 58057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // line numbers. (Debugging info for assembly language, for example, 59057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // can have source location information, but does not have functions 60057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // recorded using DW_TAG_subprogram DIEs.) 61057aa1f6173501e1a62cf91fd08275e7da439166jimblandy virtual bool HasFunctions() const { return true; } 62057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 63057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Construct a fully-qualified, language-appropriate form of NAME, 64057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // given that PARENT_NAME is the name of the construct enclosing 65057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // NAME. If PARENT_NAME is the empty string, then NAME is a 66057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // top-level name. 67057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // 68057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // This API sort of assumes that a fully-qualified name is always 69057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // some simple textual composition of the unqualified name and its 70057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // parent's name, and that we don't need to know anything else about 71057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // the parent or the child (say, their DIEs' tags) to do the job. 72057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // This is true for the languages we support at the moment, and 73057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // keeps things concrete. Perhaps a more refined operation would 74057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // take into account the parent and child DIE types, allow languages 75057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // to use their own data type for complex parent names, etc. But if 76057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // C++ doesn't need all that, who would? 77057aa1f6173501e1a62cf91fd08275e7da439166jimblandy virtual string MakeQualifiedName (const string &parent_name, 78057aa1f6173501e1a62cf91fd08275e7da439166jimblandy const string &name) const = 0; 79057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 80057aa1f6173501e1a62cf91fd08275e7da439166jimblandy // Instances for specific languages. 81057aa1f6173501e1a62cf91fd08275e7da439166jimblandy static const Language * const CPlusPlus, 82057aa1f6173501e1a62cf91fd08275e7da439166jimblandy * const Java, 83057aa1f6173501e1a62cf91fd08275e7da439166jimblandy * const Assembler; 84057aa1f6173501e1a62cf91fd08275e7da439166jimblandy}; 85057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 86057aa1f6173501e1a62cf91fd08275e7da439166jimblandy} // namespace google_breakpad 87057aa1f6173501e1a62cf91fd08275e7da439166jimblandy 88057aa1f6173501e1a62cf91fd08275e7da439166jimblandy#endif // COMMON_LINUX_LANGUAGE_H__ 89