[obis?] Properly declare global variables, deprecate

Andrew Cagney
2004-04-06T19:17:41Z

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

Hello,

This does two things:

- moves declaration of several global variables to the most applicable
header (symtab.h, breakpoints.h)

- marks those global variables as deprecated (they should be no future
uses and existing uses will need to be eliminated)

The objective here is to fix the very immediate "extern in .c file problem".

I'll leave this one for a few days,
Andrew

[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 17594 bytes --]

2004-04-06 Andrew Cagney <cagney@redhat.com>

* breakpoint.h (deprecated_exception_catchpoints_are_fragile)
(deprecated_exception_support_initialized): Declare.
* hppa-hpux-tdep.c (initialize_hp_cxx_exception_support)
(initialize_hp_cxx_exception_support)
(child_enable_exception_callback): Update.
* breakpoint.c (deprecated_exception_catchpoints_are_fragile)
(deprecated_exception_support_initialized): Rename
deprecated_exception_catchpoints_are_fragile and
deprecated_exception_support_initialized.
(breakpoint_init_inferior, breakpoint_init_inferior): Update.

* symtab.c (deprecated_hp_som_som_object_present): Rename
hp_som_som_object_present.
* symtab.h (deprecated_hp_som_som_object_present): Declare.
* symfile.c (hp_som_som_object_present, RESET_HP_UX_GLOBALS):
Update. Delete extern declaration.
* valops.c (hp_som_som_object_present): Ditto.
* parse.c (deprecated_hp_som_som_object_present)
(parse_nested_classes_for_hpacc): Ditto.
* hpread.c (hp_som_som_object_present, hpread_expand_symtab): Ditto.
* hppa-hpux-tdep.c (hp_som_som_object_present)
(initialize_hp_cxx_exception_support): Ditto.
* eval.c (hp_som_som_object_present, evaluate_subexp_standard): Ditto.
* cp-valprint.c (hp_som_som_object_present)
(cp_print_class_method): Ditto.
* c-typeprint.c (hp_som_som_object_present):
(c_type_print_base): Ditto.
* c-exp.y (hp_som_som_object_present): Ditto.

Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.165
diff -u -r1.165 breakpoint.c
--- breakpoint.c 23 Mar 2004 14:47:55 -0000 1.165
+++ breakpoint.c 6 Apr 2004 19:08:57 -0000
@@ -266,13 +266,13 @@
/* Pointer to current exception event record */
static struct exception_event_record *current_exception_event;

-/* Indicator of whether exception catchpoints should be nuked
- between runs of a program */
-int exception_catchpoints_are_fragile = 0;
+/* Indicator of whether exception catchpoints should be nuked between
+ runs of a program. */
+int deprecated_exception_catchpoints_are_fragile = 0;

/* Indicator of when exception catchpoints set-up should be
- reinitialized -- e.g. when program is re-run */
-int exception_support_initialized = 0;
+ reinitialized -- e.g. when program is re-run. */
+int deprecated_exception_support_initialized = 0;

/* This function returns a pointer to the string representation of the
pathname of the dynamically-linked library that has just been
@@ -1636,8 +1636,8 @@
default:
/* Likewise for exception catchpoints in dynamic-linked
executables where required */
- if (ep_is_exception_catchpoint (b) &&
- exception_catchpoints_are_fragile)
+ if (ep_is_exception_catchpoint (b)
+ && deprecated_exception_catchpoints_are_fragile)
{
warning_needed = 1;
delete_breakpoint (b);
@@ -1646,8 +1646,8 @@
}
}

- if (exception_catchpoints_are_fragile)
- exception_support_initialized = 0;
+ if (deprecated_exception_catchpoints_are_fragile)
+ deprecated_exception_support_initialized = 0;

/* Don't issue the warning unless it's really needed... */
if (warning_needed && (context != inf_exited))
Index: breakpoint.h
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.h,v
retrieving revision 1.31
diff -u -r1.31 breakpoint.h
--- breakpoint.h 2 Feb 2004 21:10:49 -0000 1.31
+++ breakpoint.h 6 Apr 2004 19:08:57 -0000
@@ -802,4 +802,13 @@
remove fails. */
extern int remove_hw_watchpoints (void);

