1/* Copyright (C) 2021 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 _DATAOBJECT_H
22#define _DATAOBJECT_H
23
24// A DataObject object represents a distinct dataobject.
25
26#include "dbe_structs.h"
27#include "Histable.h"
28
29extern char *DOBJ_UNSPECIFIED;
30extern char *DOBJ_UNIDENTIFIED;
31extern char *DOBJ_UNDETERMINED;
32extern char *DOBJ_ANON;
33extern char *DOBJ_UNASCERTAINABLE;
34extern char *DOBJ_UNVERIFIABLE;
35extern char *DOBJ_UNRESOLVABLE;
36
37class DataObject : public Histable
38{
39public:
40  DataObject ();
41  ~DataObject ();
42
43  static const unsigned UNSPECIFIED_ID = 0xFFFFFFFF;
44
45  int64_t size;             // size of the dataobject in bytes
46  int64_t offset;           // offset of dataobject from parent
47  DataObject *parent;       // this dataobject's parent (if any)
48  Histable *scope;          // scope of this dataobject
49  DataObject *master;       // this dataobject's master (if any)
50
51  Histable_type get_type ()         { return DOBJECT; }
52  int64_t get_size ()               { return size; }
53  int64_t get_offset ()             { return offset; }
54  DataObject *get_parent ()         { return parent; }
55  DataObject *get_master ()         { return master; }
56  char *get_typename ()             { return _typename; }
57  char *get_instname ()             { return _instname; }
58  Histable *get_scope ()            { return scope; }
59
60  char *get_unannotated_name ()
61  { // name without a <Scalar> or <Unknown> prefix
62    if (_unannotated_name)
63      return _unannotated_name;
64    return get_name ();
65  }
66
67  uint64_t get_addr ();
68  char get_offset_mark ();
69  char *get_offset_name ();
70  void set_dobjname (char *type_name, char *inst_name); // dobj->parent must already be set
71  void set_name (char *);
72  Histable *convertto (Histable_type type, Histable *obj = NULL);
73  DbeEA *find_dbeEA (Vaddr EA);
74
75private:
76  char *_unannotated_name;  // name without a <Scalar> or <Unknown> prefix
77  char *_typename;          // name of this dataobject's type
78  char *_instname;          // name of this dataobject instance
79  Vector<DbeEA*> *EAs;
80};
81
82#endif  /* _DATAOBJECT_H */
83