xref: /netbsd-src/external/gpl3/binutils/dist/gprofng/src/ClassFile.h (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
1*cb63e24eSchristos /* Copyright (C) 2021-2024 Free Software Foundation, Inc.
24f645668Schristos    Contributed by Oracle.
34f645668Schristos 
44f645668Schristos    This file is part of GNU Binutils.
54f645668Schristos 
64f645668Schristos    This program is free software; you can redistribute it and/or modify
74f645668Schristos    it under the terms of the GNU General Public License as published by
84f645668Schristos    the Free Software Foundation; either version 3, or (at your option)
94f645668Schristos    any later version.
104f645668Schristos 
114f645668Schristos    This program is distributed in the hope that it will be useful,
124f645668Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
134f645668Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
144f645668Schristos    GNU General Public License for more details.
154f645668Schristos 
164f645668Schristos    You should have received a copy of the GNU General Public License
174f645668Schristos    along with this program; if not, write to the Free Software
184f645668Schristos    Foundation, 51 Franklin Street - Fifth Floor, Boston,
194f645668Schristos    MA 02110-1301, USA.  */
204f645668Schristos 
214f645668Schristos #ifndef _CLASSFILE_H
224f645668Schristos #define _CLASSFILE_H
234f645668Schristos 
244f645668Schristos #include "Module.h"
254f645668Schristos 
264f645668Schristos class DataInputStream;
274f645668Schristos class BinaryConstantPool;
284f645668Schristos class JMethod;
294f645668Schristos class StringBuilder;
304f645668Schristos class ByteCodeInfo;
314f645668Schristos 
324f645668Schristos class ClassFile : public Module
334f645668Schristos {
344f645668Schristos public:
354f645668Schristos   ClassFile ();
364f645668Schristos   virtual ~ClassFile ();
374f645668Schristos   virtual int readFile ();
384f645668Schristos   virtual char *get_disasm (uint64_t inst_address, uint64_t end_address,
394f645668Schristos 			    uint64_t start_address, uint64_t f_offset,
404f645668Schristos 			    int64_t &inst_size);
414f645668Schristos   static char *get_java_file_name (char *clname, bool classSuffix);
424f645668Schristos 
434f645668Schristos private:
444f645668Schristos 
454f645668Schristos   void openFile (const char *fname);
464f645668Schristos   char *get_opc_name (int op);
474f645668Schristos   void readAttributes (int count);
484f645668Schristos   void printConstant (StringBuilder *sb, int index);
494f645668Schristos   long long printCodeSequence (StringBuilder *sb, uint64_t addr, DataInputStream *in);
504f645668Schristos 
514f645668Schristos   unsigned char *cf_buf;
524f645668Schristos   int64_t cf_bufsz;
534f645668Schristos   int blanksCnt;
544f645668Schristos   DataInputStream *input;
554f645668Schristos   BinaryConstantPool *bcpool;
564f645668Schristos   JMethod *cur_jmthd;
574f645668Schristos   char *class_name;
584f645668Schristos   char *class_filename;
594f645668Schristos   char *source_name;
604f645668Schristos   Vector<ByteCodeInfo *> *byteCodeInfo;
614f645668Schristos };
624f645668Schristos 
634f645668Schristos #endif
64