xref: /netbsd-src/external/gpl3/binutils/dist/gprofng/src/ClassFile.h (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
1 /* Copyright (C) 2021-2024 Free Software Foundation, Inc.
2    Contributed by Oracle.
3 
4    This file is part of GNU Binutils.
5 
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3, or (at your option)
9    any later version.
10 
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, 51 Franklin Street - Fifth Floor, Boston,
19    MA 02110-1301, USA.  */
20 
21 #ifndef _CLASSFILE_H
22 #define _CLASSFILE_H
23 
24 #include "Module.h"
25 
26 class DataInputStream;
27 class BinaryConstantPool;
28 class JMethod;
29 class StringBuilder;
30 class ByteCodeInfo;
31 
32 class ClassFile : public Module
33 {
34 public:
35   ClassFile ();
36   virtual ~ClassFile ();
37   virtual int readFile ();
38   virtual char *get_disasm (uint64_t inst_address, uint64_t end_address,
39 			    uint64_t start_address, uint64_t f_offset,
40 			    int64_t &inst_size);
41   static char *get_java_file_name (char *clname, bool classSuffix);
42 
43 private:
44 
45   void openFile (const char *fname);
46   char *get_opc_name (int op);
47   void readAttributes (int count);
48   void printConstant (StringBuilder *sb, int index);
49   long long printCodeSequence (StringBuilder *sb, uint64_t addr, DataInputStream *in);
50 
51   unsigned char *cf_buf;
52   int64_t cf_bufsz;
53   int blanksCnt;
54   DataInputStream *input;
55   BinaryConstantPool *bcpool;
56   JMethod *cur_jmthd;
57   char *class_name;
58   char *class_filename;
59   char *source_name;
60   Vector<ByteCodeInfo *> *byteCodeInfo;
61 };
62 
63 #endif
64