+
+/* Indicator of whether exception catchpoints should be nuked between
+ runs of a program. */
+extern int deprecated_exception_catchpoints_are_fragile;
+
+/* Indicator of when exception catchpoints set-up should be
+ reinitialized -- e.g. when program is re-run. */
+extern int deprecated_exception_support_initialized;
+
#endif /* !defined (BREAKPOINT_H) */
Index: c-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/c-exp.y,v
retrieving revision 1.25
diff -u -r1.25 c-exp.y
--- c-exp.y 14 Jan 2004 16:54:40 -0000 1.25
+++ c-exp.y 6 Apr 2004 19:08:57 -0000
@@ -53,9 +53,6 @@
#include "block.h"
#include "cp-support.h"

-/* Flag indicating we're dealing with HP-compiled objects */
-extern int hp_som_som_object_present;
-
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
yacc generated parsers in gdb. Note that these are only the variables
Index: c-typeprint.c
===================================================================
RCS file: /cvs/src/src/gdb/c-typeprint.c,v
retrieving revision 1.30
diff -u -r1.30 c-typeprint.c
--- c-typeprint.c 8 Nov 2003 00:13:02 -0000 1.30
+++ c-typeprint.c 6 Apr 2004 19:08:57 -0000
@@ -38,9 +38,6 @@
#include "gdb_string.h"
#include <errno.h>

-/* Flag indicating target was compiled by HP compiler */
-extern int hp_som_som_object_present;
-
static void cp_type_print_method_args (struct type *mtype, char *prefix,
char *varstring, int staticp,
struct ui_file *stream);
@@ -1078,7 +1075,7 @@
case TYPE_CODE_ENUM:
c_type_print_modifier (type, stream, 0, 1);
/* HP C supports sized enums */
- if (hp_som_som_object_present)
+ if (deprecated_hp_som_som_object_present)
switch (TYPE_LENGTH (type))
{
case 1:
Index: cp-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-valprint.c,v
retrieving revision 1.24
diff -u -r1.24 cp-valprint.c
--- cp-valprint.c 14 Sep 2003 16:32:12 -0000 1.24
+++ cp-valprint.c 6 Apr 2004 19:08:57 -0000
@@ -36,10 +36,6 @@
#include "cp-abi.h"
#include "valprint.h"

-/* Indication of presence of HP-compiled object files */
-extern int hp_som_som_object_present; /* defined in symtab.c */
-
-
int vtblprint; /* Controls printing of vtbl's */
int objectprint; /* Controls looking up an object's derived type
using what we find in its vtables. */
@@ -115,7 +111,7 @@
if (sym == 0)
{
/* 1997-08-01 Currently unsupported with HP aCC */
- if (hp_som_som_object_present)
+ if (deprecated_hp_som_som_object_present)
{
fputs_filtered ("?? <not supported with HP aCC>", stream);
return;
Index: eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.40
diff -u -r1.40 eval.c
--- eval.c 18 Feb 2004 04:22:35 -0000 1.40
+++ eval.c 6 Apr 2004 19:08:57 -0000
@@ -37,9 +37,6 @@
#include "block.h"
#include "parser-defs.h"

-/* Defined in symtab.c */
-extern int hp_som_som_object_present;
-
/* This is defined in valops.c */
extern int overload_resolution;

@@ -972,7 +969,7 @@
/* 1997-08-01 Currently we do not support function invocation
via pointers-to-methods with HP aCC. Pointer does not point
to the function, but possibly to some thunk. */
- if (hp_som_som_object_present)
+ if (deprecated_hp_som_som_object_present)
{
error ("Not implemented: function invocation through pointer to method with HP aCC");
}
@@ -1368,7 +1365,7 @@
arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);

/* With HP aCC, pointers to methods do not point to the function code */
- if (hp_som_som_object_present &&
+ if (deprecated_hp_som_som_object_present &&
(TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_PTR) &&
(TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) == TYPE_CODE_METHOD))
error ("Pointers to methods not supported with HP aCC"); /* 1997-08-19 */
@@ -1381,7 +1378,7 @@
arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);

/* With HP aCC, pointers to methods do not point to the function code */
- if (hp_som_som_object_present &&
+ if (deprecated_hp_som_som_object_present &&
(TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_PTR) &&
(TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) == TYPE_CODE_METHOD))
error ("Pointers to methods not supported with HP aCC"); /* 1997-08-19 */
@@ -1391,7 +1388,7 @@
handle_pointer_to_member:
/* HP aCC generates offsets that have bit #29 set; turn it off to get
a real offset to the member. */
- if (hp_som_som_object_present)
+ if (deprecated_hp_som_som_object_present)
{
if (!mem_offset) /* no bias -> really null */
error ("Attempted dereference of null pointer-to-member");
@@ -1431,7 +1428,7 @@
arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);

/* Do special stuff for HP aCC pointers to members */
- if (hp_som_som_object_present)
+ if (deprecated_hp_som_som_object_present)
{
/* 1997-08-19 Can't assign HP aCC pointers to methods. No details of
the implementation yet; but the pointer appears to point to a code
@@ -1934,7 +1931,7 @@
{
struct value *retvalp = evaluate_subexp_for_address (exp, pos, noside);
/* If HP aCC object, use bias for pointers to members */
- if (hp_som_som_object_present &&
+ if (deprecated_hp_som_som_object_present &&
(TYPE_CODE (VALUE_TYPE (retvalp)) == TYPE_CODE_PTR) &&
(TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (retvalp))) == TYPE_CODE_MEMBER))
{
Index: hppa-hpux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-hpux-tdep.c,v
retrieving revision 1.13
diff -u -r1.13 hppa-hpux-tdep.c
--- hppa-hpux-tdep.c 6 Apr 2004 15:30:18 -0000 1.13
+++ hppa-hpux-tdep.c 6 Apr 2004 19:08:58 -0000
@@ -44,12 +44,6 @@
}
args_for_find_stub;

-/* This is declared in symtab.c; set to 1 in hp-symtab-read.c */
-extern int hp_som_som_object_present;
-
-/* In breakpoint.c */
-extern int exception_catchpoints_are_fragile;
-
/* FIXME: brobecker 2002-12-25. The following functions will eventually
become static, after the multiarching conversion is done. */
int hppa_hpux_pc_in_sigtramp (CORE_ADDR pc, char *name);
@@ -198,8 +192,6 @@
static int hp_cxx_exception_support = 0;
/* Has the initialize function been run? */
int hp_cxx_exception_support_initialized = 0;
-/* Similar to above, but imported from breakpoint.c -- non-target-specific */
-extern int exception_support_initialized;
/* Address of __eh_notify_hook */
static CORE_ADDR eh_notify_hook_addr = 0;
/* Address of __d_eh_notify_callback */
@@ -374,7 +366,7 @@
if (recurse > 0)
{
hp_cxx_exception_support_initialized = 0;
- exception_support_initialized = 0;
+ deprecated_exception_support_initialized = 0;
return 0;
}

@@ -385,7 +377,7 @@
for exception handling debug support will be available!
This will percolate back up to breakpoint.c, where our callers
will decide to try the g++ exception-handling support instead. */
- if (!hp_som_som_object_present)
+ if (!deprecated_hp_som_som_object_present)
return 0;

/* We have a SOM executable with SOM debug info; find the hooks */
@@ -469,7 +461,7 @@
eh_notify_callback_addr = args.return_val;
recurse--;

- exception_catchpoints_are_fragile = 1;
+ deprecated_exception_catchpoints_are_fragile = 1;

if (!eh_notify_callback_addr)
{
@@ -481,7 +473,7 @@
}
}
else
- exception_catchpoints_are_fragile = 0;
+ deprecated_exception_catchpoints_are_fragile = 0;
#endif

