gdb, dwarf: Don't follow the parent of a subprogram to get a prefix.
authorFelix Willgerodt <felix.willgerodt@intel.com>
Wed, 23 Jun 2021 13:56:24 +0000 (15:56 +0200)
committerFelix Willgerodt <felix.willgerodt@intel.com>
Tue, 13 Jul 2021 13:29:29 +0000 (15:29 +0200)
commit81e33ce2894678a60ed4d5e4471cd6eb968056c2
tree4114dbe7fe5cdbd8475835806ea01aab7152752b
parent5c046e0e631dc98faec53d99c76f9d3ef44da75c
gdb, dwarf: Don't follow the parent of a subprogram to get a prefix.

During prefix resolution, if the parent is a subprogram, there is no need
to go to the parent of the subprogram.  The DIE will be local.

For a program like:
~~~
  class F1
  {
  public:
    int a;
    int
    vvv ()
    {
      class F2
      {
int f;
      };
      F2 abcd;
      return 1;
    }
  };
~~~

The class F2 should not be seen as a member of F1.

Before:
~~~
(gdb) ptype abcd
type = class F1::F2 {
  private:
    int f;
}
~~~

After:
~~~
(gdb) ptype abcd
type = class F2 {
  private:
    int f;
}
~~~

gdb/ChangeLog:
2021-06-23  Felix Willgerodt  <felix.willgerodt@intel.com>

* dwarf2/read.c (determine_prefix): Return an empty prefix if the
parent is a subprogram.

gdb/testsuite/ChangeLog:
2021-06-23  Felix Willgerodt  <felix.willgerodt@intel.com>

* gdb.cp/nested-class-func-class.cc: New file.
* gdb.cp/nested-class-func-class.exp: New file.
gdb/dwarf2/read.c
gdb/testsuite/gdb.cp/nested-class-func-class.cc [new file with mode: 0644]
gdb/testsuite/gdb.cp/nested-class-func-class.exp [new file with mode: 0644]