1262182Semaste//===-- SectionLoadHistory.h ------------------------------------*- C++ -*-===// 2262182Semaste// 3262182Semaste// The LLVM Compiler Infrastructure 4262182Semaste// 5262182Semaste// This file is distributed under the University of Illinois Open Source 6262182Semaste// License. See LICENSE.TXT for details. 7262182Semaste// 8262182Semaste//===----------------------------------------------------------------------===// 9262182Semaste 10262182Semaste#ifndef liblldb_SectionLoadHistory_h_ 11262182Semaste#define liblldb_SectionLoadHistory_h_ 12262182Semaste 13262182Semaste// C Includes 14262182Semaste// C++ Includes 15262182Semaste#include <map> 16262182Semaste 17262182Semaste// Project includes 18262182Semaste#include "lldb/lldb-public.h" 19262182Semaste#include "lldb/Host/Mutex.h" 20262182Semaste 21262182Semastenamespace lldb_private { 22262182Semaste 23262182Semasteclass SectionLoadHistory 24262182Semaste{ 25262182Semastepublic: 26262182Semaste enum { 27262182Semaste // Pass eStopIDNow to any function that takes a stop ID to get 28262182Semaste // the current value. 29262182Semaste eStopIDNow = UINT32_MAX 30262182Semaste }; 31262182Semaste //------------------------------------------------------------------ 32262182Semaste // Constructors and Destructors 33262182Semaste //------------------------------------------------------------------ 34262182Semaste SectionLoadHistory () : 35262182Semaste m_stop_id_to_section_load_list(), 36262182Semaste m_mutex (Mutex::eMutexTypeRecursive) 37262182Semaste { 38262182Semaste } 39262182Semaste 40262182Semaste ~SectionLoadHistory() 41262182Semaste { 42262182Semaste // Call clear since this takes a lock and clears the section load list 43262182Semaste // in case another thread is currently using this section load list 44262182Semaste Clear(); 45262182Semaste } 46262182Semaste 47262182Semaste SectionLoadList & 48262182Semaste GetCurrentSectionLoadList (); 49262182Semaste 50262182Semaste bool 51262182Semaste IsEmpty() const; 52262182Semaste 53262182Semaste void 54262182Semaste Clear (); 55262182Semaste 56262182Semaste uint32_t 57262182Semaste GetLastStopID() const; 58262182Semaste 59262182Semaste // Get the section load address given a process stop ID 60262182Semaste lldb::addr_t 61262182Semaste GetSectionLoadAddress (uint32_t stop_id, 62262182Semaste const lldb::SectionSP §ion_sp); 63262182Semaste 64262182Semaste bool 65262182Semaste ResolveLoadAddress (uint32_t stop_id, 66262182Semaste lldb::addr_t load_addr, 67262182Semaste Address &so_addr); 68262182Semaste 69262182Semaste bool 70262182Semaste SetSectionLoadAddress (uint32_t stop_id, 71262182Semaste const lldb::SectionSP §ion_sp, 72262182Semaste lldb::addr_t load_addr, 73262182Semaste bool warn_multiple = false); 74262182Semaste 75262182Semaste // The old load address should be specified when unloading to ensure we get 76262182Semaste // the correct instance of the section as a shared library could be loaded 77262182Semaste // at more than one location. 78262182Semaste bool 79262182Semaste SetSectionUnloaded (uint32_t stop_id, 80262182Semaste const lldb::SectionSP §ion_sp, 81262182Semaste lldb::addr_t load_addr); 82262182Semaste 83262182Semaste // Unload all instances of a section. This function can be used on systems 84262182Semaste // that don't support multiple copies of the same shared library to be 85262182Semaste // loaded at the same time. 86262182Semaste size_t 87262182Semaste SetSectionUnloaded (uint32_t stop_id, 88262182Semaste const lldb::SectionSP §ion_sp); 89262182Semaste 90262182Semaste void 91262182Semaste Dump (Stream &s, 92262182Semaste Target *target); 93262182Semaste 94262182Semasteprotected: 95262182Semaste 96262182Semaste SectionLoadList * 97262182Semaste GetSectionLoadListForStopID (uint32_t stop_id, bool read_only); 98262182Semaste 99262182Semaste typedef std::map<uint32_t, lldb::SectionLoadListSP> StopIDToSectionLoadList; 100262182Semaste StopIDToSectionLoadList m_stop_id_to_section_load_list; 101262182Semaste mutable Mutex m_mutex; 102262182Semaste 103262182Semasteprivate: 104262182Semaste DISALLOW_COPY_AND_ASSIGN (SectionLoadHistory); 105262182Semaste}; 106262182Semaste 107262182Semaste} // namespace lldb_private 108262182Semaste 109262182Semaste#endif // liblldb_SectionLoadHistory_h_ 110