/* Now, look for the breakpointable routine in end.o */
@@ -556,7 +548,7 @@
/* Set the flags */
hp_cxx_exception_support = 2; /* everything worked so far */
hp_cxx_exception_support_initialized = 1;
- exception_support_initialized = 1;
+ deprecated_exception_support_initialized = 1;

return 1;
}
@@ -575,7 +567,8 @@
{
char buf[4];

- if (!exception_support_initialized || !hp_cxx_exception_support_initialized)
+ if (!deprecated_exception_support_initialized
+ || !hp_cxx_exception_support_initialized)
if (!initialize_hp_cxx_exception_support ())
return NULL;

Index: hpread.c
===================================================================
RCS file: /cvs/src/src/gdb/hpread.c,v
retrieving revision 1.45
diff -u -r1.45 hpread.c
--- hpread.c 7 Feb 2004 23:13:47 -0000 1.45
+++ hpread.c 6 Apr 2004 19:08:58 -0000
@@ -238,11 +238,6 @@
(int, dnttpointer, union dnttentry **, struct objfile *);

\f
-/* Global to indicate presence of HP-compiled objects,
- in particular, SOM executable file with SOM debug info
- Defined in symtab.c, used in hppa-tdep.c. */
-extern int hp_som_som_object_present;
-
/* Static used to indicate a class type that requires a
fix-up of one of its method types */
static struct type *fixup_class = NULL;
@@ -2875,7 +2870,7 @@
}

