1 /* Copyright (C) 2021 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
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)
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.
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. */
24 #include "Experiment.h"
25 #include "LoadObject.h"
26 #include "DbeSession.h"
28 //////////////////////////////////////////////////////////
31 int ExpGroup::phaseCompareIdx = 0;
33 ExpGroup::ExpGroup (char *nm)
35 name = dbe_strdup (nm);
36 canonical_path (name);
37 exps = new Vector<Experiment*>;
45 ExpGroup::~ExpGroup ()
55 ExpGroup::append (Experiment *exp)
57 for (int i = 0, sz = exps->size (); i < sz; i++)
59 Experiment *e = exps->fetch (i);
64 if (exps->size () == 1)
69 ExpGroup::drop_experiment (Experiment *exp)
71 for (int i = 0, sz = exps->size (); i < sz; i++)
73 Experiment *e = exps->fetch (i);
85 ExpGroup::get_founders ()
87 Vector<Experiment*> *expList = NULL;
88 for (int i = 0, sz = exps ? exps->size () : 0; i < sz; i++)
90 Experiment *exp = exps->fetch (i);
91 if (exp->founder_exp == NULL)
94 expList = new Vector<Experiment*>;
95 expList->append (exp);
102 ExpGroup::create_list_of_loadObjects ()
104 if (loadObjs == NULL)
106 loadObjs = new Vector<LoadObject*>();
107 loadObjsMap = new DefaultMap<LoadObject*, int>();
108 for (int i = 0, sz = exps ? exps->size () : 0; i < sz; i++)
110 Experiment *exp = exps->fetch (i);
111 for (int i1 = 0, sz1 = VecSize(exp->loadObjs); i1 < sz1; i1++)
113 LoadObject *lo = exp->loadObjs->fetch (i1);
114 if (!loadObjsMap->get (lo))
116 loadObjs->append (lo);
117 loadObjsMap->put (lo, loadObjs->size ());
125 ExpGroup::get_comparable_loadObject (LoadObject *lo)
127 create_list_of_loadObjects ();
128 if (loadObjsMap->get (lo))
130 if ((lo->flags & SEG_FLAG_EXE) != 0)
131 if (dbeSession->expGroups->size () == dbeSession->nexps ())
132 for (int i = 0, sz = loadObjs ? loadObjs->size () : 0; i < sz; i++)
134 LoadObject *lobj = loadObjs->fetch (i);
135 if ((lobj->flags & SEG_FLAG_EXE) != 0)
140 char *bname = get_basename (lo->get_pathname ());
141 for (long i = 0, sz = loadObjs ? loadObjs->size () : 0; i < sz; i++)
143 LoadObject *lobj = loadObjs->get (i);
144 if (lobj->comparable_objs == NULL
145 && strcmp (bname, get_basename (lobj->get_pathname ())) == 0)
147 if (lo->platform == lobj->platform)
149 if ((lo->flags & SEG_FLAG_DYNAMIC) != 0)
151 if (dbe_strcmp (lo->firstExp->uarglist,
152 lobj->firstExp->uarglist) == 0)
162 return first_ind == -1 ? NULL : loadObjs->get (first_ind);