[PATCH5 PR gdb/16959] gdb hangs in infinite recursion
Weimin Pan
weimin.pan@oracle.com
Fri Mar 30 21:44:00 GMT 2018
On 3/29/2018 10:08 PM, Simon Marchi wrote:
> On 2018-03-28 16:44, Weimin Pan wrote:
>> The original problem was fixed (see related PR 22242). But using a
>> typedef
>> as the declared type for a static member variable, as commented in
>> this PR,
>> is still causing gdb to get into infinite loop when printing the static
>> member's value. This problem can be reproduced as follows:
>>
>> % cat t.cc
>> class A {
>> Â Â Â typedef A type;
>> public:
>> Â Â Â bool operator==(const type& other) { return true; }
>>
>> Â Â Â static const type INSTANCE;
>> };
>>
>> const A A::INSTANCE;
>>
>> int main() {
>> Â Â Â A a;
>> Â Â Â if (a == A::INSTANCE) {
>> Â Â Â Â Â Â Â return -1;
>> Â Â Â }
>> Â Â Â return 0;
>> }
>> % g++ -g t.cc
>> % gdb -ex "start" -ex "p a" a.out
>>
>> The fix is rather trivial - in cp_print_static_field(), should call
>> check_typedef() to get the static member's real type and use it to
>> check whether it's a struct or an array.
>>
>> As Simon suggested, I've added a new test case to the testsuite
>> and am passing the original type, not the real type, as argument
>> to both cp_print_value_fields() and val_print().
>>
>> Re-tested on both aarch64-linux-gnu and amd64-linux-gnu. No regressions.
>
> Hi Weimin,
>
> Could you change the title to something more descriptive about what
> the change/fix is, rather than the problem being fixed? For example,
> "Fix infinite recursion when printing static member with typedef".
>
> It is ok to push with that fixed (feel free to ask if you still need
> some guidance).
>
> Thanks!
>
> Simon
Hi Simon,
I just got started to work on this. Here is what I've done (I followed
your lead to creat a different remote name):
% git add <newfile>
% git commit -a
% git remote add upstream ssh://sourceware.org/git/binutils-gdb.git
% git fetch upstream
I have a few questions:
 * Do I need to do a "git merge" after "git fetch"? Or can I just
  do "git pull" which is equivalent to "git fetch;git merge"?
  (I was a Mercurial(hg) user, its typical workflow is like:
   hg in; do work; hg commit; hg pull; hg rebase(if needed); hg push)
 * In your previous email, you said:
  Make sure you inserted the ChangeLog entries in the actual ChangeLog
files
  and amended your commit
  It seems the "git commit -a" command will contain all the changes,
including
  those in ChangeLog files. Why do I have to insert the entries?
 * Changing the commit title to be be more descriptive:
  So I need to use "git commit --amend" to change the title?
Thanks very much for your help.
Weimin
More information about the Gdb-patches
mailing list