* [review] gdb: fix segfault in overload resolution debug output
@ 2019-11-29 10:25 Tankut Baris Aktemur (Code Review)
2019-11-29 11:06 ` Andrew Burgess (Code Review)
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tankut Baris Aktemur (Code Review) @ 2019-11-29 10:25 UTC (permalink / raw)
To: gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/734
......................................................................
gdb: fix segfault in overload resolution debug output
A segfault occurs if overload resolution debug mode is turned on via
the 'set debug overload' command. E.g.:
~~~
$ gdb ./a.out
...
(gdb) start
...
(gdb) set debug overload 1
(gdb) print foo(5)
-- Arg is int [8], parm is double [9]
Overloaded function instance (null) # of parms 1
Segmentation fault
$
~~~
The problem is, GDB tries to print the badness vector after it has
been std::move'd. Fix the problem by printing the vector before it is
moved.
gdb/ChangeLog:
2019-11-29 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* valops.c (find_oload_champ): Print part of debug messages
before the badness vector is std::move'd.
Change-Id: Ia623f9637e82ec332bfeac23eb6b0f2ffdcdde27
---
M gdb/valops.c
1 file changed, 25 insertions(+), 23 deletions(-)
diff --git a/gdb/valops.c b/gdb/valops.c
index cbb1f30..8af53de 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3023,6 +3023,28 @@
bv = rank_function (parm_types,
args.slice (static_offset));
+ if (overload_debug)
+ {
+ if (methods != NULL)
+ fprintf_filtered (gdb_stderr,
+ "Overloaded method instance %s, # of parms %d\n",
+ methods[ix].physname, (int) parm_types.size ());
+ else if (xmethods != NULL)
+ fprintf_filtered (gdb_stderr,
+ "Xmethod worker, # of parms %d\n",
+ (int) parm_types.size ());
+ else
+ fprintf_filtered (gdb_stderr,
+ "Overloaded function instance "
+ "%s # of parms %d\n",
+ functions[ix]->demangled_name (),
+ (int) parm_types.size ());
+ for (jj = 0; jj < args.size () - static_offset; jj++)
+ fprintf_filtered (gdb_stderr,
+ "...Badness @ %d : %d\n",
+ jj, bv[jj].rank);
+ }
+
if (oload_champ_bv->empty ())
{
*oload_champ_bv = std::move (bv);
@@ -3048,29 +3070,9 @@
break;
}
if (overload_debug)
- {
- if (methods != NULL)
- fprintf_filtered (gdb_stderr,
- "Overloaded method instance %s, # of parms %d\n",
- methods[ix].physname, (int) parm_types.size ());
- else if (xmethods != NULL)
- fprintf_filtered (gdb_stderr,
- "Xmethod worker, # of parms %d\n",
- (int) parm_types.size ());
- else
- fprintf_filtered (gdb_stderr,
- "Overloaded function instance "
- "%s # of parms %d\n",
- functions[ix]->demangled_name (),
- (int) parm_types.size ());
- for (jj = 0; jj < args.size () - static_offset; jj++)
- fprintf_filtered (gdb_stderr,
- "...Badness @ %d : %d\n",
- jj, bv[jj].rank);
- fprintf_filtered (gdb_stderr, "Overload resolution "
- "champion is %d, ambiguous? %d\n",
- oload_champ, oload_ambiguous);
- }
+ fprintf_filtered (gdb_stderr, "Overload resolution "
+ "champion is %d, ambiguous? %d\n",
+ oload_champ, oload_ambiguous);
}
return oload_champ;
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ia623f9637e82ec332bfeac23eb6b0f2ffdcdde27
Gerrit-Change-Number: 734
Gerrit-PatchSet: 1
Gerrit-Owner: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Gerrit-MessageType: newchange
^ permalink raw reply [flat|nested] 4+ messages in thread
* [review] gdb: fix segfault in overload resolution debug output
2019-11-29 10:25 [review] gdb: fix segfault in overload resolution debug output Tankut Baris Aktemur (Code Review)
@ 2019-11-29 11:06 ` Andrew Burgess (Code Review)
2019-11-29 11:24 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-11-29 11:24 ` Sourceware to Gerrit sync (Code Review)
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Burgess (Code Review) @ 2019-11-29 11:06 UTC (permalink / raw)
To: Tankut Baris Aktemur, gdb-patches
Andrew Burgess has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/734
......................................................................
Patch Set 1: Code-Review+2
LGTM.
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ia623f9637e82ec332bfeac23eb6b0f2ffdcdde27
Gerrit-Change-Number: 734
Gerrit-PatchSet: 1
Gerrit-Owner: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Gerrit-Reviewer: Andrew Burgess <andrew.burgess@embecosm.com>
Gerrit-Comment-Date: Fri, 29 Nov 2019 11:06:19 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pushed] gdb: fix segfault in overload resolution debug output
2019-11-29 10:25 [review] gdb: fix segfault in overload resolution debug output Tankut Baris Aktemur (Code Review)
2019-11-29 11:06 ` Andrew Burgess (Code Review)
@ 2019-11-29 11:24 ` Sourceware to Gerrit sync (Code Review)
2019-11-29 11:24 ` Sourceware to Gerrit sync (Code Review)
2 siblings, 0 replies; 4+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-11-29 11:24 UTC (permalink / raw)
To: Tankut Baris Aktemur, Andrew Burgess, gdb-patches
The original change was created by Tankut Baris Aktemur.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/734
......................................................................
gdb: fix segfault in overload resolution debug output
A segfault occurs if overload resolution debug mode is turned on via
the 'set debug overload' command. E.g.:
~~~
$ gdb ./a.out
...
(gdb) start
...
(gdb) set debug overload 1
(gdb) print foo(5)
-- Arg is int [8], parm is double [9]
Overloaded function instance (null) # of parms 1
Segmentation fault
$
~~~
The problem is, GDB tries to print the badness vector after it has
been std::move'd. Fix the problem by printing the vector before it is
moved.
gdb/ChangeLog:
2019-11-29 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* valops.c (find_oload_champ): Print part of debug messages
before the badness vector is std::move'd.
Change-Id: Ia623f9637e82ec332bfeac23eb6b0f2ffdcdde27
---
M gdb/ChangeLog
M gdb/valops.c
2 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bc61c35..a3c0670 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-29 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
+
+ * valops.c (find_oload_champ): Print part of debug messages
+ before the badness vector is std::move'd.
+
2019-11-28 Tom Tromey <tom@tromey.com>
* value.c (creal_internal_fn): Fix comment.
diff --git a/gdb/valops.c b/gdb/valops.c
index cbb1f30..8af53de 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3023,6 +3023,28 @@
bv = rank_function (parm_types,
args.slice (static_offset));
+ if (overload_debug)
+ {
+ if (methods != NULL)
+ fprintf_filtered (gdb_stderr,
+ "Overloaded method instance %s, # of parms %d\n",
+ methods[ix].physname, (int) parm_types.size ());
+ else if (xmethods != NULL)
+ fprintf_filtered (gdb_stderr,
+ "Xmethod worker, # of parms %d\n",
+ (int) parm_types.size ());
+ else
+ fprintf_filtered (gdb_stderr,
+ "Overloaded function instance "
+ "%s # of parms %d\n",
+ functions[ix]->demangled_name (),
+ (int) parm_types.size ());
+ for (jj = 0; jj < args.size () - static_offset; jj++)
+ fprintf_filtered (gdb_stderr,
+ "...Badness @ %d : %d\n",
+ jj, bv[jj].rank);
+ }
+
if (oload_champ_bv->empty ())
{
*oload_champ_bv = std::move (bv);
@@ -3048,29 +3070,9 @@
break;
}
if (overload_debug)
- {
- if (methods != NULL)
- fprintf_filtered (gdb_stderr,
- "Overloaded method instance %s, # of parms %d\n",
- methods[ix].physname, (int) parm_types.size ());
- else if (xmethods != NULL)
- fprintf_filtered (gdb_stderr,
- "Xmethod worker, # of parms %d\n",
- (int) parm_types.size ());
- else
- fprintf_filtered (gdb_stderr,
- "Overloaded function instance "
- "%s # of parms %d\n",
- functions[ix]->demangled_name (),
- (int) parm_types.size ());
- for (jj = 0; jj < args.size () - static_offset; jj++)
- fprintf_filtered (gdb_stderr,
- "...Badness @ %d : %d\n",
- jj, bv[jj].rank);
- fprintf_filtered (gdb_stderr, "Overload resolution "
- "champion is %d, ambiguous? %d\n",
- oload_champ, oload_ambiguous);
- }
+ fprintf_filtered (gdb_stderr, "Overload resolution "
+ "champion is %d, ambiguous? %d\n",
+ oload_champ, oload_ambiguous);
}
return oload_champ;
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ia623f9637e82ec332bfeac23eb6b0f2ffdcdde27
Gerrit-Change-Number: 734
Gerrit-PatchSet: 2
Gerrit-Owner: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Gerrit-Reviewer: Andrew Burgess <andrew.burgess@embecosm.com>
Gerrit-MessageType: newpatchset
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pushed] gdb: fix segfault in overload resolution debug output
2019-11-29 10:25 [review] gdb: fix segfault in overload resolution debug output Tankut Baris Aktemur (Code Review)
2019-11-29 11:06 ` Andrew Burgess (Code Review)
2019-11-29 11:24 ` [pushed] " Sourceware to Gerrit sync (Code Review)
@ 2019-11-29 11:24 ` Sourceware to Gerrit sync (Code Review)
2 siblings, 0 replies; 4+ messages in thread
From: Sourceware to Gerrit sync (Code Review) @ 2019-11-29 11:24 UTC (permalink / raw)
To: Tankut Baris Aktemur, gdb-patches; +Cc: Andrew Burgess
Sourceware to Gerrit sync has submitted this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/734
......................................................................
gdb: fix segfault in overload resolution debug output
A segfault occurs if overload resolution debug mode is turned on via
the 'set debug overload' command. E.g.:
~~~
$ gdb ./a.out
...
(gdb) start
...
(gdb) set debug overload 1
(gdb) print foo(5)
-- Arg is int [8], parm is double [9]
Overloaded function instance (null) # of parms 1
Segmentation fault
$
~~~
The problem is, GDB tries to print the badness vector after it has
been std::move'd. Fix the problem by printing the vector before it is
moved.
gdb/ChangeLog:
2019-11-29 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* valops.c (find_oload_champ): Print part of debug messages
before the badness vector is std::move'd.
Change-Id: Ia623f9637e82ec332bfeac23eb6b0f2ffdcdde27
---
M gdb/ChangeLog
M gdb/valops.c
2 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bc61c35..a3c0670 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-29 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
+
+ * valops.c (find_oload_champ): Print part of debug messages
+ before the badness vector is std::move'd.
+
2019-11-28 Tom Tromey <tom@tromey.com>
* value.c (creal_internal_fn): Fix comment.
diff --git a/gdb/valops.c b/gdb/valops.c
index cbb1f30..8af53de 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3023,6 +3023,28 @@
bv = rank_function (parm_types,
args.slice (static_offset));
+ if (overload_debug)
+ {
+ if (methods != NULL)
+ fprintf_filtered (gdb_stderr,
+ "Overloaded method instance %s, # of parms %d\n",
+ methods[ix].physname, (int) parm_types.size ());
+ else if (xmethods != NULL)
+ fprintf_filtered (gdb_stderr,
+ "Xmethod worker, # of parms %d\n",
+ (int) parm_types.size ());
+ else
+ fprintf_filtered (gdb_stderr,
+ "Overloaded function instance "
+ "%s # of parms %d\n",
+ functions[ix]->demangled_name (),
+ (int) parm_types.size ());
+ for (jj = 0; jj < args.size () - static_offset; jj++)
+ fprintf_filtered (gdb_stderr,
+ "...Badness @ %d : %d\n",
+ jj, bv[jj].rank);
+ }
+
if (oload_champ_bv->empty ())
{
*oload_champ_bv = std::move (bv);
@@ -3048,29 +3070,9 @@
break;
}
if (overload_debug)
- {
- if (methods != NULL)
- fprintf_filtered (gdb_stderr,
- "Overloaded method instance %s, # of parms %d\n",
- methods[ix].physname, (int) parm_types.size ());
- else if (xmethods != NULL)
- fprintf_filtered (gdb_stderr,
- "Xmethod worker, # of parms %d\n",
- (int) parm_types.size ());
- else
- fprintf_filtered (gdb_stderr,
- "Overloaded function instance "
- "%s # of parms %d\n",
- functions[ix]->demangled_name (),
- (int) parm_types.size ());
- for (jj = 0; jj < args.size () - static_offset; jj++)
- fprintf_filtered (gdb_stderr,
- "...Badness @ %d : %d\n",
- jj, bv[jj].rank);
- fprintf_filtered (gdb_stderr, "Overload resolution "
- "champion is %d, ambiguous? %d\n",
- oload_champ, oload_ambiguous);
- }
+ fprintf_filtered (gdb_stderr, "Overload resolution "
+ "champion is %d, ambiguous? %d\n",
+ oload_champ, oload_ambiguous);
}
return oload_champ;
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ia623f9637e82ec332bfeac23eb6b0f2ffdcdde27
Gerrit-Change-Number: 734
Gerrit-PatchSet: 2
Gerrit-Owner: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Gerrit-Reviewer: Andrew Burgess <andrew.burgess@embecosm.com>
Gerrit-MessageType: merged
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-29 11:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-29 10:25 [review] gdb: fix segfault in overload resolution debug output Tankut Baris Aktemur (Code Review)
2019-11-29 11:06 ` Andrew Burgess (Code Review)
2019-11-29 11:24 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-11-29 11:24 ` Sourceware to Gerrit sync (Code Review)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).