blob: 9ce418dead204bb512e72f601466fcaa3dbfc6d5 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- Section.cpp ---------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/Core/Section.h"
11#include "lldb/Core/Module.h"
12#include "lldb/Symbol/ObjectFile.h"
Greg Claytonf5e56de2010-09-14 23:36:40 +000013#include "lldb/Target/Target.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000014
15using namespace lldb;
16using namespace lldb_private;
17
18Section::Section
19(
20 Section *parent,
21 Module* module,
22 user_id_t sect_id,
23 const ConstString &name,
24 SectionType sect_type,
25 addr_t file_addr,
26 addr_t byte_size,
27 uint64_t file_offset,
28 uint64_t file_size,
29 uint32_t flags
30) :
31 ModuleChild (module),
32 UserID (sect_id),
33 Flags (flags),
34 m_parent (parent),
35 m_name (name),
36 m_type (sect_type),
37 m_file_addr (file_addr),
38 m_byte_size (byte_size),
39 m_file_offset (file_offset),
40 m_file_size (file_size),
41 m_children (),
42 m_fake (false),
43 m_linked_section(NULL),
44 m_linked_offset (0)
45{
46}
47
Chris Lattner30fdc8d2010-06-08 16:52:24 +000048Section::~Section()
49{
50}
51
52
53// Get a valid shared pointer to this section object
54SectionSP
55Section::GetSharedPointer() const
56{
57 SectionSP this_sp;
58 if (m_parent)
59 this_sp = m_parent->GetChildren().GetSharedPointer (this, false);
60 else
61 {
62 ObjectFile *objfile = m_module->GetObjectFile();
63 if (objfile)
64 {
65 SectionList *section_list = objfile->GetSectionList();
66 if (section_list)
67 this_sp = section_list->GetSharedPointer (this, false);
68 }
69 }
70 return this_sp;
71}
72
73
74
75ConstString&
76Section::GetName()
77{
78 if (m_linked_section)
79 return const_cast<Section *>(m_linked_section)->GetName();
80 return m_name;
81}
82
83const ConstString&
84Section::GetName() const
85{
86 if (m_linked_section)
87 return m_linked_section->GetName();
88 return m_name;
89}
90
Chris Lattner30fdc8d2010-06-08 16:52:24 +000091addr_t
92Section::GetFileAddress () const
93{
94 if (m_parent)
95 {
96 // This section has a parent which means m_file_addr is an offset into
97 // the parent section, so the file address for this section is the file
98 // address of the parent plus the offset
99 return m_parent->GetFileAddress() + m_file_addr;
100 }
101 // This section has no parent, so m_file_addr is the file base address
102 return m_file_addr;
103}
104
105addr_t
106Section::GetLinkedFileAddress () const
107{
108 if (m_linked_section)
109 return m_linked_section->GetFileAddress() + m_linked_offset;
110 return LLDB_INVALID_ADDRESS;
111}
112
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000113
114addr_t
Greg Claytonf5e56de2010-09-14 23:36:40 +0000115Section::GetLoadBaseAddress (Target *target) const
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000116{
117 addr_t load_base_addr = LLDB_INVALID_ADDRESS;
118 if (m_linked_section)
119 {
Greg Claytonf5e56de2010-09-14 23:36:40 +0000120 load_base_addr = m_linked_section->GetLoadBaseAddress(target) + m_linked_offset;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000121 }
122 else
123 if (m_parent)
124 {
Greg Claytonf5e56de2010-09-14 23:36:40 +0000125 load_base_addr = m_parent->GetLoadBaseAddress (target);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000126 if (load_base_addr != LLDB_INVALID_ADDRESS)
127 load_base_addr += GetOffset();
128 }
129 else
130 {
Greg Claytonf5e56de2010-09-14 23:36:40 +0000131 load_base_addr = target->GetSectionLoadList().GetSectionLoadAddress (this);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000132 }
133
134 return load_base_addr;
135}
136
137bool
138Section::ResolveContainedAddress (addr_t offset, Address &so_addr) const
139{
140 const uint32_t num_children = m_children.GetSize();
141 if (num_children > 0)
142 {
143 for (uint32_t i=0; i<num_children; i++)
144 {
145 Section* child_section = m_children.GetSectionAtIndex (i).get();
146
147 addr_t child_offset = child_section->GetOffset();
148 if (child_offset <= offset && offset - child_offset < child_section->GetByteSize())
149 return child_section->ResolveContainedAddress (offset - child_offset, so_addr);
150 }
151 }
152 if (m_linked_section)
153 {
154 so_addr.SetOffset(m_linked_offset + offset);
155 so_addr.SetSection(m_linked_section);
156 }
157 else
158 {
159 so_addr.SetOffset(offset);
160 so_addr.SetSection(this);
161 }
162 return true;
163}
164
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000165bool
166Section::ContainsFileAddress (addr_t vm_addr) const
167{
168 const addr_t file_addr = GetFileAddress();
169 if (file_addr != LLDB_INVALID_ADDRESS)
170 {
171 if (file_addr <= vm_addr)
172 {
173 const addr_t offset = vm_addr - file_addr;
174 return offset < GetByteSize();
175 }
176 }
177 return false;
178}
179
180bool
181Section::ContainsLinkedFileAddress (addr_t vm_addr) const
182{
183 const addr_t linked_file_addr = GetLinkedFileAddress();
184 if (linked_file_addr != LLDB_INVALID_ADDRESS)
185 {
186 if (linked_file_addr <= vm_addr)
187 {
188 const addr_t offset = vm_addr - linked_file_addr;
189 return offset < GetByteSize();
190 }
191 }
192 return false;
193}
194
195int
196Section::Compare (const Section& a, const Section& b)
197{
198 if (&a == &b)
199 return 0;
200
201 const Module* a_module = a.GetModule();
202 const Module* b_module = b.GetModule();
203 if (a_module == b_module)
204 {
205 user_id_t a_sect_uid = a.GetID();
206 user_id_t b_sect_uid = b.GetID();
207 if (a_sect_uid < b_sect_uid)
208 return -1;
209 if (a_sect_uid > b_sect_uid)
210 return 1;
211 return 0;
212 }
213 else
214 {
215 // The modules are different, just compare the module pointers
216 if (a_module < b_module)
217 return -1;
218 else
219 return 1; // We already know the modules aren't equal
220 }
221}
222
223
224void
Greg Clayton89411422010-10-08 00:21:05 +0000225Section::Dump (Stream *s, Target *target) const
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000226{
Greg Clayton89411422010-10-08 00:21:05 +0000227// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000228 s->Indent();
Greg Clayton89411422010-10-08 00:21:05 +0000229 s->Printf("0x%8.8x %-14s ", GetID(), GetSectionTypeAsCString (m_type));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000230 bool resolved = true;
231 addr_t addr = LLDB_INVALID_ADDRESS;
232
233 if (GetByteSize() == 0)
234 s->Printf("%39s", "");
235 else
236 {
Greg Claytonf6693582010-12-07 18:05:22 +0000237 if (target && m_linked_section == NULL)
Greg Claytonf5e56de2010-09-14 23:36:40 +0000238 addr = GetLoadBaseAddress (target);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000239
240 if (addr == LLDB_INVALID_ADDRESS)
241 {
Greg Claytonf5e56de2010-09-14 23:36:40 +0000242 if (target)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000243 resolved = false;
244 addr = GetFileAddress();
245 }
246
247 VMRange range(addr, addr + m_byte_size);
248 range.Dump (s, 0);
249 }
250
Greg Clayton73b472d2010-10-27 03:32:59 +0000251 s->Printf("%c 0x%8.8llx 0x%8.8llx 0x%8.8x ", resolved ? ' ' : '*', m_file_offset, m_file_size, Get());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000252
253 DumpName (s);
254
255 s->EOL();
256
257 if (m_linked_section)
258 {
259 addr = LLDB_INVALID_ADDRESS;
Greg Claytonf6693582010-12-07 18:05:22 +0000260 resolved = true;
Greg Claytonf5e56de2010-09-14 23:36:40 +0000261 if (target)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000262 {
Greg Claytonf5e56de2010-09-14 23:36:40 +0000263 addr = m_linked_section->GetLoadBaseAddress(target);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000264 if (addr != LLDB_INVALID_ADDRESS)
265 addr += m_linked_offset;
266 }
267
268 if (addr == LLDB_INVALID_ADDRESS)
269 {
Greg Claytonf5e56de2010-09-14 23:36:40 +0000270 if (target)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000271 resolved = false;
272 addr = m_linked_section->GetFileAddress() + m_linked_offset;
273 }
274
Greg Clayton65e364e2010-12-07 07:37:38 +0000275 int indent = 26 + s->GetIndentLevel();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000276 s->Printf("%*.*s", indent, indent, "");
277 VMRange linked_range(addr, addr + m_byte_size);
278 linked_range.Dump (s, 0);
279 indent = 3 * (sizeof(uint32_t) * 2 + 2 + 1) + 1;
280 s->Printf("%c%*.*s", resolved ? ' ' : '*', indent, indent, "");
281
282 m_linked_section->DumpName(s);
283 s->Printf(" + 0x%llx\n", m_linked_offset);
284 }
285
Greg Claytonf5e56de2010-09-14 23:36:40 +0000286 m_children.Dump(s, target, false);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000287}
288
289void
290Section::DumpName (Stream *s) const
291{
Greg Clayton65e364e2010-12-07 07:37:38 +0000292 if (m_parent == NULL)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000293 {
294 // The top most section prints the module basename
295 const char *module_basename = m_module->GetFileSpec().GetFilename().AsCString();
296 if (module_basename && module_basename[0])
297 s->Printf("%s.", module_basename);
298 }
299 else
300 {
301 m_parent->DumpName (s);
302 s->PutChar('.');
303 }
304 m_name.Dump(s);
305}
306
307//----------------------------------------------------------------------
308// Get the section data from a complete contiguous copy of the
309// entire executable image.
310//----------------------------------------------------------------------
311size_t
312Section::GetSectionDataFromImage (const DataExtractor& image_data, DataExtractor& section_data) const
313{
314 size_t file_size = GetByteSize();
315 if (file_size > 0)
316 {
317 off_t file_offset = GetFileOffset();
318 if (section_data.SetData (image_data, file_offset, file_size) == file_size)
319 return true;
320 }
321 return false;
322}
323
Greg Claytondda4f7b2010-06-30 23:03:03 +0000324size_t
325Section::ReadSectionDataFromObjectFile (const ObjectFile* objfile, off_t section_offset, void *dst, size_t dst_len) const
326{
327 if (objfile && dst && dst_len)
328 {
329 const FileSpec& file = objfile->GetFileSpec();
330
331 if (file)
332 {
333 off_t section_file_offset = GetFileOffset() + objfile->GetOffset() + section_offset;
334 return file.ReadFileContents (section_file_offset, dst, dst_len);
335 }
336 }
337 return 0;
338}
339
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000340//----------------------------------------------------------------------
341// Get the section data the file on disk
342//----------------------------------------------------------------------
343size_t
344Section::ReadSectionDataFromObjectFile(const ObjectFile* objfile, DataExtractor& section_data) const
345{
346 if (objfile == NULL)
347 return 0;
348
349 const FileSpec& file = objfile->GetFileSpec();
350
351 if (file)
352 {
353 size_t section_file_size = GetByteSize();
354 if (section_file_size > 0)
355 {
356 off_t section_file_offset = GetFileOffset() + objfile->GetOffset();
Greg Claytondda4f7b2010-06-30 23:03:03 +0000357 DataBufferSP section_data_sp(file.ReadFileContents(section_file_offset, section_file_size));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000358
359 section_data.SetByteOrder(objfile->GetByteOrder());
360 section_data.SetAddressByteSize(objfile->GetAddressByteSize());
Greg Claytondda4f7b2010-06-30 23:03:03 +0000361 return section_data.SetData (section_data_sp);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000362 }
363 }
364 return 0;
365}
366
367size_t
368Section::MemoryMapSectionDataFromObjectFile(const ObjectFile* objfile, DataExtractor& section_data) const
369{
370 if (objfile == NULL)
371 return 0;
372
373 const FileSpec& file = objfile->GetFileSpec();
374
375 if (file)
376 {
377 size_t section_file_size = GetFileSize();
378 if (section_file_size > 0)
379 {
380 off_t section_file_offset = GetFileOffset() + objfile->GetOffset();
Greg Claytondda4f7b2010-06-30 23:03:03 +0000381 DataBufferSP section_data_sp(file.MemoryMapFileContents(section_file_offset, section_file_size));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000382 section_data.SetByteOrder(objfile->GetByteOrder());
383 section_data.SetAddressByteSize(objfile->GetAddressByteSize());
Greg Claytondda4f7b2010-06-30 23:03:03 +0000384 return section_data.SetData (section_data_sp);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000385 }
386 }
387 return 0;
388}
389
390bool
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000391Section::IsDescendant (const Section *section)
392{
393 if (this == section)
394 return true;
395 if (m_parent)
396 return m_parent->IsDescendant (section);
397 return false;
398}
399
400bool
401Section::Slide (addr_t slide_amount, bool slide_children)
402{
403 if (m_file_addr != LLDB_INVALID_ADDRESS)
404 {
405 if (slide_amount == 0)
406 return true;
407
408 m_file_addr += slide_amount;
409
410 if (slide_children)
411 m_children.Slide (slide_amount, slide_children);
412
413 return true;
414 }
415 return false;
416}
417
418void
419Section::SetLinkedLocation (const Section *linked_section, uint64_t linked_offset)
420{
421 if (linked_section)
422 m_module = linked_section->GetModule();
423 m_linked_section = linked_section;
424 m_linked_offset = linked_offset;
425}
426
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000427#pragma mark SectionList
428
429SectionList::SectionList () :
430 m_sections()
431{
432}
433
434
435SectionList::~SectionList ()
436{
437}
438
439uint32_t
440SectionList::AddSection (SectionSP& sect_sp)
441{
442 uint32_t section_index = m_sections.size();
443 m_sections.push_back(sect_sp);
444 return section_index;
445}
446
447uint32_t
448SectionList::FindSectionIndex (const Section* sect)
449{
450 iterator sect_iter;
451 iterator begin = m_sections.begin();
452 iterator end = m_sections.end();
453 for (sect_iter = begin; sect_iter != end; ++sect_iter)
454 {
455 if (sect_iter->get() == sect)
456 {
457 // The secton was already in this section list
458 return std::distance (begin, sect_iter);
459 }
460 }
461 return UINT32_MAX;
462}
463
464uint32_t
465SectionList::AddUniqueSection (SectionSP& sect_sp)
466{
467 uint32_t sect_idx = FindSectionIndex (sect_sp.get());
468 if (sect_idx == UINT32_MAX)
469 sect_idx = AddSection (sect_sp);
470 return sect_idx;
471}
472
473
474bool
475SectionList::ReplaceSection (user_id_t sect_id, SectionSP& sect_sp, uint32_t depth)
476{
477 iterator sect_iter, end = m_sections.end();
478 for (sect_iter = m_sections.begin(); sect_iter != end; ++sect_iter)
479 {
480 if ((*sect_iter)->GetID() == sect_id)
481 {
482 *sect_iter = sect_sp;
483 return true;
484 }
485 else if (depth > 0)
486 {
487 if ((*sect_iter)->GetChildren().ReplaceSection(sect_id, sect_sp, depth - 1))
488 return true;
489 }
490 }
491 return false;
492}
493
494
495size_t
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000496SectionList::GetNumSections (uint32_t depth) const
497{
498 size_t count = m_sections.size();
499 if (depth > 0)
500 {
501 const_iterator sect_iter, end = m_sections.end();
502 for (sect_iter = m_sections.begin(); sect_iter != end; ++sect_iter)
503 {
504 count += (*sect_iter)->GetChildren().GetNumSections(depth - 1);
505 }
506 }
507 return count;
508}
509
510SectionSP
511SectionList::GetSectionAtIndex (uint32_t idx) const
512{
513 SectionSP sect_sp;
514 if (idx < m_sections.size())
515 sect_sp = m_sections[idx];
516 return sect_sp;
517}
518
519SectionSP
520SectionList::FindSectionByName (const ConstString &section_dstr) const
521{
522 SectionSP sect_sp;
523 // Check if we have a valid section string
524 if (section_dstr)
525 {
526 const_iterator sect_iter;
527 const_iterator end = m_sections.end();
528 for (sect_iter = m_sections.begin(); sect_iter != end && sect_sp.get() == NULL; ++sect_iter)
529 {
530 if ((*sect_iter)->GetName() == section_dstr)
531 {
532 sect_sp = *sect_iter;
533 }
534 else
535 {
536 sect_sp = (*sect_iter)->GetChildren().FindSectionByName(section_dstr);
537 }
538 }
539 }
540 return sect_sp;
541}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000542
543SectionSP
544SectionList::FindSectionByID (user_id_t sect_id) const
545{
546 SectionSP sect_sp;
547 if (sect_id)
548 {
549 const_iterator sect_iter;
550 const_iterator end = m_sections.end();
551 for (sect_iter = m_sections.begin(); sect_iter != end && sect_sp.get() == NULL; ++sect_iter)
552 {
553 if ((*sect_iter)->GetID() == sect_id)
554 {
555 sect_sp = *sect_iter;
556 break;
557 }
558 else
559 {
560 sect_sp = (*sect_iter)->GetChildren().FindSectionByID (sect_id);
561 }
562 }
563 }
564 return sect_sp;
565}
566
Greg Clayton70e33eb2010-07-21 21:49:46 +0000567
568SectionSP
Greg Clayton4ceb9982010-07-21 22:54:26 +0000569SectionList::FindSectionByType (lldb::SectionType sect_type, bool check_children, uint32_t start_idx) const
Greg Clayton70e33eb2010-07-21 21:49:46 +0000570{
571 SectionSP sect_sp;
572 uint32_t num_sections = m_sections.size();
573 for (uint32_t idx = start_idx; idx < num_sections; ++idx)
574 {
575 if (m_sections[idx]->GetType() == sect_type)
576 {
577 sect_sp = m_sections[idx];
578 break;
579 }
Greg Clayton4ceb9982010-07-21 22:54:26 +0000580 else if (check_children)
581 {
582 sect_sp = m_sections[idx]->GetChildren().FindSectionByType (sect_type, check_children, 0);
583 if (sect_sp)
584 break;
585 }
Greg Clayton70e33eb2010-07-21 21:49:46 +0000586 }
587 return sect_sp;
588}
589
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000590SectionSP
591SectionList::GetSharedPointer (const Section *section, bool check_children) const
592{
593 SectionSP sect_sp;
594 if (section)
595 {
596 const_iterator sect_iter;
597 const_iterator end = m_sections.end();
598 for (sect_iter = m_sections.begin(); sect_iter != end && sect_sp.get() == NULL; ++sect_iter)
599 {
600 if (sect_iter->get() == section)
601 {
602 sect_sp = *sect_iter;
603 break;
604 }
605 else if (check_children)
606 {
607 sect_sp = (*sect_iter)->GetChildren().GetSharedPointer (section, true);
608 }
609 }
610 }
611 return sect_sp;
612}
613
614
615
616SectionSP
617SectionList::FindSectionContainingFileAddress (addr_t vm_addr, uint32_t depth) const
618{
619 SectionSP sect_sp;
620 const_iterator sect_iter;
621 const_iterator end = m_sections.end();
622 for (sect_iter = m_sections.begin(); sect_iter != end && sect_sp.get() == NULL; ++sect_iter)
623 {
624 Section *sect = sect_iter->get();
625 if (sect->ContainsFileAddress (vm_addr))
626 {
627 // The file address is in this section. We need to make sure one of our child
628 // sections doesn't contain this address as well as obeying the depth limit
629 // that was passed in.
630 if (depth > 0)
631 sect_sp = sect->GetChildren().FindSectionContainingFileAddress(vm_addr, depth - 1);
632
633 if (sect_sp.get() == NULL && !sect->IsFake())
634 sect_sp = *sect_iter;
635 }
636 }
637 return sect_sp;
638}
639
640
641SectionSP
Greg Clayton016a95e2010-09-14 02:20:48 +0000642SectionList::FindSectionContainingLinkedFileAddress (addr_t vm_addr, uint32_t depth) const
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000643{
644 SectionSP sect_sp;
645 const_iterator sect_iter;
646 const_iterator end = m_sections.end();
647 for (sect_iter = m_sections.begin(); sect_iter != end && sect_sp.get() == NULL; ++sect_iter)
648 {
649 Section *sect = sect_iter->get();
650 if (sect->ContainsLinkedFileAddress (vm_addr))
651 {
652 sect_sp = *sect_iter;
Greg Clayton016a95e2010-09-14 02:20:48 +0000653 }
654 else if (depth > 0)
655 {
656 sect_sp = sect->GetChildren().FindSectionContainingLinkedFileAddress (vm_addr, depth - 1);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000657 }
658 }
659 return sect_sp;
660}
661
662bool
663SectionList::ContainsSection(user_id_t sect_id) const
664{
665 return FindSectionByID (sect_id).get() != NULL;
666}
667
668void
Greg Claytonf5e56de2010-09-14 23:36:40 +0000669SectionList::Dump (Stream *s, Target *target, bool show_header) const
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000670{
Greg Claytonf6693582010-12-07 18:05:22 +0000671 bool target_has_loaded_sections = target && !target->GetSectionLoadList().IsEmpty();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000672 if (show_header && !m_sections.empty())
673 {
Greg Clayton89411422010-10-08 00:21:05 +0000674// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
675// s->Indent();
676// s->PutCString( "SectionList\n");
677// s->IndentMore();
678// s->Printf("%*s", 2*(sizeof(void *) + 2), "");
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000679 s->Indent();
Greg Claytonf6693582010-12-07 18:05:22 +0000680 s->Printf("SectID Type %s Address File Off. File Size Flags Section Name\n", target_has_loaded_sections ? "Load" : "File");
Greg Clayton89411422010-10-08 00:21:05 +0000681// s->Printf("%*s", 2*(sizeof(void *) + 2), "");
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000682 s->Indent();
Greg Clayton89411422010-10-08 00:21:05 +0000683 s->PutCString("---------- -------------- --------------------------------------- ---------- ---------- ---------- ----------------------------\n");
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000684 }
685
686
687 const_iterator sect_iter;
688 const_iterator end = m_sections.end();
689 for (sect_iter = m_sections.begin(); sect_iter != end; ++sect_iter)
690 {
Greg Claytonf6693582010-12-07 18:05:22 +0000691 (*sect_iter)->Dump(s, target_has_loaded_sections ? target : NULL);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000692 }
693
694 if (show_header && !m_sections.empty())
695 s->IndentLess();
696
697}
698
699size_t
700SectionList::Slide (addr_t slide_amount, bool slide_children)
701{
702 size_t count = 0;
703 const_iterator pos, end = m_sections.end();
704 for (pos = m_sections.begin(); pos != end; ++pos)
705 {
706 if ((*pos)->Slide(slide_amount, slide_children))
707 ++count;
708 }
709 return count;
710}
711