2 * See the dyninst/COPYRIGHT file for copyright information.
4 * We provide the Paradyn Tools (below described as "Paradyn")
5 * on an AS IS basis, and do not warrant its validity or performance.
6 * We reserve the right to update, modify, or discontinue this
7 * software at any time. We shall have no obligation to supply such
8 * updates or modifications or any other form of support to you.
10 * By your use of Paradyn, you understand and agree that we (or any
11 * other person or entity with proprietary rights in Paradyn) are
12 * under no obligation to provide either maintenance services,
13 * update services, notices of latent defects, or correction of
14 * defects for Paradyn.
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License as published by the Free Software Foundation; either
19 * version 2.1 of the License, or (at your option) any later version.
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
26 * You should have received a copy of the GNU Lesser General Public
27 * License along with this library; if not, write to the Free Software
28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31 #include "stackwalk/h/swk_errors.h"
32 #include "stackwalk/h/procstate.h"
33 #include "stackwalk/src/libstate.h"
34 #include "common/src/headers.h"
39 using namespace Dyninst;
40 using namespace Dyninst::Stackwalker;
43 class DefaultLibState : public LibraryState
46 DefaultLibState(ProcessState *parent) :
51 virtual bool getLibraryAtAddr(Address, LibAddrPair &) {
55 virtual bool getLibraries(std::vector<LibAddrPair> &, bool) {
59 virtual void notifyOfUpdate() {
62 virtual Address getLibTrapAddress() {
70 std::map<Dyninst::PID, ProcessState *> ProcessState::proc_map;
72 ProcessState::ProcessState(Dyninst::PID pid_, std::string executable_path_) :
74 library_tracker(NULL),
76 executable_path(executable_path_)
78 std::map<PID, ProcessState *>::iterator i = proc_map.find(pid_);
79 if (i != proc_map.end())
81 sw_printf("[%s:%u] - Already attached to debuggee %d\n",
82 FILE__, __LINE__, pid_);
83 setLastError(err_badparam, "Attach requested to already " \
90 void ProcessState::setPid(Dyninst::PID pid_)
96 Dyninst::PID ProcessState::getProcessId()
101 bool ProcessState::preStackwalk(Dyninst::THR_ID)
106 bool ProcessState::postStackwalk(Dyninst::THR_ID)
111 void ProcessState::setDefaultLibraryTracker()
113 if (library_tracker) return;
115 std::string execp("");
116 ProcDebug *pd = dynamic_cast<ProcDebug *>(this);
117 if (!library_tracker) {
119 execp = pd->getExecutablePath();
120 library_tracker = new TrackLibState(this, execp);
124 Walker *ProcessState::getWalker() const
129 ProcessState::~ProcessState()
132 delete library_tracker;
136 ProcessState *ProcessState::getProcessStateByPid(Dyninst::PID pid) {
137 map<PID, ProcessState *>::iterator i = proc_map.find(pid);
138 if (i == proc_map.end())
143 unsigned ProcSelf::getAddressWidth()
145 return sizeof(void *);
148 bool ProcSelf::isFirstParty()
153 ProcSelf::~ProcSelf()
157 LibraryState::LibraryState(ProcessState *parent) :
162 LibraryState::~LibraryState()
166 LibraryState *ProcessState::getLibraryTracker()
168 return library_tracker;