current_objfile = NULL;
- hp_som_som_object_present = 1; /* Indicate we've processed an HP SOM SOM file */
+ deprecated_hp_som_som_object_present = 1; /* Indicate we've processed an HP SOM SOM file */

return end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT (objfile));
}
Index: infttrace.c
===================================================================
RCS file: /cvs/src/src/gdb/infttrace.c,v
retrieving revision 1.30
diff -u -r1.30 infttrace.c
--- infttrace.c 6 Apr 2004 18:29:09 -0000 1.30
+++ infttrace.c 6 Apr 2004 19:08:58 -0000
@@ -1,7 +1,7 @@
/* Low level Unix child interface to ttrace, for GDB when running under HP-UX.
- Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998,
- 1999, 2000, 2001, 2003
- Free Software Foundation, Inc.
+
+ Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
+ 1998, 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.

This file is part of GDB.

Index: parse.c
===================================================================
RCS file: /cvs/src/src/gdb/parse.c,v
retrieving revision 1.39
diff -u -r1.39 parse.c
--- parse.c 15 Feb 2004 15:22:06 -0000 1.39
+++ parse.c 6 Apr 2004 19:08:58 -0000
@@ -95,8 +95,6 @@
\f
static int expressiondebug = 0;

-extern int hp_som_som_object_present;
-
static void free_funcalls (void *ignore);

static void prefixify_expression (struct expression *);
@@ -590,7 +588,7 @@
return NULL, and caller must default to standard GDB
behaviour. */

- if (!hp_som_som_object_present)
+ if (!deprecated_hp_som_som_object_present)
return (struct symbol *) NULL;

p = name;
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.124
diff -u -r1.124 symfile.c
--- symfile.c 28 Feb 2004 18:04:37 -0000 1.124
+++ symfile.c 6 Apr 2004 19:08:59 -0000
@@ -65,10 +65,9 @@
/* Some HP-UX related globals to clear when a new "main"
symbol file is loaded. HP-specific. */

-extern int hp_som_som_object_present;
extern int hp_cxx_exception_support_initialized;
#define RESET_HP_UX_GLOBALS() do {\
- hp_som_som_object_present = 0; /* indicates HP-compiled code */ \
+ deprecated_hp_som_som_object_present = 0; /* indicates HP-compiled code */ \
hp_cxx_exception_support_initialized = 0; /* must reinitialize exception stuff */ \
} while (0)
#endif
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.128
diff -u -r1.128 symtab.c
--- symtab.c 19 Feb 2004 19:01:26 -0000 1.128
+++ symtab.c 6 Apr 2004 19:08:59 -0000
@@ -114,9 +114,9 @@
struct symtab **symtab);
#endif

-/* This flag is used in hppa-tdep.c, and set in hp-symtab-read.c */
-/* Signals the presence of objects compiled by HP compilers */
-int hp_som_som_object_present = 0;
+/* This flag is used in hppa-tdep.c, and set in hp-symtab-read.c.
+ Signals the presence of objects compiled by HP compilers. */
+int deprecated_hp_som_som_object_present = 0;

static void fixup_section (struct general_symbol_info *, struct objfile *);

Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.89
diff -u -r1.89 symtab.h
--- symtab.h 16 Mar 2004 20:25:24 -0000 1.89
+++ symtab.h 6 Apr 2004 19:08:59 -0000
@@ -1362,4 +1362,9 @@
extern void set_main_name (const char *name);
extern /*const */ char *main_name (void);

+/* Global to indicate presence of HP-compiled objects,
+ in particular, SOM executable file with SOM debug info
+ Defined in symtab.c, used in hppa-tdep.c. */
+extern int deprecated_hp_som_som_object_present;
+
#endif /* !defined(SYMTAB_H) */
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.121
diff -u -r1.121 valops.c
--- valops.c 2 Feb 2004 20:44:52 -0000 1.121
+++ valops.c 6 Apr 2004 19:08:59 -0000
@@ -43,10 +43,6 @@
#include "gdb_assert.h"
#include "cp-support.h"

-/* Flag indicating HP compilers were used; needed to correctly handle some
- value operations with HP aCC code/runtime. */
-extern int hp_som_som_object_present;
-
extern int overload_debug;
/* Local functions. */

@@ -299,8 +295,8 @@
{
LONGEST longest;

- if (hp_som_som_object_present && /* if target compiled by HP aCC */
- (code2 == TYPE_CODE_PTR))
+ if (deprecated_hp_som_som_object_present /* if target compiled by HP aCC */
+ && (code2 == TYPE_CODE_PTR))
{
unsigned int *ptr;
struct value *retvalp;