diff options
Diffstat (limited to 'gdb/gcore.c')
-rw-r--r-- | gdb/gcore.c | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/gdb/gcore.c b/gdb/gcore.c index fa15d06..e015f44 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -398,8 +398,8 @@ make_output_phdrs (bfd *obfd, asection *osec) DATA is 'bfd *' for the core file GDB is creating. */ static int -gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read, - int write, int exec, int modified, bool memory_tagged, +gcore_create_callback (CORE_ADDR vaddr, unsigned long size, bool read, + bool write, bool exec, bool modified, bool memory_tagged, void *data) { bfd *obfd = (bfd *) data; @@ -409,7 +409,7 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read, /* If the memory segment has no permissions set, ignore it, otherwise when we later try to access it for read/write, we'll get an error or jam the kernel. */ - if (read == 0 && write == 0 && exec == 0 && modified == 0) + if (!read && !write && !exec && !modified) { if (info_verbose) gdb_printf ("Ignore segment, %s bytes at %s\n", @@ -419,19 +419,19 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read, return 0; } - if (write == 0 && modified == 0 && !solib_keep_data_in_core (vaddr, size)) + if (!write && !modified && !solib_keep_data_in_core (vaddr, size)) { /* See if this region of memory lies inside a known file on disk. If so, we can avoid copying its contents by clearing SEC_LOAD. */ - for (objfile *objfile : current_program_space->objfiles ()) - for (obj_section *objsec : objfile->sections ()) + for (objfile &objfile : current_program_space->objfiles ()) + for (obj_section &objsec : objfile.sections ()) { - bfd *abfd = objfile->obfd.get (); - asection *asec = objsec->the_bfd_section; + bfd *abfd = objfile.obfd.get (); + asection *asec = objsec.the_bfd_section; bfd_vma align = (bfd_vma) 1 << bfd_section_alignment (asec); - bfd_vma start = objsec->addr () & -align; - bfd_vma end = (objsec->endaddr () + align - 1) & -align; + bfd_vma start = objsec.addr () & -align; + bfd_vma end = (objsec.endaddr () + align - 1) & -align; /* Match if either the entire memory region lies inside the section (i.e. a mapping covering some pages of a large @@ -440,7 +440,7 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read, This BFD was synthesized from reading target memory, we don't want to omit that. */ - if (objfile->separate_debug_objfile_backlink == NULL + if (objfile.separate_debug_objfile_backlink == NULL && ((vaddr >= start && vaddr + size <= end) || (start >= vaddr && end <= vaddr + size)) && !(bfd_get_file_flags (abfd) & BFD_IN_MEMORY)) @@ -453,7 +453,7 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read, keep:; } - if (write == 0) + if (!write) flags |= SEC_READONLY; if (exec) @@ -489,8 +489,8 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read, static int gcore_create_memtag_section_callback (CORE_ADDR vaddr, unsigned long size, - int read, int write, int exec, - int modified, bool memory_tagged, + bool read, bool write, bool exec, + bool modified, bool memory_tagged, void *data) { /* Are there memory tags in this particular memory map entry? */ @@ -532,14 +532,14 @@ objfile_find_memory_regions (struct target_ops *self, bfd_vma temp_bottom = 0, temp_top = 0; /* Call callback function for each objfile section. */ - for (objfile *objfile : current_program_space->objfiles ()) - for (obj_section *objsec : objfile->sections ()) + for (objfile &objfile : current_program_space->objfiles ()) + for (obj_section &objsec : objfile.sections ()) { - asection *isec = objsec->the_bfd_section; + asection *isec = objsec.the_bfd_section; flagword flags = bfd_section_flags (isec); /* Separate debug info files are irrelevant for gcore. */ - if (objfile->separate_debug_objfile_backlink != NULL) + if (objfile.separate_debug_objfile_backlink != NULL) continue; if ((flags & SEC_ALLOC) || (flags & SEC_LOAD)) @@ -547,11 +547,11 @@ objfile_find_memory_regions (struct target_ops *self, int size = bfd_section_size (isec); int ret; - ret = (*func) (objsec->addr (), size, - 1, /* All sections will be readable. */ + ret = (*func) (objsec.addr (), size, + true, /* All sections will be readable. */ (flags & SEC_READONLY) == 0, /* Writable. */ (flags & SEC_CODE) != 0, /* Executable. */ - 1, /* MODIFIED is unknown, pass it as true. */ + true, /* MODIFIED is unknown, pass it as true. */ false, /* No memory tags in the object file. */ obfd); if (ret != 0) @@ -562,10 +562,10 @@ objfile_find_memory_regions (struct target_ops *self, /* Make a stack segment. */ if (derive_stack_segment (&temp_bottom, &temp_top)) (*func) (temp_bottom, temp_top - temp_bottom, - 1, /* Stack section will be readable. */ - 1, /* Stack section will be writable. */ - 0, /* Stack section will not be executable. */ - 1, /* Stack section will be modified. */ + true, /* Stack section will be readable. */ + true, /* Stack section will be writable. */ + false, /* Stack section will not be executable. */ + true, /* Stack section will be modified. */ false, /* No memory tags in the object file. */ obfd); @@ -573,10 +573,10 @@ objfile_find_memory_regions (struct target_ops *self, if (derive_heap_segment (current_program_space->exec_bfd (), &temp_bottom, &temp_top)) (*func) (temp_bottom, temp_top - temp_bottom, - 1, /* Heap section will be readable. */ - 1, /* Heap section will be writable. */ - 0, /* Heap section will not be executable. */ - 1, /* Heap section will be modified. */ + true, /* Heap section will be readable. */ + true, /* Heap section will be writable. */ + false, /* Heap section will not be executable. */ + true, /* Heap section will be modified. */ false, /* No memory tags in the object file. */ obfd); @@ -850,9 +850,9 @@ gcore_find_signalled_thread () && curr_thr->stop_signal () != GDB_SIGNAL_0) return curr_thr; - for (thread_info *thr : current_inferior ()->non_exited_threads ()) - if (thr->stop_signal () != GDB_SIGNAL_0) - return thr; + for (thread_info &thr : current_inferior ()->non_exited_threads ()) + if (thr.stop_signal () != GDB_SIGNAL_0) + return &thr; /* Default to the current thread, unless it has exited. */ if (curr_thr->state != THREAD_EXITED) @@ -861,9 +861,7 @@ gcore_find_signalled_thread () return nullptr; } -void _initialize_gcore (); -void -_initialize_gcore () +INIT_GDB_FILE (gcore) { cmd_list_element *generate_core_file_cmd = add_com ("generate-core-file", class_files, gcore_command, _("\ |