public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [committed][gdbserver] Fix Wlto-type-mismatch for debug_agent
@ 2020-06-12 16:37 Tom de Vries
  2020-06-12 18:19 ` Christian Biesinger
  0 siblings, 1 reply; 5+ messages in thread
From: Tom de Vries @ 2020-06-12 16:37 UTC (permalink / raw)
  To: gdb-patches

Hi,

When building gdb including gdbserver with CFLAGS/CXXFLAGS -O2 -g -flto=auto,
I run into:
...
src/gdbserver/../gdbsupport/agent.h:47:13: error: type of 'debug_agent' \
  does not match original declaration [-Werror=lto-type-mismatch]
 extern bool debug_agent;
             ^
src/gdbserver/ax.cc:28:5: note: type 'int' should match type 'bool'
 int debug_agent = 0;
     ^
src/gdbserver/ax.cc:28:5: note: 'debug_agent' was previously declared here
src/gdbserver/ax.cc:28:5: note: code may be misoptimized unless \
  -fno-strict-aliasing is used
...

Fix this by changing the type of debug_agent in ax.cc from int to bool.

Tested on x86_64-linux.

Committed to trunk.

Thanks,
- Tom

[gdbserver] Fix Wlto-type-mismatch for debug_agent

---
 gdbserver/ax.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdbserver/ax.cc b/gdbserver/ax.cc
index 213db410a0..42d28128fa 100644
--- a/gdbserver/ax.cc
+++ b/gdbserver/ax.cc
@@ -25,7 +25,7 @@
 static void ax_vdebug (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
 
 #ifdef IN_PROCESS_AGENT
-int debug_agent = 0;
+bool debug_agent = 0;
 #endif
 
 static void

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [committed][gdbserver] Fix Wlto-type-mismatch for debug_agent
  2020-06-12 16:37 [committed][gdbserver] Fix Wlto-type-mismatch for debug_agent Tom de Vries
@ 2020-06-12 18:19 ` Christian Biesinger
  2020-06-17 16:38   ` Tom de Vries
  0 siblings, 1 reply; 5+ messages in thread
From: Christian Biesinger @ 2020-06-12 18:19 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

On Fri, Jun 12, 2020 at 11:37 AM Tom de Vries <tdevries@suse.de> wrote:
>
> Hi,
>
> When building gdb including gdbserver with CFLAGS/CXXFLAGS -O2 -g -flto=auto,
> I run into:
> ...
> src/gdbserver/../gdbsupport/agent.h:47:13: error: type of 'debug_agent' \
>   does not match original declaration [-Werror=lto-type-mismatch]
>  extern bool debug_agent;
>              ^
> src/gdbserver/ax.cc:28:5: note: type 'int' should match type 'bool'
>  int debug_agent = 0;
>      ^
> src/gdbserver/ax.cc:28:5: note: 'debug_agent' was previously declared here
> src/gdbserver/ax.cc:28:5: note: code may be misoptimized unless \
>   -fno-strict-aliasing is used

So it sounds like this didn't come up before because ax.cc doesn't
include gdbsupport/agent.h? It probably should?

Christian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [committed][gdbserver] Fix Wlto-type-mismatch for debug_agent
  2020-06-12 18:19 ` Christian Biesinger
@ 2020-06-17 16:38   ` Tom de Vries
  2020-06-18  8:44     ` [PATCH][gdbserver] Add missing include of gdbsupport/agent.h Tom de Vries
  0 siblings, 1 reply; 5+ messages in thread
From: Tom de Vries @ 2020-06-17 16:38 UTC (permalink / raw)
  To: Christian Biesinger; +Cc: gdb-patches

On 6/12/20 8:19 PM, Christian Biesinger wrote:
> On Fri, Jun 12, 2020 at 11:37 AM Tom de Vries <tdevries@suse.de> wrote:
>>
>> Hi,
>>
>> When building gdb including gdbserver with CFLAGS/CXXFLAGS -O2 -g -flto=auto,
>> I run into:
>> ...
>> src/gdbserver/../gdbsupport/agent.h:47:13: error: type of 'debug_agent' \
>>   does not match original declaration [-Werror=lto-type-mismatch]
>>  extern bool debug_agent;
>>              ^
>> src/gdbserver/ax.cc:28:5: note: type 'int' should match type 'bool'
>>  int debug_agent = 0;
>>      ^
>> src/gdbserver/ax.cc:28:5: note: 'debug_agent' was previously declared here
>> src/gdbserver/ax.cc:28:5: note: code may be misoptimized unless \
>>   -fno-strict-aliasing is used
> 
> So it sounds like this didn't come up before because ax.cc doesn't
> include gdbsupport/agent.h?

Yes.

> It probably should?

Um, good point, thanks.

Though ax.h does:
...
#ifdef IN_PROCESS_AGENT
#define debug_threads debug_agent
#endif
...
so I wonder if we should have the include there instead.  I'll try to
test this.

