[review] Remove unused includes in infcmd.c and infrun.c

Message ID gerrit.1572157288000.I5e25af54ecd2235960c4127add8f604ddbb19153@gnutoolchain-gerrit.osci.io
State New, archived
Headers

Commit Message

Simon Marchi (Code Review) Oct. 27, 2019, 6:21 a.m. UTC
  Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/322
......................................................................

Remove unused includes in infcmd.c and infrun.c

include-what-you-use reported this:

../../../src/binutils-gdb/gdb/infcmd.c should remove these lines:
- #include <signal.h>  // lines 22-22
- #include "cli/cli-decode.h"  // lines 48-48
- #include "cli/cli-utils.h"  // lines 56-56
- #include "event-top.h"  // lines 38-38
- #include "infcall.h"  // lines 57-57
- #include "parser-defs.h"  // lines 39-39

../../../src/binutils-gdb/gdb/infrun.c should remove these lines:
- #include <signal.h>  // lines 37-37
- #include "cli/cli-script.h"  // lines 31-31
- #include "continuations.h"  // lines 54-54
- #include "dictionary.h"  // lines 45-45
- #include "gdbsupport/gdb_wait.h"  // lines 28-28
- #include "interps.h"  // lines 55-55

Remove those includes.

Tested by rebuilding, and by quick inspection that the include fields
were indeed unnecessary.

gdb/ChangeLog:

	* infcmd.c: Remove includes.
	* infrun.c: Remove includes.

Change-Id: I5e25af54ecd2235960c4127add8f604ddbb19153
---
M gdb/infcmd.c
M gdb/infrun.c
2 files changed, 0 insertions(+), 12 deletions(-)
  

Comments

Simon Marchi (Code Review) Oct. 28, 2019, 12:37 p.m. UTC | #1
Tom Tromey has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/322
......................................................................


Patch Set 1: Code-Review+2

Thanks.  This seems fine to me.

How does include-what-you-use decide if an include is unnecessary?
  
Simon Marchi (Code Review) Oct. 28, 2019, 12:57 p.m. UTC | #2
Simon Marchi has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/322
......................................................................


Patch Set 1:

> Patch Set 1: Code-Review+2
> 
> Thanks.  This seems fine to me.
> 
> How does include-what-you-use decide if an include is unnecessary?

I suppose it compiles the file, makes the list of all symbols/types/macros provided by each header file, makes the list of all symbols/types/macros used in the .c file, and reports if some header file did not contribute anything the .c file used.

I haven't tried, but we might need to be a bit careful when preprocessor #ifs or #ifdefs are involved.  Since it compiles a particular configuration, as described in a compile_commands.json file, I would guess that it only considers what's kept by the preprocessor in this particular configuration.  So it could tell you to remove an include that's actually needed when the other branch of the #ifdef is taken.  Though maybe in that case, the include file should be conditionally included, using that same condition.
  
Simon Marchi (Code Review) Oct. 28, 2019, 1:38 p.m. UTC | #3
Tom Tromey has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/322
......................................................................


Patch Set 1:

> I haven't tried, but we might need to be a bit careful when preprocessor #ifs or #ifdefs are involved.  Since it compiles a particular configuration, as described in a compile_commands.json file, I would guess that it only considers what's kept by the preprocessor in this particular configuration.  So it could tell you to remove an include that's actually needed when the other branch of the #ifdef is taken.  Though maybe in that case, the include file should be conditionally included, using that same condition.

Yeah, I that would be good as well, just because it makes the connection more
explicit.
  
Simon Marchi (Code Review) Oct. 28, 2019, 3:29 p.m. UTC | #4
Konrad Kleine has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/322
......................................................................


Patch Set 1:

LGTM if it still compiles and passes tests. I hesitate to give a +1 though :)
  
Simon Marchi (Code Review) Oct. 28, 2019, 3:51 p.m. UTC | #5
Simon Marchi has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/322
......................................................................


Patch Set 1:

> Patch Set 1:
> 
> I hesitate to give a +1 though :)

Please don't! Or a -1 if you find something to change.
  

Patch

diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 465d3a1..5ca9933 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -19,7 +19,6 @@ 
 
 #include "defs.h"
 #include "arch-utils.h"
-#include <signal.h>
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "frame.h"
@@ -35,8 +34,6 @@ 
 #include "objfiles.h"
 #include "completer.h"
 #include "ui-out.h"
-#include "event-top.h"
-#include "parser-defs.h"
 #include "regcache.h"
 #include "reggroups.h"
 #include "block.h"
@@ -45,7 +42,6 @@ 
 #include "observable.h"
 #include "target-descriptions.h"
 #include "user-regs.h"
-#include "cli/cli-decode.h"
 #include "gdbthread.h"
 #include "valprint.h"
 #include "inline-frame.h"
@@ -53,8 +49,6 @@ 
 #include "inf-loop.h"
 #include "continuations.h"
 #include "linespec.h"
-#include "cli/cli-utils.h"
-#include "infcall.h"
 #include "thread-fsm.h"
 #include "top.h"
 #include "interps.h"
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 66a066f..d8a6eed 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -25,16 +25,13 @@ 
 #include "frame.h"
 #include "inferior.h"
 #include "breakpoint.h"
-#include "gdbsupport/gdb_wait.h"
 #include "gdbcore.h"
 #include "gdbcmd.h"
-#include "cli/cli-script.h"
 #include "target.h"
 #include "gdbthread.h"
 #include "annotate.h"
 #include "symfile.h"
 #include "top.h"
-#include <signal.h>
 #include "inf-loop.h"
 #include "regcache.h"
 #include "value.h"
@@ -42,7 +39,6 @@ 
 #include "language.h"
 #include "solib.h"
 #include "main.h"
-#include "dictionary.h"
 #include "block.h"
 #include "mi/mi-common.h"
 #include "event-top.h"
@@ -51,8 +47,6 @@ 
 #include "inline-frame.h"
 #include "jit.h"
 #include "tracepoint.h"
-#include "continuations.h"
-#include "interps.h"
 #include "skip.h"
 #include "probe.h"
 #include "objfiles.h"