# dp_codinfo.h

Go to the documentation of this file.

    00001 ///
    00002 /// \file       dp_codinfo.h
    00003 ///             Debug file parsing
    00004 ///
    00005
    00006 /*
    00007     Copyright (C) 2009, Nicolas VIVIEN
    00008
    00009     This program is free software; you can redistribute it and/or modify
    00010     it under the terms of the GNU General Public License as published by
    00011     the Free Software Foundation; either version 2 of the License, or
    00012     (at your option) any later version.
    00013
    00014     This program is distributed in the hope that it will be useful,
    00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00017
    00018     See the GNU General Public License in the COPYING file at the
    00019     root directory of this project for more details.
    00020 */
    00021
    00022 #ifndef __BARRYJDG_CODINFO_H__
    00023 #define __BARRYJDG_CODINFO_H__
    00024
    00025
    00026 #include "dll.h"
    00027 #include <iosfwd>
    00028 #include <string>
    00029 #include <vector>
    00030 #include <stdint.h>
    00031
    00032
    00033 namespace Barry {
    00034
    00035 namespace JDG {
    00036
    00037
    00038 class BXEXPORT DebugFileEntry
    00039 {
    00040 private:
    00041 protected:
    00042
    00043 public:
    00044         std::string fileName;
    00045         std::string appName;
    00046         uint32_t uniqueId;
    00047
    00048         void Dump(std::ostream &os) const;
    00049 };
    00050
    00051
    00052 class BXEXPORT DebugFileList : public std::vector<DebugFileEntry>
    00053 {
    00054 public:
    00055         typedef std::vector<DebugFileEntry>             base_type;
    00056         typedef base_type::iterator                     iterator;
    00057         typedef base_type::const_iterator               const_iterator;
    00058
    00059 public:
    00060         void AddElement(uint32_t uniqueid, const std::string &appname, const std::string &filename);
    00061         void Dump(std::ostream &os) const;
    00062 };
    00063 inline std::ostream& operator<<(std::ostream &os, const DebugFileList &list) {
    00064         list.Dump(os);
    00065         return os;
    00066 }
    00067
    00068
    00069 class BXEXPORT ClassEntry
    00070 {
    00071 private:
    00072 protected:
    00073
    00074 public:
    00075         // For JDB
    00076         int index;
    00077
    00078         // Read from the ".debug" file
    00079         std::string className;
    00080         std::string classPath;
    00081         std::string sourceFile;
    00082
    00083         uint32_t type;
    00084         uint32_t unknown02;
    00085         uint32_t unknown03;
    00086         uint32_t id;
    00087         uint32_t unknown05;
    00088         uint32_t unknown06;
    00089         uint32_t unknown07;
    00090         uint32_t unknown08;
    00091
    00092         std::string GetFullClassName() { return classPath + "." + className; };
    00093 };
    00094
    00095
    00096 class BXEXPORT ClassList : public std::vector<ClassEntry>
    00097 {
    00098 public:
    00099         typedef std::vector<ClassEntry>                 base_type;
    00100         typedef base_type::iterator                     iterator;
    00101         typedef base_type::const_iterator               const_iterator;
    00102
    00103 public:
    00104         void CreateDefaultEntries();
    00105 };
    00106
    00107
    00108
    00109
    00110
    00111 class BXEXPORT CodInfo
    00112 {
    00113 private:
    00114         uint32_t ParseNextHeaderField(std::istream &input);
    00115         uint32_t ParseNextTypeField(std::istream &input);
    00116
    00117         void ParseAppName(std::istream &input);
    00118         void ParseUniqueId(std::istream &input);
    00119
    00120         void ParseBoolean(std::istream &input);
    00121         void ParseByte(std::istream &input);
    00122         void ParseChar(std::istream &input);
    00123         void ParseShort(std::istream &input);
    00124         void ParseInt(std::istream &input);
    00125         void ParseLong(std::istream &input);
    00126         void ParseClass(std::istream &input);
    00127         void ParseArray(std::istream &input);
    00128         void ParseVoid(std::istream &input);
    00129         void ParseDouble(std::istream &input);
    00130
    00131 protected:
    00132
    00133 public:
    00134         uint32_t uniqueId;
    00135         std::string appName;
    00136         ClassList classList;
    00137
    00138         bool LoadDebugFile(const char *filename);
    00139
    00140         void ParseHeaderSection(std::istream &input);
    00141         void ParseTypeSection(std::istream &input);
    00142         void ParseResourceSection(std::istream &input);
    00143
    00144         uint32_t GetUniqueId();
    00145         std::string GetAppName();
    00146 };
    00147
    00148
    00149 BXEXPORT void SearchDebugFile(DebugFileList &list);
    00150 BXEXPORT bool LoadDebugInfo(const DebugFileList &list, const char *filename, CodInfo &info);
    00151 BXEXPORT bool LoadDebugInfo(const DebugFileList &list, const uint32_t uniqueId, const std::string module, CodInfo &info);
    00152
    00153
    00154 } // namespace JDG
    00155
    00156 } // namespace Barry
    00157
    00158
    00159 #endif
    00160