* [PATCH 2/3] Fix a couple of comments
2019-04-09 18:11 [PATCH 0/3] some minor objfile iteration improvements Tom Tromey
@ 2019-04-09 18:09 ` Tom Tromey
2019-04-10 1:51 ` Simon Marchi
2019-04-09 18:09 ` [PATCH 3/3] Introduce a separate debug objfile iterator Tom Tromey
2019-04-09 18:09 ` [PATCH 1/3] Remove some uses of "object_files" Tom Tromey
2 siblings, 1 reply; 19+ messages in thread
From: Tom Tromey @ 2019-04-09 18:09 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
While working on objfiles I noticed a typo in one comment, and another
comment that, as far as I can tell, has been obsolete for a very long
time.
gdb/ChangeLog
2019-04-09 Tom Tromey <tom@tromey.com>
* symfile.c (reread_symbols): Remove old comment.
* objfiles.c (free_all_objfiles): Fix a typo.
---
gdb/ChangeLog | 5 +++++
gdb/objfiles.c | 2 +-
gdb/symfile.c | 6 ------
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 1c95e068842..ada5edc42fa 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -699,7 +699,7 @@ free_all_objfiles (void)
{
struct so_list *so;
- /* Any objfile referencewould become stale. */
+ /* Any objfile reference would become stale. */
for (so = master_so_list (); so; so = so->next)
gdb_assert (so->objfile == NULL);
diff --git a/gdb/symfile.c b/gdb/symfile.c
index ba82f1b83ca..dd9c4ae9856 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2432,12 +2432,6 @@ reread_symbols (void)
int res;
std::vector<struct objfile *> new_objfiles;
- /* With the addition of shared libraries, this should be modified,
- the load time should be saved in the partial symbol tables, since
- different tables may come from different source files. FIXME.
- This routine should then walk down each partial symbol table
- and see if the symbol table that it originates from has been changed. */
-
for (objfile *objfile : current_program_space->objfiles ())
{
if (objfile->obfd == NULL)
--
2.17.2
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 1/3] Remove some uses of "object_files"
2019-04-09 18:11 [PATCH 0/3] some minor objfile iteration improvements Tom Tromey
2019-04-09 18:09 ` [PATCH 2/3] Fix a couple of comments Tom Tromey
2019-04-09 18:09 ` [PATCH 3/3] Introduce a separate debug objfile iterator Tom Tromey
@ 2019-04-09 18:09 ` Tom Tromey
2019-04-10 1:49 ` Simon Marchi
2 siblings, 1 reply; 19+ messages in thread
From: Tom Tromey @ 2019-04-09 18:09 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
The "object_files" macro is sometimes used when iterating over
objfiles. This patch removes a few such uses in favor of the new
range adapter.
gdb/ChangeLog
2019-04-09 Tom Tromey <tom@tromey.com>
* ia64-tdep.c (ia64_get_dyn_info_list): Use foreach.
* minsyms.c (lookup_minimal_symbol): Use foreach.
(lookup_minimal_symbol_text, lookup_minimal_symbol_by_pc_name)
(lookup_minimal_symbol_solib_trampoline): Likewise.
* symfile.c (reread_symbols): Use foreach.
---
gdb/ChangeLog | 8 ++++++++
gdb/ia64-tdep.c | 3 +--
gdb/minsyms.c | 26 ++++++++++----------------
gdb/symfile.c | 3 +--
4 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index 7b4d0a0bfa1..f46673986ba 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -2845,7 +2845,6 @@ ia64_get_dyn_info_list (unw_addr_space_t as,
unw_word_t *dilap, void *arg)
{
struct obj_section *text_sec;
- struct objfile *objfile;
unw_word_t ip, addr;
unw_dyn_info_t di;
int ret;
@@ -2853,7 +2852,7 @@ ia64_get_dyn_info_list (unw_addr_space_t as,
if (!libunwind_is_initialized ())
return -UNW_ENOINFO;
- for (objfile = object_files; objfile; objfile = objfile->next)
+ for (objfile *objfile : current_program_space->objfiles ())
{
void *buf = NULL;
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 51b65f51421..34198d122dc 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -308,7 +308,6 @@ struct bound_minimal_symbol
lookup_minimal_symbol (const char *name, const char *sfile,
struct objfile *objf)
{
- struct objfile *objfile;
found_minimal_symbols found;
unsigned int mangled_hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
@@ -323,10 +322,11 @@ lookup_minimal_symbol (const char *name, const char *sfile,
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
- for (objfile = object_files;
- objfile != NULL && found.external_symbol.minsym == NULL;
- objfile = objfile->next)
+ for (objfile *objfile : current_program_space->objfiles ())
{
+ if (found.external_symbol.minsym != NULL)
+ break;
+
if (objf == NULL || objf == objfile
|| objf == objfile->separate_debug_objfile_backlink)
{
@@ -522,17 +522,17 @@ iterate_over_minimal_symbols
struct bound_minimal_symbol
lookup_minimal_symbol_text (const char *name, struct objfile *objf)
{
- struct objfile *objfile;
struct minimal_symbol *msymbol;
struct bound_minimal_symbol found_symbol = { NULL, NULL };
struct bound_minimal_symbol found_file_symbol = { NULL, NULL };
unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
- for (objfile = object_files;
- objfile != NULL && found_symbol.minsym == NULL;
- objfile = objfile->next)
+ for (objfile *objfile : current_program_space->objfiles ())
{
+ if (found_symbol.minsym != NULL)
+ break;
+
if (objf == NULL || objf == objfile
|| objf == objfile->separate_debug_objfile_backlink)
{
@@ -574,14 +574,11 @@ struct minimal_symbol *
lookup_minimal_symbol_by_pc_name (CORE_ADDR pc, const char *name,
struct objfile *objf)
{
- struct objfile *objfile;
struct minimal_symbol *msymbol;
unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
- for (objfile = object_files;
- objfile != NULL;
- objfile = objfile->next)
+ for (objfile *objfile : current_program_space->objfiles ())
{
if (objf == NULL || objf == objfile
|| objf == objfile->separate_debug_objfile_backlink)
@@ -606,15 +603,12 @@ struct bound_minimal_symbol
lookup_minimal_symbol_solib_trampoline (const char *name,
struct objfile *objf)
{
- struct objfile *objfile;
struct minimal_symbol *msymbol;
struct bound_minimal_symbol found_symbol = { NULL, NULL };
unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
- for (objfile = object_files;
- objfile != NULL;
- objfile = objfile->next)
+ for (objfile *objfile : current_program_space->objfiles ())
{
if (objf == NULL || objf == objfile
|| objf == objfile->separate_debug_objfile_backlink)
diff --git a/gdb/symfile.c b/gdb/symfile.c
index dbfc306c521..ba82f1b83ca 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2427,7 +2427,6 @@ remove_symbol_file_command (const char *args, int from_tty)
void
reread_symbols (void)
{
- struct objfile *objfile;
long new_modtime;
struct stat new_statbuf;
int res;
@@ -2439,7 +2438,7 @@ reread_symbols (void)
This routine should then walk down each partial symbol table
and see if the symbol table that it originates from has been changed. */
- for (objfile = object_files; objfile; objfile = objfile->next)
+ for (objfile *objfile : current_program_space->objfiles ())
{
if (objfile->obfd == NULL)
continue;
--
2.17.2
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 3/3] Introduce a separate debug objfile iterator
2019-04-09 18:11 [PATCH 0/3] some minor objfile iteration improvements Tom Tromey
2019-04-09 18:09 ` [PATCH 2/3] Fix a couple of comments Tom Tromey
@ 2019-04-09 18:09 ` Tom Tromey
2019-04-10 2:01 ` Simon Marchi
2019-04-30 15:44 ` Sandra Loosemore
2019-04-09 18:09 ` [PATCH 1/3] Remove some uses of "object_files" Tom Tromey
2 siblings, 2 replies; 19+ messages in thread
From: Tom Tromey @ 2019-04-09 18:09 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This introduces a new iterator and range adapter for iteration over
the separate debug files of a given objfile. As in the current
approach, the requested objfile is returned first, followed by the
separate debug objfiles.
gdb/ChangeLog
2019-04-09 Tom Tromey <tom@tromey.com>
* symtab.c (lookup_global_symbol_from_objfile)
(lookup_symbol_in_objfile_from_linkage_name): Use the iterator.
* objfiles.h (class separate_debug_iterator): New.
(class separate_debug_range): New.
(struct objfile) <separate_debug_objfiles>: New method.
(objfile_separate_debug_iterate): Don't declare.
* objfiles.c (separate_debug_iterator::operator++): Rename from
objfile_separate_debug_iterate.
(objfile_relocate, objfile_rebase, objfile_has_symbols): Use the
iterator.
* minsyms.c (lookup_minimal_symbol_by_pc_section): Use the
iterator.
---
gdb/ChangeLog | 15 +++++++++++
gdb/minsyms.c | 5 +---
gdb/objfiles.c | 67 ++++++++++++++++++++++++-------------------------
gdb/objfiles.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++---
gdb/symtab.c | 12 +++------
5 files changed, 117 insertions(+), 50 deletions(-)
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 34198d122dc..8037329a862 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -696,7 +696,6 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
int lo;
int hi;
int newobj;
- struct objfile *objfile;
struct minimal_symbol *msymbol;
struct minimal_symbol *best_symbol = NULL;
struct objfile *best_objfile = NULL;
@@ -722,9 +721,7 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
gdb_assert (section != NULL);
- for (objfile = section->objfile;
- objfile != NULL;
- objfile = objfile_separate_debug_iterate (section->objfile, objfile))
+ for (struct objfile *objfile : section->objfile->separate_debug_objfiles ())
{
CORE_ADDR pc = pc_in;
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index ada5edc42fa..71518ea5b24 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -446,44 +446,50 @@ entry_point_address (void)
return retval;
}
-/* Iterator on PARENT and every separate debug objfile of PARENT.
- The usage pattern is:
- for (objfile = parent;
- objfile;
- objfile = objfile_separate_debug_iterate (parent, objfile))
- ...
-*/
-
-struct objfile *
-objfile_separate_debug_iterate (const struct objfile *parent,
- const struct objfile *objfile)
+separate_debug_iterator &
+separate_debug_iterator::operator++ ()
{
+ gdb_assert (m_objfile != nullptr);
+
struct objfile *res;
/* If any, return the first child. */
- res = objfile->separate_debug_objfile;
+ res = m_objfile->separate_debug_objfile;
if (res)
- return res;
+ {
+ m_objfile = res;
+ return *this;
+ }
/* Common case where there is no separate debug objfile. */
- if (objfile == parent)
- return NULL;
+ if (m_objfile == m_parent)
+ {
+ m_objfile = nullptr;
+ return *this;
+ }
/* Return the brother if any. Note that we don't iterate on brothers of
the parents. */
- res = objfile->separate_debug_objfile_link;
+ res = m_objfile->separate_debug_objfile_link;
if (res)
- return res;
+ {
+ m_objfile = res;
+ return *this;
+ }
- for (res = objfile->separate_debug_objfile_backlink;
- res != parent;
+ for (res = m_objfile->separate_debug_objfile_backlink;
+ res != m_parent;
res = res->separate_debug_objfile_backlink)
{
gdb_assert (res != NULL);
if (res->separate_debug_objfile_link)
- return res->separate_debug_objfile_link;
+ {
+ m_objfile = res->separate_debug_objfile_link;
+ return *this;
+ }
}
- return NULL;
+ m_objfile = nullptr;
+ return *this;
}
/* Put one object file before a specified on in the global list.
@@ -860,15 +866,15 @@ void
objfile_relocate (struct objfile *objfile,
const struct section_offsets *new_offsets)
{
- struct objfile *debug_objfile;
int changed = 0;
changed |= objfile_relocate1 (objfile, new_offsets);
- for (debug_objfile = objfile->separate_debug_objfile;
- debug_objfile;
- debug_objfile = objfile_separate_debug_iterate (objfile, debug_objfile))
+ for (struct objfile *debug_objfile : objfile->separate_debug_objfiles ())
{
+ if (debug_objfile == objfile)
+ continue;
+
section_addr_info objfile_addrs
= build_section_addr_info_from_objfile (objfile);
@@ -917,14 +923,9 @@ objfile_rebase1 (struct objfile *objfile, CORE_ADDR slide)
void
objfile_rebase (struct objfile *objfile, CORE_ADDR slide)
{
- struct objfile *debug_objfile;
int changed = 0;
- changed |= objfile_rebase1 (objfile, slide);
-
- for (debug_objfile = objfile->separate_debug_objfile;
- debug_objfile;
- debug_objfile = objfile_separate_debug_iterate (objfile, debug_objfile))
+ for (struct objfile *debug_objfile : objfile->separate_debug_objfiles ())
changed |= objfile_rebase1 (debug_objfile, slide);
/* Relocate breakpoints as necessary, after things are relocated. */
@@ -965,9 +966,7 @@ objfile_has_full_symbols (struct objfile *objfile)
int
objfile_has_symbols (struct objfile *objfile)
{
- struct objfile *o;
-
- for (o = objfile; o; o = objfile_separate_debug_iterate (objfile, o))
+ for (struct objfile *o : objfile->separate_debug_objfiles ())
if (objfile_has_partial_symbols (o) || objfile_has_full_symbols (o))
return 1;
return 0;
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 368d9f3abe2..168f7fc275b 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -318,6 +318,63 @@ struct objfile_per_bfd_storage
std::bitset<nr_languages> demangled_hash_languages;
};
+/* An iterator that first returns a parent objfile, and then each
+ separate debug objfile. */
+
+class separate_debug_iterator
+{
+public:
+
+ explicit separate_debug_iterator (struct objfile *objfile)
+ : m_objfile (objfile),
+ m_parent (objfile)
+ {
+ }
+
+ bool operator!= (const separate_debug_iterator &other)
+ {
+ return m_objfile != other.m_objfile;
+ }
+
+ separate_debug_iterator &operator++ ();
+
+ struct objfile *operator* ()
+ {
+ return m_objfile;
+ }
+
+private:
+
+ struct objfile *m_objfile;
+ struct objfile *m_parent;
+};
+
+/* A range adapter wrapping separate_debug_iterator. */
+
+class separate_debug_range
+{
+public:
+
+ explicit separate_debug_range (struct objfile *objfile)
+ : m_objfile (objfile)
+ {
+ }
+
+ separate_debug_iterator begin ()
+ {
+ return separate_debug_iterator (m_objfile);
+ }
+
+ separate_debug_iterator end ()
+ {
+ return separate_debug_iterator (nullptr);
+ }
+
+private:
+
+ struct objfile *m_objfile;
+};
+
/* Master structure for keeping track of each file from which
gdb reads symbols. There are several ways these get allocated: 1.
The main symbol file, symfile_objfile, set by the symbol-file command,
@@ -396,6 +453,14 @@ struct objfile
return msymbols_range (this);
}
+ /* Return a range adapter for iterating over all the separate debug
+ objfiles of this objfile. */
+
+ separate_debug_range separate_debug_objfiles ()
+ {
+ return separate_debug_range (this);
+ }
+
/* All struct objfile's are chained together by their next pointers.
The program space field "objfiles" (frequently referenced via
@@ -563,9 +628,6 @@ extern CORE_ADDR entry_point_address (void);
extern void build_objfile_section_table (struct objfile *);
-extern struct objfile *objfile_separate_debug_iterate (const struct objfile *,
- const struct objfile *);
-
extern void put_objfile_before (struct objfile *, struct objfile *);
extern void add_separate_debug_objfile (struct objfile *, struct objfile *);
diff --git a/gdb/symtab.c b/gdb/symtab.c
index d25f560f084..16e641a830b 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2246,11 +2246,7 @@ lookup_global_symbol_from_objfile (struct objfile *main_objfile,
const char *name,
const domain_enum domain)
{
- struct objfile *objfile;
-
- for (objfile = main_objfile;
- objfile;
- objfile = objfile_separate_debug_iterate (main_objfile, objfile))
+ for (struct objfile *objfile : main_objfile->separate_debug_objfiles ())
{
struct block_symbol result
= lookup_symbol_in_objfile (objfile, GLOBAL_BLOCK, name, domain);
@@ -2327,7 +2323,7 @@ lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile,
domain_enum domain)
{
enum language lang = current_language->la_language;
- struct objfile *main_objfile, *cur_objfile;
+ struct objfile *main_objfile;
demangle_result_storage storage;
const char *modified_name = demangle_for_lookup (linkage_name, lang, storage);
@@ -2337,9 +2333,7 @@ lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile,
else
main_objfile = objfile;
- for (cur_objfile = main_objfile;
- cur_objfile;
- cur_objfile = objfile_separate_debug_iterate (main_objfile, cur_objfile))
+ for (struct objfile *cur_objfile : main_objfile->separate_debug_objfiles ())
{
struct block_symbol result;
--
2.17.2
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 0/3] some minor objfile iteration improvements
@ 2019-04-09 18:11 Tom Tromey
2019-04-09 18:09 ` [PATCH 2/3] Fix a couple of comments Tom Tromey
` (2 more replies)
0 siblings, 3 replies; 19+ messages in thread
From: Tom Tromey @ 2019-04-09 18:11 UTC (permalink / raw)
To: gdb-patches
This series comes from some experiments I've been doing with objfile
reuse.
These particular patches just change gdb to use foreach in a few more
spots, introducing a new separate-debug-objfile iterator in the
process. Patch #2 is trivial, just fixing some obsolete comments I
noticed while working in this area.
Regression tested by the buildbot.
Tom
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/3] Remove some uses of "object_files"
2019-04-09 18:09 ` [PATCH 1/3] Remove some uses of "object_files" Tom Tromey
@ 2019-04-10 1:49 ` Simon Marchi
2019-04-10 2:26 ` Tom Tromey
0 siblings, 1 reply; 19+ messages in thread
From: Simon Marchi @ 2019-04-10 1:49 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 2019-04-09 2:09 p.m., Tom Tromey wrote:
> The "object_files" macro is sometimes used when iterating over
> objfiles. This patch removes a few such uses in favor of the new
> range adapter.
>
> gdb/ChangeLog
> 2019-04-09 Tom Tromey <tom@tromey.com>
>
> * ia64-tdep.c (ia64_get_dyn_info_list): Use foreach.
> * minsyms.c (lookup_minimal_symbol): Use foreach.
> (lookup_minimal_symbol_text, lookup_minimal_symbol_by_pc_name)
> (lookup_minimal_symbol_solib_trampoline): Likewise.
> * symfile.c (reread_symbols): Use foreach.
LGTM. I would even suggest replacing the remaining few instances of object_files
with current_program_space->objfiles_head and removing the macro completely.
Simon
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/3] Fix a couple of comments
2019-04-09 18:09 ` [PATCH 2/3] Fix a couple of comments Tom Tromey
@ 2019-04-10 1:51 ` Simon Marchi
0 siblings, 0 replies; 19+ messages in thread
From: Simon Marchi @ 2019-04-10 1:51 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 2019-04-09 2:09 p.m., Tom Tromey wrote:
> While working on objfiles I noticed a typo in one comment, and another
> comment that, as far as I can tell, has been obsolete for a very long
> time.
I don't really understand the comment. Is it obsolete because what the
comment suggests has been implemented, or it's just not relevant anymore?
Simon
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/3] Introduce a separate debug objfile iterator
2019-04-09 18:09 ` [PATCH 3/3] Introduce a separate debug objfile iterator Tom Tromey
@ 2019-04-10 2:01 ` Simon Marchi
2019-04-10 14:08 ` Tom Tromey
2019-04-30 15:44 ` Sandra Loosemore
1 sibling, 1 reply; 19+ messages in thread
From: Simon Marchi @ 2019-04-10 2:01 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 2019-04-09 2:09 p.m., Tom Tromey wrote:
> This introduces a new iterator and range adapter for iteration over
> the separate debug files of a given objfile. As in the current
> approach, the requested objfile is returned first, followed by the
> separate debug objfiles.
>
> gdb/ChangeLog
> 2019-04-09 Tom Tromey <tom@tromey.com>
>
> * symtab.c (lookup_global_symbol_from_objfile)
> (lookup_symbol_in_objfile_from_linkage_name): Use the iterator.
> * objfiles.h (class separate_debug_iterator): New.
> (class separate_debug_range): New.
> (struct objfile) <separate_debug_objfiles>: New method.
> (objfile_separate_debug_iterate): Don't declare.
> * objfiles.c (separate_debug_iterator::operator++): Rename from
> objfile_separate_debug_iterate.
> (objfile_relocate, objfile_rebase, objfile_has_symbols): Use the
> iterator.
> * minsyms.c (lookup_minimal_symbol_by_pc_section): Use the
> iterator.
> ---
> gdb/ChangeLog | 15 +++++++++++
> gdb/minsyms.c | 5 +---
> gdb/objfiles.c | 67 ++++++++++++++++++++++++-------------------------
> gdb/objfiles.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++---
> gdb/symtab.c | 12 +++------
> 5 files changed, 117 insertions(+), 50 deletions(-)
>
> diff --git a/gdb/minsyms.c b/gdb/minsyms.c
> index 34198d122dc..8037329a862 100644
> --- a/gdb/minsyms.c
> +++ b/gdb/minsyms.c
> @@ -696,7 +696,6 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
> int lo;
> int hi;
> int newobj;
> - struct objfile *objfile;
> struct minimal_symbol *msymbol;
> struct minimal_symbol *best_symbol = NULL;
> struct objfile *best_objfile = NULL;
> @@ -722,9 +721,7 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
>
> gdb_assert (section != NULL);
>
> - for (objfile = section->objfile;
> - objfile != NULL;
> - objfile = objfile_separate_debug_iterate (section->objfile, objfile))
> + for (struct objfile *objfile : section->objfile->separate_debug_objfiles ())
> {
> CORE_ADDR pc = pc_in;
>
> diff --git a/gdb/objfiles.c b/gdb/objfiles.c
> index ada5edc42fa..71518ea5b24 100644
> --- a/gdb/objfiles.c
> +++ b/gdb/objfiles.c
> @@ -446,44 +446,50 @@ entry_point_address (void)
> return retval;
> }
>
> -/* Iterator on PARENT and every separate debug objfile of PARENT.
> - The usage pattern is:
> - for (objfile = parent;
> - objfile;
> - objfile = objfile_separate_debug_iterate (parent, objfile))
> - ...
> -*/
> -
> -struct objfile *
> -objfile_separate_debug_iterate (const struct objfile *parent,
> - const struct objfile *objfile)
> +separate_debug_iterator &
> +separate_debug_iterator::operator++ ()
> {
> + gdb_assert (m_objfile != nullptr);
> +
> struct objfile *res;
>
> /* If any, return the first child. */
> - res = objfile->separate_debug_objfile;
> + res = m_objfile->separate_debug_objfile;
> if (res)
> - return res;
> + {
> + m_objfile = res;
> + return *this;
> + }
>
> /* Common case where there is no separate debug objfile. */
> - if (objfile == parent)
> - return NULL;
> + if (m_objfile == m_parent)
> + {
> + m_objfile = nullptr;
> + return *this;
> + }
>
> /* Return the brother if any. Note that we don't iterate on brothers of
> the parents. */
> - res = objfile->separate_debug_objfile_link;
> + res = m_objfile->separate_debug_objfile_link;
> if (res)
> - return res;
> + {
> + m_objfile = res;
> + return *this;
> + }
>
> - for (res = objfile->separate_debug_objfile_backlink;
> - res != parent;
> + for (res = m_objfile->separate_debug_objfile_backlink;
> + res != m_parent;
> res = res->separate_debug_objfile_backlink)
> {
> gdb_assert (res != NULL);
> if (res->separate_debug_objfile_link)
> - return res->separate_debug_objfile_link;
> + {
> + m_objfile = res->separate_debug_objfile_link;
> + return *this;
> + }
> }
> - return NULL;
> + m_objfile = nullptr;
> + return *this;
> }
>
> /* Put one object file before a specified on in the global list.
> @@ -860,15 +866,15 @@ void
> objfile_relocate (struct objfile *objfile,
> const struct section_offsets *new_offsets)
> {
> - struct objfile *debug_objfile;
> int changed = 0;
>
> changed |= objfile_relocate1 (objfile, new_offsets);
>
> - for (debug_objfile = objfile->separate_debug_objfile;
> - debug_objfile;
> - debug_objfile = objfile_separate_debug_iterate (objfile, debug_objfile))
> + for (struct objfile *debug_objfile : objfile->separate_debug_objfiles ())
> {
> + if (debug_objfile == objfile)
> + continue;
> +
> section_addr_info objfile_addrs
> = build_section_addr_info_from_objfile (objfile);
>
> @@ -917,14 +923,9 @@ objfile_rebase1 (struct objfile *objfile, CORE_ADDR slide)
> void
> objfile_rebase (struct objfile *objfile, CORE_ADDR slide)
> {
> - struct objfile *debug_objfile;
> int changed = 0;
>
> - changed |= objfile_rebase1 (objfile, slide);
> -
> - for (debug_objfile = objfile->separate_debug_objfile;
> - debug_objfile;
> - debug_objfile = objfile_separate_debug_iterate (objfile, debug_objfile))
> + for (struct objfile *debug_objfile : objfile->separate_debug_objfiles ())
> changed |= objfile_rebase1 (debug_objfile, slide);
>
> /* Relocate breakpoints as necessary, after things are relocated. */
> @@ -965,9 +966,7 @@ objfile_has_full_symbols (struct objfile *objfile)
> int
> objfile_has_symbols (struct objfile *objfile)
> {
> - struct objfile *o;
> -
> - for (o = objfile; o; o = objfile_separate_debug_iterate (objfile, o))
> + for (struct objfile *o : objfile->separate_debug_objfiles ())
> if (objfile_has_partial_symbols (o) || objfile_has_full_symbols (o))
> return 1;
> return 0;
> diff --git a/gdb/objfiles.h b/gdb/objfiles.h
> index 368d9f3abe2..168f7fc275b 100644
> --- a/gdb/objfiles.h
> +++ b/gdb/objfiles.h
> @@ -318,6 +318,63 @@ struct objfile_per_bfd_storage
> std::bitset<nr_languages> demangled_hash_languages;
> };
>
> +/* An iterator that first returns a parent objfile, and then each
> + separate debug objfile. */
> +
> +class separate_debug_iterator
> +{
> +public:
> +
> + explicit separate_debug_iterator (struct objfile *objfile)
> + : m_objfile (objfile),
> + m_parent (objfile)
> + {
> + }
> +
> + bool operator!= (const separate_debug_iterator &other)
> + {
> + return m_objfile != other.m_objfile;
> + }
> +
> + separate_debug_iterator &operator++ ();
> +
> + struct objfile *operator* ()
> + {
> + return m_objfile;
> + }
> +
> +private:
> +
> + struct objfile *m_objfile;
> + struct objfile *m_parent;
> +};
> +
> +/* A range adapter wrapping separate_debug_iterator. */
> +
> +class separate_debug_range
> +{
> +public:
> +
> + explicit separate_debug_range (struct objfile *objfile)
> + : m_objfile (objfile)
> + {
> + }
> +
> + separate_debug_iterator begin ()
> + {
> + return separate_debug_iterator (m_objfile);
> + }
> +
> + separate_debug_iterator end ()
> + {
> + return separate_debug_iterator (nullptr);
> + }
> +
> +private:
> +
> + struct objfile *m_objfile;
> +};
> +
> /* Master structure for keeping track of each file from which
> gdb reads symbols. There are several ways these get allocated: 1.
> The main symbol file, symfile_objfile, set by the symbol-file command,
> @@ -396,6 +453,14 @@ struct objfile
> return msymbols_range (this);
> }
>
> + /* Return a range adapter for iterating over all the separate debug
> + objfiles of this objfile. */
> +
> + separate_debug_range separate_debug_objfiles ()
> + {
> + return separate_debug_range (this);
> + }
> +
>
> /* All struct objfile's are chained together by their next pointers.
> The program space field "objfiles" (frequently referenced via
> @@ -563,9 +628,6 @@ extern CORE_ADDR entry_point_address (void);
>
> extern void build_objfile_section_table (struct objfile *);
>
> -extern struct objfile *objfile_separate_debug_iterate (const struct objfile *,
> - const struct objfile *);
> -
> extern void put_objfile_before (struct objfile *, struct objfile *);
>
> extern void add_separate_debug_objfile (struct objfile *, struct objfile *);
> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index d25f560f084..16e641a830b 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -2246,11 +2246,7 @@ lookup_global_symbol_from_objfile (struct objfile *main_objfile,
> const char *name,
> const domain_enum domain)
> {
> - struct objfile *objfile;
> -
> - for (objfile = main_objfile;
> - objfile;
> - objfile = objfile_separate_debug_iterate (main_objfile, objfile))
> + for (struct objfile *objfile : main_objfile->separate_debug_objfiles ())
> {
> struct block_symbol result
> = lookup_symbol_in_objfile (objfile, GLOBAL_BLOCK, name, domain);
> @@ -2327,7 +2323,7 @@ lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile,
> domain_enum domain)
> {
> enum language lang = current_language->la_language;
> - struct objfile *main_objfile, *cur_objfile;
> + struct objfile *main_objfile;
>
> demangle_result_storage storage;
> const char *modified_name = demangle_for_lookup (linkage_name, lang, storage);
> @@ -2337,9 +2333,7 @@ lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile,
> else
> main_objfile = objfile;
>
> - for (cur_objfile = main_objfile;
> - cur_objfile;
> - cur_objfile = objfile_separate_debug_iterate (main_objfile, cur_objfile))
> + for (struct objfile *cur_objfile : main_objfile->separate_debug_objfiles ())
> {
> struct block_symbol result;
>
>
Thanks, this LGTM.
While touching this code, could you fixup the various?
- if (res)
+ if (res != NULL)
Simon
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/3] Remove some uses of "object_files"
2019-04-10 1:49 ` Simon Marchi
@ 2019-04-10 2:26 ` Tom Tromey
2019-04-10 2:50 ` Simon Marchi
0 siblings, 1 reply; 19+ messages in thread
From: Tom Tromey @ 2019-04-10 2:26 UTC (permalink / raw)
To: Simon Marchi; +Cc: Tom Tromey, gdb-patches
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
Simon> LGTM. I would even suggest replacing the remaining few instances
Simon> of object_files with current_program_space->objfiles_head and
Simon> removing the macro completely.
Yeah, I'll do it, though I think not as part of this patch. Some of the
remaining uses are in objfile destructor, and I was working toward
changing how objfiles are stored (using std::list rather than an
intrusive list) but I haven't finished those patches yet...
Tom
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/3] Remove some uses of "object_files"
2019-04-10 2:26 ` Tom Tromey
@ 2019-04-10 2:50 ` Simon Marchi
2019-04-10 14:08 ` Tom Tromey
0 siblings, 1 reply; 19+ messages in thread
From: Simon Marchi @ 2019-04-10 2:50 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 2019-04-09 10:25 p.m., Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
>
> Simon> LGTM. I would even suggest replacing the remaining few instances
> Simon> of object_files with current_program_space->objfiles_head and
> Simon> removing the macro completely.
>
> Yeah, I'll do it, though I think not as part of this patch. Some of the
> remaining uses are in objfile destructor, and I was working toward
> changing how objfiles are stored (using std::list rather than an
> intrusive list) but I haven't finished those patches yet...
Here is a patch that does it (goes on top of your patch), we can apply it if it
doesn't conflict too much with your other work.
From 5866bf2c26900ca78a06ec2bf3c758efc8cf4375 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@polymtl.ca>
Date: Tue, 9 Apr 2019 21:45:49 -0400
Subject: [PATCH] Remove object_files macro
This macro was provided as a compat layer when introducing multiprocess
support in GDB, to avoid having to update all usages. There are very
few of them left, so I suggest getting rid of it, replacing them with
the definition of the macro (current_program_space->objfiles_head). It
becomes more apparent that the caller code depends on the
current_program_space, which I think is good.
At the same time, I changed MULTI_OBJFILE_P to become a function instead
of a macro.
I noticed that object_files was also referenced in the list-objfiles
function defined in gdb.gdb. The function also accesses fields in
the objfile structure that no longer exist. I took the opportunity to
update them at the same time, since it's a small obvious change.
gdb/ChangeLog:
* progspace.h (object_files): Remove.
* objfiles.h (MULTI_OBJFILE_P): Change this macro...
(multi_objfile_p): ... to become this function.
* objfiles.c (objfile::objfile): Remove MULTI_OBJFILE_P usages.
* maint.c (maintenance_translate_address): Use multi_objfile_p
instead of MULTI_OBJFILE_P.
* printcmd.c (info_symbol_command): Likewise.
* gdb.gdb (list-objfiles): Don't use object_files, fix access to
objfile fields.
---
gdb/gdb.gdb | 4 ++--
gdb/maint.c | 2 +-
gdb/objfiles.c | 12 +++++++-----
gdb/objfiles.h | 14 ++++++++++----
gdb/printcmd.c | 2 +-
gdb/progspace.h | 4 ----
6 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/gdb/gdb.gdb b/gdb/gdb.gdb
index 437784102c1f..f107178c6353 100644
--- a/gdb/gdb.gdb
+++ b/gdb/gdb.gdb
@@ -2,11 +2,11 @@
# structures.
define list-objfiles
- set $obj = object_files
+ set $obj = current_program_space->objfiles_head
printf "objfile bfd msyms name\n"
while $obj != 0
printf "0x%-8x 0x%-8x %6d %s\n", $obj, $obj->obfd, \
- $obj->minimal_symbol_count, $obj->name
+ $obj->per_bfd->minimal_symbol_count, $obj->original_name
set var $obj = $obj->next
end
end
diff --git a/gdb/maint.c b/gdb/maint.c
index 8fc660eb9394..c907dc806d45 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -483,7 +483,7 @@ maintenance_translate_address (const char *arg, int from_tty)
gdb_assert (sect->objfile && objfile_name (sect->objfile));
obj_name = objfile_name (sect->objfile);
- if (MULTI_OBJFILE_P ())
+ if (multi_objfile_p ())
printf_filtered (_("%s + %s in section %s of %s\n"),
symbol_name, symbol_offset,
section_name, obj_name);
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 1c95e068842a..d90164433a07 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -393,13 +393,13 @@ objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_)
/* Add this file onto the tail of the linked list of other such files. */
- if (object_files == NULL)
- object_files = this;
+ if (current_program_space->objfiles_head == NULL)
+ current_program_space->objfiles_head = this;
else
{
struct objfile *last_one;
- for (last_one = object_files;
+ for (last_one = current_program_space->objfiles_head;
last_one->next;
last_one = last_one->next);
last_one->next = this;
@@ -496,7 +496,8 @@ put_objfile_before (struct objfile *objfile, struct objfile *before_this)
unlink_objfile (objfile);
- for (objp = &object_files; *objp != NULL; objp = &((*objp)->next))
+ for (objp = ¤t_program_space->objfiles_head; *objp != NULL;
+ objp = &((*objp)->next))
{
if (*objp == before_this)
{
@@ -528,7 +529,8 @@ unlink_objfile (struct objfile *objfile)
{
struct objfile **objpp;
- for (objpp = &object_files; *objpp != NULL; objpp = &((*objpp)->next))
+ for (objpp = ¤t_program_space->objfiles_head;
+ *objpp != NULL; objpp = &((*objpp)->next))
{
if (*objpp == objfile)
{
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 368d9f3abe25..8d26c039976b 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -398,8 +398,8 @@ struct objfile
/* All struct objfile's are chained together by their next pointers.
- The program space field "objfiles" (frequently referenced via
- the macro "object_files") points to the first link in this chain. */
+ The program space field "objfiles_head" points to the first link in this
+ chain. */
struct objfile *next = nullptr;
@@ -679,9 +679,15 @@ extern void default_iterate_over_objfiles_in_search_order
uninitialized section index. */
#define SECT_OFF_BSS(objfile) (objfile)->sect_index_bss
-/* Answer whether there is more than one object file loaded. */
+/* Answer whether there is more than one object file loaded in the current
+ program space. */
-#define MULTI_OBJFILE_P() (object_files && object_files->next)
+static inline
+bool multi_objfile_p ()
+{
+ return (current_program_space->objfiles_head != NULL
+ && current_program_space->objfiles_head->next != NULL);
+}
/* Reset the per-BFD storage area on OBJ. */
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 9e84594fe687..46f0c3400ef7 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1319,7 +1319,7 @@ info_symbol_command (const char *arg, int from_tty)
gdb_assert (osect->objfile && objfile_name (osect->objfile));
obj_name = objfile_name (osect->objfile);
- if (MULTI_OBJFILE_P ())
+ if (multi_objfile_p ())
if (pc_in_unmapped_range (addr, osect))
if (section_is_overlay (osect))
printf_filtered (_("%s in load address range of "
diff --git a/gdb/progspace.h b/gdb/progspace.h
index 039f55517305..e77e21fdda65 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -259,10 +259,6 @@ struct address_space
#define symfile_objfile current_program_space->symfile_object_file
-/* All known objfiles are kept in a linked list. This points to the
- root of this list. */
-#define object_files current_program_space->objfiles_head
-
/* The set of target sections matching the sections mapped into the
current program space. */
#define current_target_sections (¤t_program_space->target_sections)
--
2.21.0
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/3] Remove some uses of "object_files"
2019-04-10 2:50 ` Simon Marchi
@ 2019-04-10 14:08 ` Tom Tromey
0 siblings, 0 replies; 19+ messages in thread
From: Tom Tromey @ 2019-04-10 14:08 UTC (permalink / raw)
To: Simon Marchi; +Cc: Tom Tromey, gdb-patches
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
Simon> Here is a patch that does it (goes on top of your patch), we can apply it if it
Simon> doesn't conflict too much with your other work.
Thanks. This looks good to me.
Simon> At the same time, I changed MULTI_OBJFILE_P to become a function instead
Simon> of a macro.
FWIW in my patch to do this, I changed it into a method on the program
space.
Tom
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/3] Introduce a separate debug objfile iterator
2019-04-10 2:01 ` Simon Marchi
@ 2019-04-10 14:08 ` Tom Tromey
0 siblings, 0 replies; 19+ messages in thread
From: Tom Tromey @ 2019-04-10 14:08 UTC (permalink / raw)
To: Simon Marchi; +Cc: Tom Tromey, gdb-patches
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
Simon> While touching this code, could you fixup the various?
Simon> - if (res)
Simon> + if (res != NULL)
I did this.
Tom
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/3] Introduce a separate debug objfile iterator
2019-04-09 18:09 ` [PATCH 3/3] Introduce a separate debug objfile iterator Tom Tromey
2019-04-10 2:01 ` Simon Marchi
@ 2019-04-30 15:44 ` Sandra Loosemore
2019-04-30 15:51 ` Tom Tromey
1 sibling, 1 reply; 19+ messages in thread
From: Sandra Loosemore @ 2019-04-30 15:44 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 4/9/19 12:09 PM, Tom Tromey wrote:
> This introduces a new iterator and range adapter for iteration over
> the separate debug files of a given objfile. As in the current
> approach, the requested objfile is returned first, followed by the
> separate debug objfiles.
>
> gdb/ChangeLog
> 2019-04-09 Tom Tromey <tom@tromey.com>
>
> * symtab.c (lookup_global_symbol_from_objfile)
> (lookup_symbol_in_objfile_from_linkage_name): Use the iterator.
> * objfiles.h (class separate_debug_iterator): New.
> (class separate_debug_range): New.
> (struct objfile) <separate_debug_objfiles>: New method.
> (objfile_separate_debug_iterate): Don't declare.
> * objfiles.c (separate_debug_iterator::operator++): Rename from
> objfile_separate_debug_iterate.
> (objfile_relocate, objfile_rebase, objfile_has_symbols): Use the
> iterator.
> * minsyms.c (lookup_minimal_symbol_by_pc_section): Use the
> iterator.
FYI, this series of patches has broken builds with older versions of GCC
(we've got 5.2.1 installed on our build system here). Multiple failures
like:
/path/to/gdb/minsyms.c: In function 'bound_minimal_symbol
lookup_minimal_symbol_by_pc_section(CORE_ADDR, obj_section*,
lookup_msym_prefer)':
/path/to/gdb/minsyms.c:724:8: error: types may not be defined in a
for-range-declaration [-Werror]
for (struct objfile *objfile :
section->objfile->separate_debug_objfiles ())
^~~~~~
-Sandra
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/3] Introduce a separate debug objfile iterator
2019-04-30 15:44 ` Sandra Loosemore
@ 2019-04-30 15:51 ` Tom Tromey
2019-05-01 18:30 ` Tom Tromey
0 siblings, 1 reply; 19+ messages in thread
From: Tom Tromey @ 2019-04-30 15:51 UTC (permalink / raw)
To: Sandra Loosemore; +Cc: Tom Tromey, gdb-patches
>>>>> "Sandra" == Sandra Loosemore <sandra@codesourcery.com> writes:
Sandra> FYI, this series of patches has broken builds with older versions of
Sandra> GCC (we've got 5.2.1 installed on our build system here). Multiple
Sandra> failures like:
I think that's a bug in that version of gcc, but gdb has routinely
worked around it in the past.
Sandra> /path/to/gdb/minsyms.c: In function 'bound_minimal_symbol
Sandra> lookup_minimal_symbol_by_pc_section(CORE_ADDR, obj_section*,
Sandra> lookup_msym_prefer)':
Sandra> /path/to/gdb/minsyms.c:724:8: error: types may not be defined in a
Sandra> for-range-declaration [-Werror]
Sandra> for (struct objfile *objfile :
section-> objfile->separate_debug_objfiles ())
Sandra> ^~~~~~
If you can send me a full list, I can send you a patch to test.
thanks,
Tom
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/3] Introduce a separate debug objfile iterator
2019-04-30 15:51 ` Tom Tromey
@ 2019-05-01 18:30 ` Tom Tromey
2019-05-03 18:23 ` Sandra Loosemore
0 siblings, 1 reply; 19+ messages in thread
From: Tom Tromey @ 2019-05-01 18:30 UTC (permalink / raw)
To: Tom Tromey; +Cc: Sandra Loosemore, gdb-patches
Sandra> FYI, this series of patches has broken builds with older versions of
Sandra> GCC (we've got 5.2.1 installed on our build system here). Multiple
Sandra> failures like:
Tom> I think that's a bug in that version of gcc, but gdb has routinely
Tom> worked around it in the past.
[...]
Tom> If you can send me a full list, I can send you a patch to test.
I did a grep and came up with the appended.
If you try it, and it works, I will check it in.
thanks,
Tom
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 1a566635b2d..2b4445ee185 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12483,7 +12483,7 @@ create_excep_cond_exprs (struct ada_catchpoint *c,
because the expression may hold the addresses of multiple symbols
in some cases. */
std::multimap<program_space *, struct bp_location *> loc_map;
- for (struct bp_location *bl = c->loc; bl != NULL; bl = bl->next)
+ for (bp_location *bl = c->loc; bl != NULL; bl = bl->next)
loc_map.emplace (bl->pspace, bl);
scoped_restore_current_program_space save_pspace;
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 8282ef27e61..e3368ce6471 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1706,7 +1706,7 @@ darwin_attach_pid (struct inferior *inf)
static struct thread_info *
thread_info_from_private_thread_info (darwin_thread_info *pti)
{
- for (struct thread_info *it : all_threads ())
+ for (thread_info *it : all_threads ())
{
darwin_thread_info *iter_pti = get_darwin_thread_info (it);
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b0bdecf96fc..b5ea9e3cc0a 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -15962,7 +15962,7 @@ handle_struct_member_die (struct die_info *child_die, struct type *type,
field for our sole member child. */
struct attribute *discr = dwarf2_attr (child_die, DW_AT_discr_value, cu);
- for (struct die_info *variant_child = child_die->child;
+ for (die_info *variant_child = child_die->child;
variant_child != NULL;
variant_child = sibling_die (variant_child))
{
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 8037329a862..9d29d880aab 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -721,7 +721,7 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
gdb_assert (section != NULL);
- for (struct objfile *objfile : section->objfile->separate_debug_objfiles ())
+ for (objfile *objfile : section->objfile->separate_debug_objfiles ())
{
CORE_ADDR pc = pc_in;
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 1b0ea29980d..30823c2d889 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -864,7 +864,7 @@ objfile_relocate (struct objfile *objfile,
changed |= objfile_relocate1 (objfile, new_offsets);
- for (struct objfile *debug_objfile : objfile->separate_debug_objfiles ())
+ for (::objfile *debug_objfile : objfile->separate_debug_objfiles ())
{
if (debug_objfile == objfile)
continue;
@@ -919,7 +919,7 @@ objfile_rebase (struct objfile *objfile, CORE_ADDR slide)
{
int changed = 0;
- for (struct objfile *debug_objfile : objfile->separate_debug_objfiles ())
+ for (::objfile *debug_objfile : objfile->separate_debug_objfiles ())
changed |= objfile_rebase1 (debug_objfile, slide);
/* Relocate breakpoints as necessary, after things are relocated. */
@@ -960,7 +960,7 @@ objfile_has_full_symbols (struct objfile *objfile)
int
objfile_has_symbols (struct objfile *objfile)
{
- for (struct objfile *o : objfile->separate_debug_objfiles ())
+ for (::objfile *o : objfile->separate_debug_objfiles ())
if (objfile_has_partial_symbols (o) || objfile_has_full_symbols (o))
return 1;
return 0;
diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c
index 039b0432231..6ba95107918 100644
--- a/gdb/ser-tcp.c
+++ b/gdb/ser-tcp.c
@@ -323,7 +323,7 @@ net_open (struct serial *scb, const char *name)
{
got_connrefused = false;
- for (struct addrinfo *iter = ainfo; iter != NULL; iter = iter->ai_next)
+ for (addrinfo *iter = ainfo; iter != NULL; iter = iter->ai_next)
{
/* Iterate over the list of possible addresses to connect
to. For each, we'll try to connect and see if it
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 16e641a830b..0e1f7ead294 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2246,7 +2246,7 @@ lookup_global_symbol_from_objfile (struct objfile *main_objfile,
const char *name,
const domain_enum domain)
{
- for (struct objfile *objfile : main_objfile->separate_debug_objfiles ())
+ for (objfile *objfile : main_objfile->separate_debug_objfiles ())
{
struct block_symbol result
= lookup_symbol_in_objfile (objfile, GLOBAL_BLOCK, name, domain);
@@ -2333,7 +2333,7 @@ lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile,
else
main_objfile = objfile;
- for (struct objfile *cur_objfile : main_objfile->separate_debug_objfiles ())
+ for (::objfile *cur_objfile : main_objfile->separate_debug_objfiles ())
{
struct block_symbol result;
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/3] Introduce a separate debug objfile iterator
2019-05-01 18:30 ` Tom Tromey
@ 2019-05-03 18:23 ` Sandra Loosemore
2019-05-03 23:28 ` Tom Tromey
0 siblings, 1 reply; 19+ messages in thread
From: Sandra Loosemore @ 2019-05-03 18:23 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 683 bytes --]
On 5/1/19 12:10 PM, Tom Tromey wrote:
> Sandra> FYI, this series of patches has broken builds with older versions of
> Sandra> GCC (we've got 5.2.1 installed on our build system here). Multiple
> Sandra> failures like:
>
> Tom> I think that's a bug in that version of gcc, but gdb has routinely
> Tom> worked around it in the past.
>
> [...]
>
> Tom> If you can send me a full list, I can send you a patch to test.
>
> I did a grep and came up with the appended.
> If you try it, and it works, I will check it in.
I found one more use in ada-lang.c that you'd missed. Things build with
the attached version of the patch, but I haven't done any testing beyond
that.
-Sandra
[-- Attachment #2: objfile.patch --]
[-- Type: text/x-patch, Size: 4945 bytes --]
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 1a56663..20fb349 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12483,7 +12483,7 @@ create_excep_cond_exprs (struct ada_catchpoint *c,
because the expression may hold the addresses of multiple symbols
in some cases. */
std::multimap<program_space *, struct bp_location *> loc_map;
- for (struct bp_location *bl = c->loc; bl != NULL; bl = bl->next)
+ for (bp_location *bl = c->loc; bl != NULL; bl = bl->next)
loc_map.emplace (bl->pspace, bl);
scoped_restore_current_program_space save_pspace;
@@ -13231,7 +13231,7 @@ ada_exception_catchpoint_cond_string (const char *excep_string,
excep_string = ada_encode (excep_string);
std::vector<struct bound_minimal_symbol> symbols
= ada_lookup_simple_minsyms (excep_string);
- for (const struct bound_minimal_symbol &msym : symbols)
+ for (const bound_minimal_symbol &msym : symbols)
{
if (!result.empty ())
result += " or ";
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 8282ef2..e3368ce 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1706,7 +1706,7 @@ darwin_attach_pid (struct inferior *inf)
static struct thread_info *
thread_info_from_private_thread_info (darwin_thread_info *pti)
{
- for (struct thread_info *it : all_threads ())
+ for (thread_info *it : all_threads ())
{
darwin_thread_info *iter_pti = get_darwin_thread_info (it);
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b0bdecf..b5ea9e3 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -15962,7 +15962,7 @@ handle_struct_member_die (struct die_info *child_die, struct type *type,
field for our sole member child. */
struct attribute *discr = dwarf2_attr (child_die, DW_AT_discr_value, cu);
- for (struct die_info *variant_child = child_die->child;
+ for (die_info *variant_child = child_die->child;
variant_child != NULL;
variant_child = sibling_die (variant_child))
{
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 8037329..9d29d88 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -721,7 +721,7 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
gdb_assert (section != NULL);
- for (struct objfile *objfile : section->objfile->separate_debug_objfiles ())
+ for (objfile *objfile : section->objfile->separate_debug_objfiles ())
{
CORE_ADDR pc = pc_in;
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 1b0ea29..30823c2 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -864,7 +864,7 @@ objfile_relocate (struct objfile *objfile,
changed |= objfile_relocate1 (objfile, new_offsets);
- for (struct objfile *debug_objfile : objfile->separate_debug_objfiles ())
+ for (::objfile *debug_objfile : objfile->separate_debug_objfiles ())
{
if (debug_objfile == objfile)
continue;
@@ -919,7 +919,7 @@ objfile_rebase (struct objfile *objfile, CORE_ADDR slide)
{
int changed = 0;
- for (struct objfile *debug_objfile : objfile->separate_debug_objfiles ())
+ for (::objfile *debug_objfile : objfile->separate_debug_objfiles ())
changed |= objfile_rebase1 (debug_objfile, slide);
/* Relocate breakpoints as necessary, after things are relocated. */
@@ -960,7 +960,7 @@ objfile_has_full_symbols (struct objfile *objfile)
int
objfile_has_symbols (struct objfile *objfile)
{
- for (struct objfile *o : objfile->separate_debug_objfiles ())
+ for (::objfile *o : objfile->separate_debug_objfiles ())
if (objfile_has_partial_symbols (o) || objfile_has_full_symbols (o))
return 1;
return 0;
diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c
index 927a285..5aa7105 100644
--- a/gdb/ser-tcp.c
+++ b/gdb/ser-tcp.c
@@ -319,7 +319,7 @@ net_open (struct serial *scb, const char *name)
{
got_connrefused = false;
- for (struct addrinfo *iter = ainfo; iter != NULL; iter = iter->ai_next)
+ for (addrinfo *iter = ainfo; iter != NULL; iter = iter->ai_next)
{
/* Iterate over the list of possible addresses to connect
to. For each, we'll try to connect and see if it
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 16e641a..0e1f7ea 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2246,7 +2246,7 @@ lookup_global_symbol_from_objfile (struct objfile *main_objfile,
const char *name,
const domain_enum domain)
{
- for (struct objfile *objfile : main_objfile->separate_debug_objfiles ())
+ for (objfile *objfile : main_objfile->separate_debug_objfiles ())
{
struct block_symbol result
= lookup_symbol_in_objfile (objfile, GLOBAL_BLOCK, name, domain);
@@ -2333,7 +2333,7 @@ lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile,
else
main_objfile = objfile;
- for (struct objfile *cur_objfile : main_objfile->separate_debug_objfiles ())
+ for (::objfile *cur_objfile : main_objfile->separate_debug_objfiles ())
{
struct block_symbol result;
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/3] Introduce a separate debug objfile iterator
2019-05-03 18:23 ` Sandra Loosemore
@ 2019-05-03 23:28 ` Tom Tromey
2019-05-15 9:45 ` John Marshall
0 siblings, 1 reply; 19+ messages in thread
From: Tom Tromey @ 2019-05-03 23:28 UTC (permalink / raw)
To: Sandra Loosemore; +Cc: Tom Tromey, gdb-patches
>> I did a grep and came up with the appended.
>> If you try it, and it works, I will check it in.
Sandra> I found one more use in ada-lang.c that you'd missed. Things build
Sandra> with the attached version of the patch, but I haven't done any testing
Sandra> beyond that.
Thanks for doing that. Somehow there seems to have been one more in
dictionary.c as well. I've appended the patch I am going to push.
Tom
commit bba6afebd7fde978acb6e06a48084a694aab3b7a
Author: Tom Tromey <tom@tromey.com>
Date: Fri May 3 17:21:36 2019 -0600
Remove "struct" from foreach statements
Some versions of gcc have a bug that causes
for (struct mumble : something)
... to give a compiler error. We routinely work around this bug in
gdb, but apparently had not done so in a while. This patch fixes the
remaining known cases of this problem.
gdb/ChangeLog
2019-05-03 Sandra Loosemore <sandra@codesourcery.com>
Tom Tromey <tom@tromey.com>
* dictionary.c (collate_pending_symbols_by_language): Remove
"struct" from foreach.
* symtab.c (lookup_global_symbol_from_objfile)
(lookup_symbol_in_objfile_from_linkage_name): Remove "struct" from
foreach.
* ser-tcp.c (net_open): Remove "struct" from foreach.
* objfiles.c (objfile_relocate, objfile_rebase)
(objfile_has_symbols): Remove "struct" from foreach.
* minsyms.c (lookup_minimal_symbol_by_pc_section): Remove "struct"
from foreach.
* dwarf2read.c (handle_struct_member_die): Remove "struct" from
foreach.
* darwin-nat.c (thread_info_from_private_thread_info): Remove
"struct" from foreach.
* ada-lang.c (create_excep_cond_exprs)
(ada_exception_catchpoint_cond_string): Remove "struct" from
foreach.
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index eba0426463a..ed6d77a0bfb 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,24 @@
+2019-05-03 Sandra Loosemore <sandra@codesourcery.com>
+ Tom Tromey <tom@tromey.com>
+
+ * dictionary.c (collate_pending_symbols_by_language): Remove
+ "struct" from foreach.
+ * symtab.c (lookup_global_symbol_from_objfile)
+ (lookup_symbol_in_objfile_from_linkage_name): Remove "struct" from
+ foreach.
+ * ser-tcp.c (net_open): Remove "struct" from foreach.
+ * objfiles.c (objfile_relocate, objfile_rebase)
+ (objfile_has_symbols): Remove "struct" from foreach.
+ * minsyms.c (lookup_minimal_symbol_by_pc_section): Remove "struct"
+ from foreach.
+ * dwarf2read.c (handle_struct_member_die): Remove "struct" from
+ foreach.
+ * darwin-nat.c (thread_info_from_private_thread_info): Remove
+ "struct" from foreach.
+ * ada-lang.c (create_excep_cond_exprs)
+ (ada_exception_catchpoint_cond_string): Remove "struct" from
+ foreach.
+
2019-05-01 Tom Tromey <tromey@adacore.com>
* ada-lang.c (ada_value_primitive_field): Treat more fields as
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 1a566635b2d..20fb3497c03 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12483,7 +12483,7 @@ create_excep_cond_exprs (struct ada_catchpoint *c,
because the expression may hold the addresses of multiple symbols
in some cases. */
std::multimap<program_space *, struct bp_location *> loc_map;
- for (struct bp_location *bl = c->loc; bl != NULL; bl = bl->next)
+ for (bp_location *bl = c->loc; bl != NULL; bl = bl->next)
loc_map.emplace (bl->pspace, bl);
scoped_restore_current_program_space save_pspace;
@@ -13231,7 +13231,7 @@ ada_exception_catchpoint_cond_string (const char *excep_string,
excep_string = ada_encode (excep_string);
std::vector<struct bound_minimal_symbol> symbols
= ada_lookup_simple_minsyms (excep_string);
- for (const struct bound_minimal_symbol &msym : symbols)
+ for (const bound_minimal_symbol &msym : symbols)
{
if (!result.empty ())
result += " or ";
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 8282ef27e61..e3368ce6471 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1706,7 +1706,7 @@ darwin_attach_pid (struct inferior *inf)
static struct thread_info *
thread_info_from_private_thread_info (darwin_thread_info *pti)
{
- for (struct thread_info *it : all_threads ())
+ for (thread_info *it : all_threads ())
{
darwin_thread_info *iter_pti = get_darwin_thread_info (it);
diff --git a/gdb/dictionary.c b/gdb/dictionary.c
index 88eff2fa439..4e38b2e2340 100644
--- a/gdb/dictionary.c
+++ b/gdb/dictionary.c
@@ -932,7 +932,7 @@ collate_pending_symbols_by_language (const struct pending *symbol_list)
{
std::unordered_map<enum language, std::vector<symbol *>> nsyms;
- for (const struct pending *list_counter = symbol_list;
+ for (const pending *list_counter = symbol_list;
list_counter != nullptr; list_counter = list_counter->next)
{
for (int i = list_counter->nsyms - 1; i >= 0; --i)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b0bdecf96fc..b5ea9e3cc0a 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -15962,7 +15962,7 @@ handle_struct_member_die (struct die_info *child_die, struct type *type,
field for our sole member child. */
struct attribute *discr = dwarf2_attr (child_die, DW_AT_discr_value, cu);
- for (struct die_info *variant_child = child_die->child;
+ for (die_info *variant_child = child_die->child;
variant_child != NULL;
variant_child = sibling_die (variant_child))
{
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 8037329a862..9d29d880aab 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -721,7 +721,7 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
gdb_assert (section != NULL);
- for (struct objfile *objfile : section->objfile->separate_debug_objfiles ())
+ for (objfile *objfile : section->objfile->separate_debug_objfiles ())
{
CORE_ADDR pc = pc_in;
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 1b0ea29980d..30823c2d889 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -864,7 +864,7 @@ objfile_relocate (struct objfile *objfile,
changed |= objfile_relocate1 (objfile, new_offsets);
- for (struct objfile *debug_objfile : objfile->separate_debug_objfiles ())
+ for (::objfile *debug_objfile : objfile->separate_debug_objfiles ())
{
if (debug_objfile == objfile)
continue;
@@ -919,7 +919,7 @@ objfile_rebase (struct objfile *objfile, CORE_ADDR slide)
{
int changed = 0;
- for (struct objfile *debug_objfile : objfile->separate_debug_objfiles ())
+ for (::objfile *debug_objfile : objfile->separate_debug_objfiles ())
changed |= objfile_rebase1 (debug_objfile, slide);
/* Relocate breakpoints as necessary, after things are relocated. */
@@ -960,7 +960,7 @@ objfile_has_full_symbols (struct objfile *objfile)
int
objfile_has_symbols (struct objfile *objfile)
{
- for (struct objfile *o : objfile->separate_debug_objfiles ())
+ for (::objfile *o : objfile->separate_debug_objfiles ())
if (objfile_has_partial_symbols (o) || objfile_has_full_symbols (o))
return 1;
return 0;
diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c
index 039b0432231..6ba95107918 100644
--- a/gdb/ser-tcp.c
+++ b/gdb/ser-tcp.c
@@ -323,7 +323,7 @@ net_open (struct serial *scb, const char *name)
{
got_connrefused = false;
- for (struct addrinfo *iter = ainfo; iter != NULL; iter = iter->ai_next)
+ for (addrinfo *iter = ainfo; iter != NULL; iter = iter->ai_next)
{
/* Iterate over the list of possible addresses to connect
to. For each, we'll try to connect and see if it
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 16e641a830b..0e1f7ead294 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2246,7 +2246,7 @@ lookup_global_symbol_from_objfile (struct objfile *main_objfile,
const char *name,
const domain_enum domain)
{
- for (struct objfile *objfile : main_objfile->separate_debug_objfiles ())
+ for (objfile *objfile : main_objfile->separate_debug_objfiles ())
{
struct block_symbol result
= lookup_symbol_in_objfile (objfile, GLOBAL_BLOCK, name, domain);
@@ -2333,7 +2333,7 @@ lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile,
else
main_objfile = objfile;
- for (struct objfile *cur_objfile : main_objfile->separate_debug_objfiles ())
+ for (::objfile *cur_objfile : main_objfile->separate_debug_objfiles ())
{
struct block_symbol result;
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/3] Introduce a separate debug objfile iterator
2019-05-03 23:28 ` Tom Tromey
@ 2019-05-15 9:45 ` John Marshall
2019-05-15 15:45 ` Tom Tromey
0 siblings, 1 reply; 19+ messages in thread
From: John Marshall @ 2019-05-15 9:45 UTC (permalink / raw)
To: Tom Tromey; +Cc: Sandra Loosemore, gdb-patches
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 26965 bytes --]
On 3 May 2019, Tom Tromey <tom@tromey.com> wrote:
> commit bba6afebd7fde978acb6e06a48084a694aab3b7a
> Author: Tom Tromey <tom@tromey.com>
> Date: Fri May 3 17:21:36 2019 -0600
>
> Remove "struct" from foreach statements
> [snip]
> * darwin-nat.c (thread_info_from_private_thread_info): Remove
> "struct" from foreach.
This broke compilation on macOS (tested on Mojave) with both Clang and GCC (9.1.0):
CXX darwin-nat.o
../../../binutils-gdb/gdb/darwin-nat.c:1709:8: error: must use 'class' tag to refer to type 'thread_info' in this scope
for (thread_info *it : all_threads ())
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/mach/thread_act.h:240:15: note:
class 'thread_info' is hidden by a non-type declaration of 'thread_info' here
kern_return_t thread_info
Mach has a thread_info() function declared in that header, which darwin-nat.c #includes.
Cheers,
John
From gdb-patches-return-156115-listarch-gdb-patches=sources.redhat.com@sourceware.org Wed May 15 11:16:16 2019
Return-Path: <gdb-patches-return-156115-listarch-gdb-patches=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-patches@sources.redhat.com
Received: (qmail 79344 invoked by alias); 15 May 2019 11:16:16 -0000
Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-patches.sourceware.org>
List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-patches/>
List-Post: <mailto:gdb-patches@sourceware.org>
List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs>
Sender: gdb-patches-owner@sourceware.org
Delivered-To: mailing list gdb-patches@sourceware.org
Received: (qmail 79331 invoked by uid 89); 15 May 2019 11:16:15 -0000
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=1,1
X-HELO: mail-wr1-f42.google.com
Received: from mail-wr1-f42.google.com (HELO mail-wr1-f42.google.com) (209.85.221.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 May 2019 11:16:12 +0000
Received: by mail-wr1-f42.google.com with SMTP id c5so2182118wrs.11 for <gdb-patches@sourceware.org>; Wed, 15 May 2019 04:16:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id; bh=6KsXpw8NbQHqtXZwFNA7MJSewuVpxlkn28wZrSj+844=; b=CQBobbhw194qu18BqGu/Ih6t0F2uLHbQ4kXa1+9Kr5AZcOkm37iy5xDwYIg1f9geEs 4xqDXJnimHzMFZdg2kt3p5AEv9VQLJ3ZPy6yQIq/FMLGrvM5GF0c7SE3WMOp9tGwotOc xr82uou9OFPVBQ9TCs5E108rZ3h+QsOwRTtXuHJbQnedxACcm5at1Ij5wT5cD4ecLf2w RB4WuWgbvncbFCqjkhWzJwnvsTXVAgAuwE9m96nFhC2J/eU3VP6R+zv793fw5VuUyUaS sVXFAszwooeiBkrydMlufr9poHr53PRyYgG6olzu0kwrR3g9/tsjdPlsjPUqrCdXSoES iTGA=Return-Path: <andrew.burgess@embecosm.com>
Received: from localhost (host86-180-62-212.range86-180.btcentralplus.com. [86.180.62.212]) by smtp.gmail.com with ESMTPSA id w13sm6233515wmk.0.2019.05.15.04.16.08 (version=TLS1_2 cipherìDHE-RSA-CHACHA20-POLY1305 bits%6/256); Wed, 15 May 2019 04:16:08 -0700 (PDT)
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCH] gdb/fortran: Show the type for non allocated / associated types
Date: Wed, 15 May 2019 11:16:00 -0000
Message-Id: <20190515111606.6754-1-andrew.burgess@embecosm.com>
X-IsSubscribed: yes
X-SW-Source: 2019-05/txt/msg00347.txt.bz2
Content-length: 22590
This is an update of this patch:
https://sourceware.org/ml/gdb-patches/2018-11/msg00474.html
The only minor changes from the original patch are:
+ updating to use 'bool' instead of 'int' for a flag parameter,
+ updating expected testsuite results to take account of some other
changes I've made in GDB's Fortran support,
+ probably some other minor comments / layout changes throughout.
---
Show the type of not-allocated and/or not-associated types. For array
types and pointer to array types we are going to print the number of
ranks.
Consider this Fortran program:
program test
integer, allocatable :: vla (:)
logical l
allocate (vla(5:12))
l = allocated (vla)
end program test
And this GDB session with current HEAD:
(gdb) start
...
2 integer, allocatable :: vla (:)
(gdb) n
4 allocate (vla(5:12))
(gdb) ptype vla
type = <not allocated>
(gdb) p vla
$1 = <not allocated>
(gdb)
And the same session with this patch applied:
(gdb) start
...
2 integer, allocatable :: vla (:)
(gdb) n
4 allocate (vla(5:12))
(gdb) ptype vla
type = integer(kind=4), allocatable (:)
(gdb) p vla
$1 = <not allocated>
(gdb)
The type of 'vla' is now printed correctly, while the value itself
still shows as '<not allocated>'. How GDB prints the type of
associated pointers has changed in a similar way.
gdb/ChangeLog:
* f-typeprint.c (f_print_type): Don't return early for not
associated or not allocated types.
(f_type_print_varspec_suffix): Add print_rank parameter and print
ranks of array types in case they dangling.
(f_type_print_base): Add print_rank parameter.
gdb/testsuite/ChangeLog:
* gdb.fortran/pointers.f90: New file.
* gdb.fortran/print_type.exp: New file.
* gdb.fortran/vla-ptype.exp: Adapt expected results.
* gdb.fortran/vla-type.exp: Likewise.
* gdb.fortran/vla-value.exp: Likewise.
* gdb.mi/mi-vla-fortran.exp: Likewise.
---
gdb/ChangeLog | 9 +++
gdb/f-typeprint.c | 83 +++++++++++-----------
gdb/testsuite/ChangeLog | 10 +++
gdb/testsuite/gdb.fortran/pointers.f90 | 80 ++++++++++++++++++++++
gdb/testsuite/gdb.fortran/print_type.exp | 114 +++++++++++++++++++++++++++++++
gdb/testsuite/gdb.fortran/vla-ptype.exp | 12 ++--
gdb/testsuite/gdb.fortran/vla-type.exp | 7 +-
gdb/testsuite/gdb.fortran/vla-value.exp | 10 +--
gdb/testsuite/gdb.mi/mi-vla-fortran.exp | 8 +--
9 files changed, 277 insertions(+), 56 deletions(-)
create mode 100644 gdb/testsuite/gdb.fortran/pointers.f90
create mode 100755 gdb/testsuite/gdb.fortran/print_type.exp
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index a7c1a00a714..659ed05a75e 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -37,7 +37,7 @@ static void f_type_print_args (struct type *, struct ui_file *);
#endif
static void f_type_print_varspec_suffix (struct type *, struct ui_file *, int,
- int, int, int);
+ int, int, int, bool);
void f_type_print_varspec_prefix (struct type *, struct ui_file *,
int, int);
@@ -53,18 +53,6 @@ f_print_type (struct type *type, const char *varstring, struct ui_file *stream,
{
enum type_code code;
- if (type_not_associated (type))
- {
- val_print_not_associated (stream);
- return;
- }
-
- if (type_not_allocated (type))
- {
- val_print_not_allocated (stream);
- return;
- }
-
f_type_print_base (type, stream, show, level);
code = TYPE_CODE (type);
if ((varstring != NULL && *varstring != '\0')
@@ -96,7 +84,7 @@ f_print_type (struct type *type, const char *varstring, struct ui_file *stream,
demangled_args = (*varstring != '\0'
&& varstring[strlen (varstring) - 1] == ')');
- f_type_print_varspec_suffix (type, stream, show, 0, demangled_args, 0);
+ f_type_print_varspec_suffix (type, stream, show, 0, demangled_args, 0, false);
}
}
@@ -166,7 +154,7 @@ f_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
static void
f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
int show, int passed_a_ptr, int demangled_args,
- int arrayprint_recurse_level)
+ int arrayprint_recurse_level, bool print_rank_only)
{
/* No static variables are permitted as an error call may occur during
execution of this function. */
@@ -188,36 +176,52 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
fprintf_filtered (stream, "(");
if (type_not_associated (type))
- val_print_not_associated (stream);
+ print_rank_only = true;
else if (type_not_allocated (type))
- val_print_not_allocated (stream);
- else
- {
- if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
- f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
- 0, 0, arrayprint_recurse_level);
+ print_rank_only = true;
+ else if ((TYPE_ASSOCIATED_PROP (type)
+ && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ASSOCIATED_PROP (type)))
+ || (TYPE_ALLOCATED_PROP (type)
+ && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ALLOCATED_PROP (type)))
+ || (TYPE_DATA_LOCATION (type)
+ && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_DATA_LOCATION (type))))
+ {
+ /* This case exist when we ptype a typename which has the dynamic
+ properties but cannot be resolved as there is no object. */
+ print_rank_only = true;
+ }
- LONGEST lower_bound = f77_get_lowerbound (type);
+ if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
+ f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
+ 0, 0, arrayprint_recurse_level,
+ print_rank_only);
- if (lower_bound != 1) /* Not the default. */
+ if (print_rank_only)
+ fprintf_filtered (stream, ":");
+ else
+ {
+ LONGEST lower_bound = f77_get_lowerbound (type);
+ if (lower_bound != 1) /* Not the default. */
fprintf_filtered (stream, "%s:", plongest (lower_bound));
- /* Make sure that, if we have an assumed size array, we
- print out a warning and print the upperbound as '*'. */
+ /* Make sure that, if we have an assumed size array, we
+ print out a warning and print the upperbound as '*'. */
- if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
- fprintf_filtered (stream, "*");
- else
- {
- LONGEST upper_bound = f77_get_upperbound (type);
+ if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
+ fprintf_filtered (stream, "*");
+ else
+ {
+ LONGEST upper_bound = f77_get_upperbound (type);
fputs_filtered (plongest (upper_bound), stream);
- }
+ }
+ }
+
+ if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
+ f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
+ 0, 0, arrayprint_recurse_level,
+ print_rank_only);
- if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
- f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
- 0, 0, arrayprint_recurse_level);
- }
if (arrayprint_recurse_level == 1)
fprintf_filtered (stream, ")");
else
@@ -228,7 +232,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
case TYPE_CODE_PTR:
case TYPE_CODE_REF:
f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0,
- arrayprint_recurse_level);
+ arrayprint_recurse_level, false);
fprintf_filtered (stream, " )");
break;
@@ -237,7 +241,8 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
int i, nfields = TYPE_NFIELDS (type);
f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
- passed_a_ptr, 0, arrayprint_recurse_level);
+ passed_a_ptr, 0,
+ arrayprint_recurse_level, false);
if (passed_a_ptr)
fprintf_filtered (stream, ") ");
fprintf_filtered (stream, "(");
@@ -416,7 +421,7 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
fputs_filtered (" :: ", stream);
fputs_filtered (TYPE_FIELD_NAME (type, index), stream);
f_type_print_varspec_suffix (TYPE_FIELD_TYPE (type, index),
- stream, show - 1, 0, 0, 0);
+ stream, show - 1, 0, 0, 0, false);
fputs_filtered ("\n", stream);
}
fprintfi_filtered (level, stream, "End Type ");
diff --git a/gdb/testsuite/gdb.fortran/pointers.f90 b/gdb/testsuite/gdb.fortran/pointers.f90
new file mode 100644
index 00000000000..af0c9892995
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/pointers.f90
@@ -0,0 +1,80 @@
+! Copyright 2019 Free Software Foundation, Inc.
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 3 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+program pointers
+
+ type :: two
+ integer, allocatable :: ivla1 (:)
+ integer, allocatable :: ivla2 (:, :)
+ end type two
+
+ logical, target :: logv
+ complex, target :: comv
+ character, target :: charv
+ character (len=3), target :: chara
+ integer, target :: intv
+ integer, target, dimension (10,2) :: inta
+ real, target :: realv
+ type(two), target :: twov
+
+ logical, pointer :: logp
+ complex, pointer :: comp
+ character, pointer:: charp
+ character (len=3), pointer:: charap
+ integer, pointer :: intp
+ integer, pointer, dimension (:,:) :: intap
+ real, pointer :: realp
+ type(two), pointer :: twop
+
+ nullify (logp)
+ nullify (comp)
+ nullify (charp)
+ nullify (charap)
+ nullify (intp)
+ nullify (intap)
+ nullify (realp)
+ nullify (twop)
+
+ logp => logv ! Before pointer assignment
+ comp => comv
+ charp => charv
+ charap => chara
+ intp => intv
+ intap => inta
+ realp => realv
+ twop => twov
+
+ logv = associated(logp) ! Before value assignment
+ comv = cmplx(1,2)
+ charv = "a"
+ chara = "abc"
+ intv = 10
+ inta(:,:) = 1
+ inta(3,1) = 3
+ realv = 3.14
+
+ allocate (twov%ivla1(3))
+ allocate (twov%ivla2(2,2))
+ twov%ivla1(1) = 11
+ twov%ivla1(2) = 12
+ twov%ivla1(3) = 13
+ twov%ivla2(1,1) = 211
+ twov%ivla2(2,1) = 221
+ twov%ivla2(1,2) = 212
+ twov%ivla2(2,2) = 222
+
+ intv = intv + 1 ! After value assignment
+
+end program pointers
diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp
new file mode 100755
index 00000000000..2d6fb34e4e3
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/print_type.exp
@@ -0,0 +1,114 @@
+# Copyright 2019 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check how GDB handles printing pointers, both when associated, and
+# when not associated.
+
+standard_testfile "pointers.f90"
+load_lib fortran.exp
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ {debug f90 quiet}] } {
+ return -1
+}
+
+if ![runto_main] {
+ untested "could not run to main"
+ return -1
+}
+
+# Depending on the compiler being used, the type names can be printed
+# differently.
+set logical [fortran_logical4]
+set real [fortran_real4]
+set int [fortran_int4]
+set complex [fortran_complex4]
+
+# Print the inferior variable VAR_NAME, and check that the result
+# matches the string TYPE.
+proc check_pointer_type { var_name type } {
+ gdb_test "ptype ${var_name}" \
+ "type = PTR TO -> \\( ${type} \\)"
+}
+
+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
+gdb_continue_to_breakpoint "Before pointer assignment"
+
+with_test_prefix "pointers not associated" {
+ check_pointer_type "logp" "$logical"
+ check_pointer_type "comp" "$complex"
+ check_pointer_type "charp" "character\\*1"
+ check_pointer_type "charap" "character\\*3"
+ check_pointer_type "intp" "$int"
+
+ # Current gfortran seems to not mark 'intap' as a pointer. Intels
+ # Fortran compiler does though.
+ set test "ptype intap"
+ gdb_test_multiple "ptype intap" $test {
+ -re "type = PTR TO -> \\( $int \\(:,:\\) \\)\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "type = $int \\(:,:\\)\r\n$gdb_prompt $" {
+ pass $test
+ }
+ }
+
+ check_pointer_type "realp" "$real"
+ check_pointer_type "twop" \
+ [multi_line "Type two" \
+ " $int, allocatable :: ivla1\\(:\\)" \
+ " $int, allocatable :: ivla2\\(:,:\\)" \
+ "End Type two"]
+}
+
+gdb_test "ptype two" \
+ [multi_line "type = Type two" \
+ " $int, allocatable :: ivla1\\(:\\)" \
+ " $int, allocatable :: ivla2\\(:,:\\)" \
+ "End Type two"]
+
+gdb_breakpoint [gdb_get_line_number "Before value assignment"]
+gdb_continue_to_breakpoint "Before value assignment"
+gdb_test "ptype twop" \
+ [multi_line "type = PTR TO -> \\( Type two" \
+ " $int, allocatable :: ivla1\\(:\\)" \
+ " $int, allocatable :: ivla2\\(:,:\\)" \
+ "End Type two \\)"]
+
+gdb_breakpoint [gdb_get_line_number "After value assignment"]
+gdb_continue_to_breakpoint "After value assignment"
+gdb_test "ptype logv" "type = $logical"
+gdb_test "ptype comv" "type = $complex"
+gdb_test "ptype charv" "type = character\\*1"
+gdb_test "ptype chara" "type = character\\*3"
+gdb_test "ptype intv" "type = $int"
+gdb_test "ptype inta" "type = $int \\(10,2\\)"
+gdb_test "ptype realv" "type = $real"
+
+gdb_test "ptype logp" "type = PTR TO -> \\( $logical \\)"
+gdb_test "ptype comp" "type = PTR TO -> \\( $complex \\)"
+gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1 \\)"
+gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3 \\)"
+gdb_test "ptype intp" "type = PTR TO -> \\( $int \\)"
+set test "ptype intap"
+gdb_test_multiple $test $test {
+ -re "type = $int \\(10,2\\)\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "type = PTR TO -> \\( $int \\(10,2\\)\\)\r\n$gdb_prompt $" {
+ pass $test
+ }
+}
+gdb_test "ptype realp" "type = PTR TO -> \\( $real \\)"
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
index 0f4abb63757..a4c3c9c7030 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
@@ -32,9 +32,9 @@ set real [fortran_real4]
# Check the ptype of various VLA states and pointer to VLA's.
gdb_breakpoint [gdb_get_line_number "vla1-init"]
gdb_continue_to_breakpoint "vla1-init"
-gdb_test "ptype vla1" "type = <not allocated>" "ptype vla1 not initialized"
-gdb_test "ptype vla2" "type = <not allocated>" "ptype vla2 not initialized"
-gdb_test "ptype pvla" "type = <not associated>" "ptype pvla not initialized"
+gdb_test "ptype vla1" "type = $real, allocatable \\(:,:,:\\)" "ptype vla1 not initialized"
+gdb_test "ptype vla2" "type = $real, allocatable \\(:,:,:\\)" "ptype vla2 not initialized"
+gdb_test "ptype pvla" "type = $real \\(:,:,:\\)" "ptype pvla not initialized"
gdb_test "ptype vla1(3, 6, 9)" "no such vector element \\\(vector not allocated\\\)" \
"ptype vla1(3, 6, 9) not initialized"
gdb_test "ptype vla2(5, 45, 20)" \
@@ -81,20 +81,20 @@ gdb_test "ptype vla2(5, 45, 20)" "type = $real" \
gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
gdb_continue_to_breakpoint "pvla-deassociated"
-gdb_test "ptype pvla" "type = <not associated>" "ptype pvla deassociated"
+gdb_test "ptype pvla" "type = $real \\(:,:,:\\)" "ptype pvla deassociated"
gdb_test "ptype pvla(5, 45, 20)" \
"no such vector element \\\(vector not associated\\\)" \
"ptype pvla(5, 45, 20) not associated"
gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
gdb_continue_to_breakpoint "vla1-deallocated"
-gdb_test "ptype vla1" "type = <not allocated>" "ptype vla1 not allocated"
+gdb_test "ptype vla1" "type = $real, allocatable \\(:,:,:\\)" "ptype vla1 not allocated"
gdb_test "ptype vla1(3, 6, 9)" "no such vector element \\\(vector not allocated\\\)" \
"ptype vla1(3, 6, 9) not allocated"
gdb_breakpoint [gdb_get_line_number "vla2-deallocated"]
gdb_continue_to_breakpoint "vla2-deallocated"
-gdb_test "ptype vla2" "type = <not allocated>" "ptype vla2 not allocated"
+gdb_test "ptype vla2" "type = $real, allocatable \\(:,:,:\\)" "ptype vla2 not allocated"
gdb_test "ptype vla2(5, 45, 20)" \
"no such vector element \\\(vector not allocated\\\)" \
"ptype vla2(5, 45, 20) not allocated"
diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
index 951f118194a..b88a3d042d1 100755
--- a/gdb/testsuite/gdb.fortran/vla-type.exp
+++ b/gdb/testsuite/gdb.fortran/vla-type.exp
@@ -132,7 +132,10 @@ gdb_test "ptype fivearr(2)%tone" \
"End Type one" ]
# Check allocation status of dynamic array and it's dynamic members
-gdb_test "ptype fivedynarr" "type = <not allocated>"
+gdb_test "ptype fivedynarr" \
+ [multi_line "type = Type five" \
+ " Type one :: tone" \
+ "End Type five, allocatable \\(:\\)" ]
gdb_test "next" ""
gdb_test "ptype fivedynarr(2)" \
[multi_line "type = Type five" \
@@ -141,7 +144,7 @@ gdb_test "ptype fivedynarr(2)" \
"ptype fivedynarr(2), tone is not allocated"
gdb_test "ptype fivedynarr(2)%tone" \
[multi_line "type = Type one" \
- " $int, allocatable :: ivla\\(<not allocated>\\)" \
+ " $int, allocatable :: ivla\\(:,:,:\\)" \
"End Type one" ] \
"ptype fivedynarr(2)%tone, not allocated"
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
index be397fd95fb..3cf5d675005 100644
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
@@ -35,7 +35,7 @@ gdb_breakpoint [gdb_get_line_number "vla1-init"]
gdb_continue_to_breakpoint "vla1-init"
gdb_test "print vla1" " = <not allocated>" "print non-allocated vla1"
gdb_test "print &vla1" \
- " = \\\(PTR TO -> \\\( $real, allocatable \\\(<not allocated>\\\) \\\)\\\) $hex" \
+ " = \\\(PTR TO -> \\\( $real, allocatable \\\(:,:,:\\\) \\\)\\\) $hex" \
"print non-allocated &vla1"
gdb_test "print vla1(1,1,1)" "no such vector element \\\(vector not allocated\\\)" \
"print member in non-allocated vla1 (1)"
@@ -76,7 +76,7 @@ gdb_test "print vla1(9, 9, 9)" " = 999" \
# Try to access values in undefined pointer to VLA (dangling)
gdb_test "print pvla" " = <not associated>" "print undefined pvla"
gdb_test "print &pvla" \
- " = \\\(PTR TO -> \\\( $real \\\(<not associated>\\\) \\\)\\\) $hex" \
+ " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\) \\\)\\\) $hex" \
"print non-associated &pvla"
gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated\\\)" \
"print undefined pvla(1,3,8)"
@@ -134,7 +134,7 @@ if ![runto MAIN__] then {
continue
}
gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
-gdb_continue_to_breakpoint "vla2-allocated"
+gdb_continue_to_breakpoint "vla2-allocated, second time"
# Many instructions to be executed when step over this line, and it is
# slower in remote debugging. Increase the timeout to avoid timeout
# fail.
@@ -151,13 +151,13 @@ gdb_test "next" "\\d+.*vla1\\(1, 3, 8\\) = 1001" "next (2)"
gdb_test "print \$myvar(3,6,9)" " = 1311" "print \$myvar(3,6,9)"
gdb_breakpoint [gdb_get_line_number "pvla-associated"]
-gdb_continue_to_breakpoint "pvla-associated"
+gdb_continue_to_breakpoint "pvla-associated, second time"
gdb_test_no_output "set \$mypvar = pvla" "set \$mypvar = pvla"
gdb_test "print \$mypvar(1,3,8)" " = 1001" "print \$mypvar(1,3,8)"
# deallocate pointer and make sure user defined variable still has the
# right value.
gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
-gdb_continue_to_breakpoint "pvla-deassociated"
+gdb_continue_to_breakpoint "pvla-deassociated, second time"
gdb_test "print \$mypvar(1,3,8)" " = 1001" \
"print \$mypvar(1,3,8) after deallocated"
diff --git a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
index 0759ccbaebe..ec04bbe5a69 100644
--- a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
+++ b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
@@ -51,10 +51,10 @@ mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
mi_gdb_test "500-data-evaluate-expression vla1" \
"500\\^done,value=\"<not allocated>\"" "evaluate not allocated vla, before allocation"
-mi_create_varobj_checked vla1_not_allocated vla1 "<not allocated>" \
+mi_create_varobj_checked vla1_not_allocated vla1 "$real, allocatable \\(:\\)" \
"create local variable vla1_not_allocated"
mi_gdb_test "501-var-info-type vla1_not_allocated" \
- "501\\^done,type=\"<not allocated>\"" \
+ "501\\^done,type=\"$real, allocatable \\(:\\)\"" \
"info type variable vla1_not_allocated"
mi_gdb_test "502-var-show-format vla1_not_allocated" \
"502\\^done,format=\"natural\"" \
@@ -146,10 +146,10 @@ gdb_expect {
-re "580\\^done,value=\"<not associated>\".*${mi_gdb_prompt}$" {
pass $test
- mi_create_varobj_checked pvla2_not_associated pvla2 "<not associated>" \
+ mi_create_varobj_checked pvla2_not_associated pvla2 "$real \\(:,:\\)" \
"create local variable pvla2_not_associated"
mi_gdb_test "581-var-info-type pvla2_not_associated" \
- "581\\^done,type=\"<not associated>\"" \
+ "581\\^done,type=\"$real \\(:,:\\)\"" \
"info type variable pvla2_not_associated"
mi_gdb_test "582-var-show-format pvla2_not_associated" \
"582\\^done,format=\"natural\"" \
--
2.14.5
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/3] Introduce a separate debug objfile iterator
2019-05-15 9:45 ` John Marshall
@ 2019-05-15 15:45 ` Tom Tromey
2019-05-15 20:00 ` John Marshall
0 siblings, 1 reply; 19+ messages in thread
From: Tom Tromey @ 2019-05-15 15:45 UTC (permalink / raw)
To: John Marshall; +Cc: Tom Tromey, Sandra Loosemore, gdb-patches
>>>>> "John" == John Marshall <John.W.Marshall@glasgow.ac.uk> writes:
John> On 3 May 2019, Tom Tromey <tom@tromey.com> wrote:
>> commit bba6afebd7fde978acb6e06a48084a694aab3b7a
>> Author: Tom Tromey <tom@tromey.com>
>> Date: Fri May 3 17:21:36 2019 -0600
>>
>> Remove "struct" from foreach statements
>> [snip]
>> * darwin-nat.c (thread_info_from_private_thread_info): Remove
>> "struct" from foreach.
John> This broke compilation on macOS (tested on Mojave) with both Clang and GCC (9.1.0):
Can you try the appended? I no longer have a macOS machine to test on.
If this works for you, I will check it in.
This clashes with the normal gcc bug workaround that we do here; but I
think on macOS that probably isn't worth worrying about.
Tom
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index e3368ce6471..8282ef27e61 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1706,7 +1706,7 @@ darwin_attach_pid (struct inferior *inf)
static struct thread_info *
thread_info_from_private_thread_info (darwin_thread_info *pti)
{
- for (thread_info *it : all_threads ())
+ for (struct thread_info *it : all_threads ())
{
darwin_thread_info *iter_pti = get_darwin_thread_info (it);
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 3/3] Introduce a separate debug objfile iterator
2019-05-15 15:45 ` Tom Tromey
@ 2019-05-15 20:00 ` John Marshall
0 siblings, 0 replies; 19+ messages in thread
From: John Marshall @ 2019-05-15 20:00 UTC (permalink / raw)
To: Tom Tromey; +Cc: Sandra Loosemore, gdb-patches
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 6178 bytes --]
On 15 May 2019, at 16:45, Tom Tromey <tom@tromey.com> wrote:
> John> This broke compilation on macOS (tested on Mojave) with both Clang and GCC (9.1.0):
>
> Can you try the appended? I no longer have a macOS machine to test on.
Yes, that does the trick.
> This clashes with the normal gcc bug workaround that we do here; but I
> think on macOS that probably isn't worth worrying about.
Possibly a C-style for loop with explicit begin()/end() would work with both, but I'd agree that it's not worth worrying about for this Darwin-only file.
Thanks,
John
From gdb-patches-return-156121-listarch-gdb-patches=sources.redhat.com@sourceware.org Wed May 15 21:30:59 2019
Return-Path: <gdb-patches-return-156121-listarch-gdb-patches=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-patches@sources.redhat.com
Received: (qmail 84626 invoked by alias); 15 May 2019 21:30:56 -0000
Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-patches.sourceware.org>
List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-patches/>
List-Post: <mailto:gdb-patches@sourceware.org>
List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs>
Sender: gdb-patches-owner@sourceware.org
Delivered-To: mailing list gdb-patches@sourceware.org
Received: (qmail 84450 invoked by uid 89); 15 May 2019 21:30:39 -0000
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammyX-HELO: mail-wr1-f44.google.com
Received: from mail-wr1-f44.google.com (HELO mail-wr1-f44.google.com) (209.85.221.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 May 2019 21:30:21 +0000
Received: by mail-wr1-f44.google.com with SMTP id d9so1090628wrx.0 for <gdb-patches@sourceware.org>; Wed, 15 May 2019 14:30:15 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XvPLxkseq9ZRVEoNTfQ7AzN1P96nL0iuNe04dEQD+24=; b=S/yPUfo3nLPMMSq3MEpfr3pEzhgtKz0ZnfZZ7nbvJGhs0QTTz317g6YcfN4fxkUCGw mllxLml+ODial/v7Ai7lXwc6JR7GbaIcLglKdPej6m3/0AA4MfNRvhpeJ8eboKxBBttR /rUalG5+LWxblwc93OMaiyk2fUvq8ZAwH9jJXJtMsN2/mM9egXKPPPMLuu+uys9VpHyU C6wD8rMFR0bgkYJwRbJDcYJdu9arIDYgvgtzCf6qy2oeDJttOWDEOA9yjRv5E0S9iigq 3H+uIkkcPl3TrZJNhOi18K6jQyosLer2hbAm0/trCDXJeO7Rb+4gioeA3IgM5aztuBh9 YgvQ=Return-Path: <andrew.burgess@embecosm.com>
Received: from localhost (host86-180-62-212.range86-180.btcentralplus.com. [86.180.62.212]) by smtp.gmail.com with ESMTPSA id y132sm5675259wmd.35.2019.05.15.14.30.12 (version=TLS1_2 cipherìDHE-RSA-CHACHA20-POLY1305 bits%6/256); Wed, 15 May 2019 14:30:12 -0700 (PDT)
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PUSHED] gdb/fortran: Add sizeof tests for indexed and sliced arrays
Date: Wed, 15 May 2019 21:30:00 -0000
Message-Id: <20190515213009.23058-1-andrew.burgess@embecosm.com>
In-Reply-To: <20181127183139.71170-12-sbasierski@pl.sii.eu>
References: <20181127183139.71170-12-sbasierski@pl.sii.eu>
X-IsSubscribed: yes
X-SW-Source: 2019-05/txt/msg00353.txt.bz2
Content-length: 2597
I've pushed the below.
Thanks,
Andrew
--
Add tests for calling sizeof on indexed and sliced arrays, and on
pointers to arrays. These are all things that currently work, but
were previously untested.
gdb/testsuite/ChangeLog:
* gdb.fortran/vla-sizeof.exp: Add tests of sizeof applied to
indexed and sliced arrays, and pointers to arrays.
---
gdb/testsuite/ChangeLog | 5 +++++
gdb/testsuite/gdb.fortran/vla-sizeof.exp | 23 +++++++++++++++++++----
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
index 7f74a699d76..b6fdaebbf51 100644
--- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
@@ -29,18 +29,33 @@ if ![runto_main] {
gdb_breakpoint [gdb_get_line_number "vla1-init"]
gdb_continue_to_breakpoint "vla1-init"
gdb_test "print sizeof(vla1)" " = 0" "print sizeof non-allocated vla1"
+gdb_test "print sizeof(vla1(3,2,1))" \
+ "no such vector element \\(vector not allocated\\)" \
+ "print sizeof non-allocated indexed vla1"
+gdb_test "print sizeof(vla1(3:4,2,1))" "slice out of range" \
+ "print sizeof non-allocated sliced vla1"
# Try to access value in allocated VLA
-gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
-gdb_continue_to_breakpoint "vla2-allocated"
+gdb_breakpoint [gdb_get_line_number "vla1-allocated"]
+gdb_continue_to_breakpoint "vla1-allocated"
gdb_test "print sizeof(vla1)" " = 4000" "print sizeof allocated vla1"
+gdb_test "print sizeof(vla1(3,2,1))" "4" \
+ "print sizeof element from allocated vla1"
+gdb_test "print sizeof(vla1(3:4,2,1))" "800" \
+ "print sizeof sliced vla1"
# Try to access values in undefined pointer to VLA (dangling)
-gdb_breakpoint [gdb_get_line_number "vla1-filled"]
-gdb_continue_to_breakpoint "vla1-filled"
gdb_test "print sizeof(pvla)" " = 0" "print sizeof non-associated pvla"
+gdb_test "print sizeof(pvla(3,2,1))" \
+ "no such vector element \\(vector not associated\\)" \
+ "print sizeof non-associated indexed pvla"
+gdb_test "print sizeof(pvla(3:4,2,1))" "slice out of range" \
+ "print sizeof non-associated sliced pvla"
# Try to access values in pointer to VLA and compare them
gdb_breakpoint [gdb_get_line_number "pvla-associated"]
gdb_continue_to_breakpoint "pvla-associated"
gdb_test "print sizeof(pvla)" " = 4000" "print sizeof associated pvla"
+gdb_test "print sizeof(pvla(3,2,1))" "4" \
+ "print sizeof element from associated pvla"
+gdb_test "print sizeof(pvla(3:4,2,1))" "800" "print sizeof sliced pvla"
--
2.14.5
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2019-05-15 20:00 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-09 18:11 [PATCH 0/3] some minor objfile iteration improvements Tom Tromey
2019-04-09 18:09 ` [PATCH 2/3] Fix a couple of comments Tom Tromey
2019-04-10 1:51 ` Simon Marchi
2019-04-09 18:09 ` [PATCH 3/3] Introduce a separate debug objfile iterator Tom Tromey
2019-04-10 2:01 ` Simon Marchi
2019-04-10 14:08 ` Tom Tromey
2019-04-30 15:44 ` Sandra Loosemore
2019-04-30 15:51 ` Tom Tromey
2019-05-01 18:30 ` Tom Tromey
2019-05-03 18:23 ` Sandra Loosemore
2019-05-03 23:28 ` Tom Tromey
2019-05-15 9:45 ` John Marshall
2019-05-15 15:45 ` Tom Tromey
2019-05-15 20:00 ` John Marshall
2019-04-09 18:09 ` [PATCH 1/3] Remove some uses of "object_files" Tom Tromey
2019-04-10 1:49 ` Simon Marchi
2019-04-10 2:26 ` Tom Tromey
2019-04-10 2:50 ` Simon Marchi
2019-04-10 14:08 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox