Re: [PATCH 05/40] command.h: Include common/scoped_restore.h

Pedro Alves
2017-06-27T15:46:16Z

On 06/27/2017 01:02 PM, Pedro Alves wrote:

> I should have included this info in the original submission.
> Sorry about that.
>

Here's the same patch with commit log updated to include the missing
info, and also fix the silly typo in the filename in the
subject/ChangeLog.

From 63aba45330a791ab60a79acbe90344c9deb260e9 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Thu, 1 Jun 2017 17:03:11 +0100
Subject: [PATCH 05/40] gdb/command.h: Include common/scoped_restore.h
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

command.h depends on scoped_restore:

extern scoped_restore_tmpl<int> prevent_dont_repeat (void);

But doesn't include the corresponding header
("common/scoped_restore.h"). We haven't noticed a problem because
utils.h includes scoped_restore.h, and defs.h includes utils.h.

However, a patch that makes "symtab.h" include "completer.h", exposed
the issue:
https://sourceware.org/ml/gdb-patches/2017-06/msg00023.html.

Without this fix that would break building all .o files like this:

In file included from src/gdb/completer.h:21:0,
from src/gdb/symtab.h:28,
from src/gdb/language.h:26,
from src/gdb/frame.h:72,
from src/gdb/gdbarch.h:39,
from src/gdb/defs.h:636,
from src/gdb/top.c:20:
src/gdb/command.h:434:8: error: ‘scoped_restore_tmpl’ does not name a type
extern scoped_restore_tmpl<int> prevent_dont_repeat (void);
^
Makefile:1911: recipe for target 'top.o' failed

because defs.h includes gdbarch.h before it includes utils.h.

gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>

* command.h: Include "common/scoped_restore.h".
---
gdb/command.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/gdb/command.h b/gdb/command.h
index aa179e9..4a56a51 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -19,6 +19,7 @@
#define COMMAND_H 1

#include "gdb_vecs.h"
+#include "common/scoped_restore.h"

/* This file defines the public interface for any code wanting to
create commands. */
--
2.5.5