Thanks,
- Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH][gdbserver] Add missing include of gdbsupport/agent.h
  2020-06-17 16:38   ` Tom de Vries
@ 2020-06-18  8:44     ` Tom de Vries
  2020-06-19 20:22       ` Christian Biesinger
  0 siblings, 1 reply; 5+ messages in thread
From: Tom de Vries @ 2020-06-18  8:44 UTC (permalink / raw)
  To: Christian Biesinger; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1242 bytes --]

[ was: Re: [committed][gdbserver] Fix Wlto-type-mismatch for debug_agent ]
On 6/17/20 6:38 PM, Tom de Vries wrote:
> On 6/12/20 8:19 PM, Christian Biesinger wrote:
>> On Fri, Jun 12, 2020 at 11:37 AM Tom de Vries <tdevries@suse.de> wrote:
>>>
>>> Hi,
>>>
>>> When building gdb including gdbserver with CFLAGS/CXXFLAGS -O2 -g -flto=auto,
>>> I run into:
>>> ...
>>> src/gdbserver/../gdbsupport/agent.h:47:13: error: type of 'debug_agent' \
>>>   does not match original declaration [-Werror=lto-type-mismatch]
>>>  extern bool debug_agent;
>>>              ^
>>> src/gdbserver/ax.cc:28:5: note: type 'int' should match type 'bool'
>>>  int debug_agent = 0;
>>>      ^
>>> src/gdbserver/ax.cc:28:5: note: 'debug_agent' was previously declared here
>>> src/gdbserver/ax.cc:28:5: note: code may be misoptimized unless \
>>>   -fno-strict-aliasing is used
>>
>> So it sounds like this didn't come up before because ax.cc doesn't
>> include gdbsupport/agent.h?
> 
> Yes.
> 
>> It probably should?
> 
> Um, good point, thanks.
> 
> Though ax.h does:
> ...
> #ifdef IN_PROCESS_AGENT
> #define debug_threads debug_agent
> #endif
> ...
> so I wonder if we should have the include there instead.  I'll try to
> test this.

Any comments?

Thanks,
- Tom


[-- Attachment #2: 0001-gdbserver-Add-missing-include-of-gdbsupport-agent.h.patch --]
[-- Type: text/x-patch, Size: 1263 bytes --]

[gdbserver] Add missing include of gdbsupport/agent.h

The file gdbserver/ax.h contains:
...
 #ifdef IN_PROCESS_AGENT
 #define debug_threads debug_agent
 #endif
...
but does not declare debug_agent.

Fix this by adding an include of gdbsupport/agent.h.

[ If this fix would have been in place before commit 8118159c69 "[gdbserver] Fix
Wlto-type-mismatch for debug_agent", we would have simply run into this build
breaker with a regular, non-lto build:
...
src/gdbserver/ax.cc:28:5: error: conflicting declaration 'int debug_agent'
 int debug_agent = 0;
     ^~~~~~~~~~~
In file included from src/gdbserver/ax.h:25:0,
                 from src/gdbserver/ax.cc:20:
src/gdbsupport/agent.h:47:13: note: previous declaration as 'bool debug_agent'
 extern bool debug_agent;
             ^~~~~~~~~~~
... ]

Tested on x86_64-linux.

gdbserver/ChangeLog:

2020-06-18  Tom de Vries  <tdevries@suse.de>

	* ax.h: Include gdbsupport/debug_agent.h.

---
 gdbserver/ax.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gdbserver/ax.h b/gdbserver/ax.h
index 1fba69e7ad..b7ff7d8910 100644
--- a/gdbserver/ax.h
+++ b/gdbserver/ax.h
@@ -22,6 +22,7 @@
 #include "regcache.h"
 
 #ifdef IN_PROCESS_AGENT
+#include "gdbsupport/agent.h"
 #define debug_threads debug_agent
 #endif
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][gdbserver] Add missing include of gdbsupport/agent.h
  2020-06-18  8:44     ` [PATCH][gdbserver] Add missing include of gdbsupport/agent.h Tom de Vries
@ 2020-06-19 20:22       ` Christian Biesinger
  0 siblings, 0 replies; 5+ messages in thread
From: Christian Biesinger @ 2020-06-19 20:22 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

On Thu, Jun 18, 2020 at 3:44 AM Tom de Vries <tdevries@suse.de> wrote:
>
> [ was: Re: [committed][gdbserver] Fix Wlto-type-mismatch for debug_agent ]
> On 6/17/20 6:38 PM, Tom de Vries wrote:
> > On 6/12/20 8:19 PM, Christian Biesinger wrote:
> >> On Fri, Jun 12, 2020 at 11:37 AM Tom de Vries <tdevries@suse.de> wrote:
> >>>
> >>> Hi,
> >>>
> >>> When building gdb including gdbserver with CFLAGS/CXXFLAGS -O2 -g -flto=auto,
> >>> I run into:
> >>> ...
> >>> src/gdbserver/../gdbsupport/agent.h:47:13: error: type of 'debug_agent' \
> >>>   does not match original declaration [-Werror=lto-type-mismatch]
> >>>  extern bool debug_agent;
> >>>              ^
> >>> src/gdbserver/ax.cc:28:5: note: type 'int' should match type 'bool'
> >>>  int debug_agent = 0;
> >>>      ^
> >>> src/gdbserver/ax.cc:28:5: note: 'debug_agent' was previously declared here
> >>> src/gdbserver/ax.cc:28:5: note: code may be misoptimized unless \
> >>>   -fno-strict-aliasing is used
> >>
> >> So it sounds like this didn't come up before because ax.cc doesn't
> >> include gdbsupport/agent.h?
> >
> > Yes.
> >
> >> It probably should?
> >
> > Um, good point, thanks.
> >
> > Though ax.h does:
> > ...
> > #ifdef IN_PROCESS_AGENT
> > #define debug_threads debug_agent
> > #endif
> > ...
> > so I wonder if we should have the include there instead.  I'll try to
> > test this.
>
> Any comments?

Looks good to me (but I'm not a maintainer)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-19 20:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-12 16:37 [committed][gdbserver] Fix Wlto-type-mismatch for debug_agent Tom de Vries
2020-06-12 18:19 ` Christian Biesinger
2020-06-17 16:38   ` Tom de Vries
2020-06-18  8:44     ` [PATCH][gdbserver] Add missing include of gdbsupport/agent.h Tom de Vries
2020-06-19 20:22       ` Christian Biesinger

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).