* [RFA]: Turn on Ada support
@ 2004-06-08 9:08 Paul Hilfinger
2004-06-08 22:15 ` Eli Zaretskii
2004-06-09 7:24 ` Jim Blandy
0 siblings, 2 replies; 21+ messages in thread
From: Paul Hilfinger @ 2004-06-08 9:08 UTC (permalink / raw)
To: gdb-patches
While I am chewing away at the requested mongo ChangeLog entry for
the Ada sources, here is something for others to chew on. The proposed
patch below turns on basic Ada support, expression evaluation specifically.
There are still many additional pieces of functionality to move into the
public sources for Ada tasking, exceptions, and breakpoints in generic
instances especially. However, this is enough to be a coherent piece.
Eli, I have also included the relevant extract from our gdb.texinfo file.
Not being sure how you'd like this handled, I have kept all our section
headers and inserted little bracketed comments to indicate missing portions.
Paul Hilfinger
ACT, Inc.
gdb/ChangeLog:
2004-06-03 Paul N. Hilfinger <Hilfinger@gnat.com>
Turn on initial Ada support (mainly expression evaluation).
* Makefile.in (ada_lex_c): Define
(HFILES_NO_SRCDIR): Add ada-lang.h.
(COMMON_OBS): Add ada-lang.o, ada-typeprint.o, ada-valprint.o,
ada-tasks.o.
(YYOBJ): Add ada-exp.o.
(rule .l.c): Generalize to not mention ada.
(ada-lex.o): Remove (ada-lex.c is included by ada-exp.y).
(ada-lang.o): Add dependencies on completer.h, gdb_obstack.h,
hashtab.h.
(ada-tasks.o): Add dependency on gdb_string.h.
(ada-valprint.o): Add dependency on gdb_string.h.
* symtab.c: Add dependency on ada-lang.h.
(symbol_natural_name): Add Ada case.
(symbol_demangled_name): Add Ada case.
(symbol_search_name): Add Ada case.
* symfile.c (init_filename_language_table): Add extensions for
Ada.
* defs.h (enum language): Add language_ada.
* gdbtypes.h (TYPE_FLAG_FIXED_INSTANCE): Define.
gdb/doc/ChangeLog:
2004-06-08 Paul N. Hilfinger <hilfinger@gnat.com>
* gdb.texinfo (Filenames): Add Ada suffixes.
(Ada) New section.
Index: current-public.74/gdb/Makefile.in
--- current-public.74/gdb/Makefile.in Mon, 07 Jun 2004 23:35:41 -0700
+++ submit.74(w)/gdb/Makefile.in Mon, 07 Jun 2004 23:44:02 -0700
@@ -616,6 +616,7 @@ nm_h = @nm_h@
# gdb/ headers
#
+ada_lex_c = ada-lex.c
ada_lang_h = ada-lang.h $(value_h) $(gdbtypes_h)
alphabsd_tdep_h = alphabsd-tdep.h
alpha_tdep_h = alpha-tdep.h
@@ -833,7 +834,7 @@ HFILES_NO_SRCDIR = bcache.h buildsym.h c
symfile.h symfile-mem.h stabsread.h target.h terminal.h typeprint.h \
xcoffsolib.h \
macrotab.h macroexp.h macroscope.h \
- c-lang.h f-lang.h \
+ ada-lang.h c-lang.h f-lang.h \
jv-lang.h \
m2-lang.h p-lang.h \
complaints.h valprint.h \
@@ -894,7 +895,7 @@ COMMON_OBS = $(DEPFILES) $(YYOBJ) \
dbxread.o coffread.o coff-pe-read.o elfread.o \
dwarfread.o dwarf2read.o mipsread.o stabsread.o corefile.o \
dwarf2expr.o dwarf2loc.o dwarf2-frame.o \
- c-lang.o f-lang.o objc-lang.o \
+ ada-lang.o c-lang.o f-lang.o objc-lang.o \
ui-out.o cli-out.o \
varobj.o wrapper.o \
jv-lang.o jv-valprint.o jv-typeprint.o \
@@ -902,8 +903,9 @@ COMMON_OBS = $(DEPFILES) $(YYOBJ) \
scm-exp.o scm-lang.o scm-valprint.o \
sentinel-frame.o \
complaints.o typeprint.o \
- c-typeprint.o f-typeprint.o m2-typeprint.o \
- c-valprint.o cp-valprint.o f-valprint.o m2-valprint.o \
+ ada-typeprint.o c-typeprint.o f-typeprint.o m2-typeprint.o \
+ ada-valprint.o c-valprint.o cp-valprint.o f-valprint.o m2-valprint.o \
+ ada-tasks.o \
nlmread.o serial.o mdebugread.o top.o utils.o \
ui-file.o \
user-regs.o \
@@ -927,6 +929,7 @@ YYFILES = c-exp.c \
f-exp.c m2-exp.c p-exp.c
YYOBJ = c-exp.o \
objc-exp.o \
+ ada-exp.o \
jv-exp.o \
f-exp.o m2-exp.o p-exp.o
@@ -1495,7 +1498,7 @@ valprint.o: $(srcdir)/valprint.c
echo $(FLEX) -Isit $< ">" $@; \
$(FLEX) -Isit $< > $@; \
elif [ ! -f $@ -a ! -f $< ]; then \
- echo "ada-lex.c missing and flex not available."; \
+ echo "$< missing and flex not available."; \
false; \
elif [ ! -f $@ ]; then \
echo "Warning: $*.c older than $*.l and flex not available."; \
@@ -1522,18 +1525,18 @@ ada-lang.o: ada-lang.c $(gdb_string_h) $
$(gdbtypes_h) $(gdbcmd_h) $(expression_h) $(parser_defs_h) \
$(language_h) $(c_lang_h) $(inferior_h) $(symfile_h) $(objfiles_h) \
$(breakpoint_h) $(gdbcore_h) $(ada_lang_h) $(ui_out_h) $(block_h) \
- $(infcall_h) $(dictionary_h)
-ada-lex.o: ada-lex.c
+ $(completer_h) $(infcall_h) $(gdb_obstack_h) $(dictionary_h) \
+ $(hashtab_h)
ada-tasks.o: ada-tasks.c $(defs_h) $(command_h) $(value_h) $(language_h) \
$(inferior_h) $(symtab_h) $(target_h) $(regcache_h) $(gdbcore_h) \
- $(gregset_h) $(ada_lang_h)
+ $(gregset_h) $(gdb_string_h) $(ada_lang_h)
ada-typeprint.o: ada-typeprint.c $(defs_h) $(gdb_obstack_h) $(bfd_h) \
$(symtab_h) $(gdbtypes_h) $(expression_h) $(value_h) $(gdbcore_h) \
$(target_h) $(command_h) $(gdbcmd_h) $(language_h) $(demangle_h) \
$(c_lang_h) $(typeprint_h) $(ada_lang_h) $(gdb_string_h)
ada-valprint.o: ada-valprint.c $(defs_h) $(symtab_h) $(gdbtypes_h) \
$(expression_h) $(value_h) $(demangle_h) $(valprint_h) $(language_h) \
- $(annotate_h) $(ada_lang_h) $(c_lang_h) $(infcall_h)
+ $(annotate_h) $(ada_lang_h) $(c_lang_h) $(gdb_string_h) $(infcall_h)
aix-thread.o: aix-thread.c $(defs_h) $(gdb_assert_h) $(gdbthread_h) \
$(target_h) $(inferior_h) $(regcache_h) $(gdbcmd_h) $(language_h) \
$(ppc_tdep_h) $(gdb_string_h)
Index: current-public.74/gdb/defs.h
--- current-public.74/gdb/defs.h Wed, 12 May 2004 23:26:12 -0700
+++ submit.74(w)/gdb/defs.h Thu, 13 May 2004 00:19:44 -0700
@@ -220,6 +220,7 @@ enum language
language_asm, /* Assembly language */
language_scm, /* Scheme / Guile */
language_pascal, /* Pascal */
+ language_ada, /* Ada */
language_minimal /* All other languages, minimal support only */
};
Index: current-public.74/gdb/gdbtypes.h
--- current-public.74/gdb/gdbtypes.h Thu, 03 Jun 2004 00:14:01 -0700
+++ submit.74(w)/gdb/gdbtypes.h Thu, 03 Jun 2004 01:21:04 -0700
@@ -273,6 +273,17 @@ enum type_code
#define TYPE_ADDRESS_CLASS_ALL(t) (TYPE_INSTANCE_FLAGS(t) \
& TYPE_FLAG_ADDRESS_CLASS_ALL)
+/* The debugging formats (especially STABS) do not contain enough information
+ to represent all Ada types---especially those whose size depends on
+ dynamic quantities. Therefore, the GNAT Ada compiler includes
+ extra information in the form of additional type definitions
+ connected by naming conventions. This flag indicates that the
+ type is an ordinary (unencoded) GDB type that has been created from
+ the necessary run-time information, and does not need further
+ interpretation. Optionally marks ordinary, fixed-size GDB type. */
+
+#define TYPE_FLAG_FIXED_INSTANCE (1 << 15)
+
/* Array bound type. */
enum array_bound_type
{
Index: current-public.74/gdb/symfile.c
--- current-public.74/gdb/symfile.c Fri, 21 May 2004 00:57:36 -0700
+++ submit.74(w)/gdb/symfile.c Fri, 21 May 2004 01:38:26 -0700
@@ -2180,6 +2180,10 @@ init_filename_language_table (void)
add_filename_language (".pas", language_pascal);
add_filename_language (".p", language_pascal);
add_filename_language (".pp", language_pascal);
+ add_filename_language (".adb", language_ada);
+ add_filename_language (".ads", language_ada);
+ add_filename_language (".a", language_ada);
+ add_filename_language (".ada", language_ada);
}
}
Index: current-public.74/gdb/symtab.c
--- current-public.74/gdb/symtab.c Tue, 25 May 2004 01:48:02 -0700
+++ submit.74(w)/gdb/symtab.c Mon, 07 Jun 2004 01:49:15 -0700
@@ -41,6 +41,7 @@
#include "source.h"
#include "filenames.h" /* for FILENAME_CMP */
#include "objc-lang.h"
+#include "ada-lang.h"
#include "hashtab.h"
@@ -632,17 +633,30 @@ symbol_init_demangled_name (struct gener
char *
symbol_natural_name (const struct general_symbol_info *gsymbol)
{
- if ((gsymbol->language == language_cplus
- || gsymbol->language == language_java
- || gsymbol->language == language_objc)
- && (gsymbol->language_specific.cplus_specific.demangled_name != NULL))
+ switch (gsymbol->language)
{
- return gsymbol->language_specific.cplus_specific.demangled_name;
- }
- else
- {
- return gsymbol->name;
+ case language_cplus:
+ case language_java:
+ case language_objc:
+ if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
+ {
+ return gsymbol->language_specific.cplus_specific.demangled_name;
+ }
+ break;
+ case language_ada:
+ if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
+ {
+ return gsymbol->language_specific.cplus_specific.demangled_name;
+ }
+ else
+ {
+ return ada_decode_symbol (gsymbol);
+ }
+ break;
+ default:
+ break;
}
+ return gsymbol->name;
}
/* Return the demangled name for a symbol based on the language for
@@ -650,13 +664,30 @@ symbol_natural_name (const struct genera
char *
symbol_demangled_name (struct general_symbol_info *gsymbol)
{
- if (gsymbol->language == language_cplus
- || gsymbol->language == language_java
- || gsymbol->language == language_objc)
- return gsymbol->language_specific.cplus_specific.demangled_name;
-
- else
- return NULL;
+ switch (gsymbol->language)
+ {
+ case language_cplus:
+ case language_java:
+ case language_objc:
+ if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
+ {
+ return gsymbol->language_specific.cplus_specific.demangled_name;
+ }
+ break;
+ case language_ada:
+ if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
+ {
+ return gsymbol->language_specific.cplus_specific.demangled_name;
+ }
+ else
+ {
+ return ada_decode_symbol (gsymbol);
+ }
+ break;
+ default:
+ break;
+ }
+ return NULL;
}
/* Return the search name of a symbol---generally the demangled or
@@ -664,7 +695,10 @@ symbol_demangled_name (struct general_sy
If there is no distinct demangled name, then returns the same value
(same pointer) as SYMBOL_LINKAGE_NAME. */
char *symbol_search_name (const struct general_symbol_info *gsymbol) {
- return symbol_natural_name (gsymbol);
+ if (gsymbol->language == language_ada)
+ return gsymbol->name;
+ else
+ return symbol_natural_name (gsymbol);
}
Index: current-public.74/gdb/doc/gdb.texinfo
--- current-public.74/gdb/doc/gdb.texinfo Tue, 25 May 2004 01:48:02 -0700
+++ submit.74(w)/gdb/doc/gdb.texinfo Tue, 08 Jun 2004 01:02:28 -0700
@@ -7741,6 +7741,11 @@ If a source file name ends in one of the
@value{GDBN} infers that its language is the one indicated.
@table @file
+@item .ada
+@itemx .ads
+@itemx .adb
+@itemx .a
+Ada source file.
@item .c
C source file
@@ -8031,7 +8036,7 @@ being set automatically by @value{GDBN}.
@node Support
@section Supported languages
-@value{GDBN} supports C, C@t{++}, Objective-C, Fortran, Java, assembly, and Modula-2.
+@value{GDBN} supports C, C@t{++}, Objective-C, Fortran, Java, assembly, Modula-2, and Ada.
@c This is false ...
Some @value{GDBN} features may be used in expressions regardless of the
language you use: the @value{GDBN} @code{@@} and @code{::} operators,
@@ -8051,6 +8056,7 @@ language reference or tutorial.
* C:: C and C@t{++}
* Objective-C:: Objective-C
* Modula-2:: Modula-2
+* Ada:: Ada
@end menu
@node C
@@ -8666,7 +8672,7 @@ the description of an object. However,
with certain Objective-C libraries that have a particular hook
function, @code{_NSPrintForDebugger}, defined.
-@node Modula-2, , Objective-C, Support
+@node Modula-2, Ada, Objective-C, Support
@subsection Modula-2
@cindex Modula-2, @value{GDBN} support
@@ -9108,6 +9114,498 @@ address can be specified by an integral
@cindex @code{#} in Modula-2
In @value{GDBN} scripts, the Modula-2 inequality operator @code{#} is
interpreted as the beginning of a comment. Use @code{<>} instead.
+
+@node Ada
+@subsection Ada
+@cindex Ada
+
+The extensions made to @value{GDBN} for Ada only support
+output from the @sc{gnu} Ada (GNAT) compiler.
+Other Ada compilers are not currently supported, and
+attempting to debug executables produced by them is most likely
+to be difficult.
+
+
+@cindex expressions in Ada
+@menu
+* Ada Mode Intro:: General remarks on the Ada syntax
+ and semantics supported by Ada mode
+ in @value{GDBN}
+* Omissions from Ada:: Restrictions on the Ada expression syntax.
+* Additions to Ada:: Extensions of the Ada expression syntax.
+* Stopping Before Main Program:: Debugging the program during elaboration.
+* Ada Exceptions:: Setting breakpoints on exception handlers.
+* Ada Tasks:: Listing and setting breakpoints in tasks.
+* Ada Tasks and Core Files:: Tasking Support when Debugging Core Files
+* Ada Generic Units:: Dealing with generic instantiations.
+* Ada Set Commands:: New settable GDB parameters for Ada.
+* Ada Glitches:: Known peculiarities of Ada mode.
+@end menu
+
+@node Ada Mode Intro
+@subsubsection Introduction
+@cindex Ada mode, general
+
+The Ada mode of @value{GDBN} supports a fairly large subset of Ada expression
+syntax, with some extensions.
+The philosophy behind the design of this subset is
+
+@itemize @bullet
+@item
+That @value{GDBN} should provide basic literals and access to operations for
+arithmetic, dereferencing, field selection, indexing, and subprogram calls,
+leaving more sophisticated computations to subprograms written into the
+program (which therefore may be called from @value{GDBN}).
+
+@item
+That type safety and strict adherence to Ada language restrictions
+are not particularly important to the @value{GDBN} user.
+
+@item
+That brevity is important to the @value{GDBN} user.
+@end itemize
+
+Thus, for brevity, the debugger acts as if there were
+implicit @code{with} and @code{use} clauses in effect for all user-written
+packages, making it unnecessary to fully qualify most names with
+their packages, regardless of context. Where this causes ambiguity,
+@value{GDBN} asks the user's intent.
+
+The debugger will start in Ada mode if it detects an Ada main program.
+As for other languages, it will enter Ada mode when stopped in a program that
+was translated from an Ada source file.
+
+While in Ada mode, you may use `@t{-}@t{-}' for comments. This is useful
+mostly for documenting command files. The standard @value{GDBN} comment
+(@code{#}) still works at the beginning of a line in Ada mode, but not in the
+middle (to allow based literals).
+
+The debugger supports limited overloading. Given a subprogram call in which
+the function symbol has multiple definitions, it will use the number of
+actual parameters and some information about their types to attempt to narrow
+the set of definitions. It also makes very limited use of context, preferring
+procedures to functions in the context of the @code{call} command, and
+functions to procedures elsewhere.
+
+@node Omissions from Ada
+@subsubsection Omissions from Ada
+@cindex Ada, omissions from
+
+Here are the notable omissions from the subset:
+
+@itemize @bullet
+@item
+Only a subset of the attributes are supported:
+
+@itemize @minus
+@item
+@t{'First}, @t{'Last}, and @t{'Length}
+ on array objects (not on types and subtypes).
+
+@item
+@t{'Min} and @t{'Max}.
+
+@item
+@t{'Pos} and @t{'Val}.
+
+@item
+@t{'Tag}.
+
+@item
+@t{'Range} on array objects (not subtypes), but only as the right
+operand of the membership (@code{in}) operator.
+
+@item
+@t{'Access}, @t{'Unchecked_Access}, and
+@t{'Unrestricted_Access} (a GNAT extension).
+
+@item
+@t{'Address}.
+@end itemize
+
+@item
+The names in
+@code{Characters.Latin_1} are not available and
+concatenation is not implemented. Thus, escape characters in strings are
+not currently available.
+
+@item
+Equality tests (@code{=} and @code{/=}) on arrays test for bitwise
+equality of representations. They will generally work correctly
+for strings and arrays whose elements have integer or enumeration types.
+They may not work correctly for arrays whose element
+types have user-defined equality, for arrays of real values
+(in particular, IEEE-conformant floating point, because of negative
+zeroes and NaNs), and for arrays whose elements contain unused bits with
+indeterminate values.
+
+@item
+The other component-by-component array operations (@b{and}, @b{or},
+@b{xor}, @b{not}, and relational tests other than equality)
+are not implemented.
+
+@item
+There are no record or array aggregates.
+
+@item
+Dispatching subprogram calls are not implemented.
+
+@item
+The overloading algorithm is much more limited (i.e., less selective)
+than that of real Ada. It makes only limited use of the context in which a subexpression
+appears to resolve its meaning, and it is much looser in its rules for allowing
+type matches. As a result, some function calls will be ambiguous, and the user
+will be asked to choose the proper resolution.
+
+@item
+The @b{new} operator is not implemented.
+
+@item
+Entry calls are not implemented.
+
+@item
+Aside from printing, arithmetic operations on the native VAX floating-point
+formats are not supported.
+
+@item
+It is not possible to slice a packed array.
+@end itemize
+
+@node Additions to Ada
+@subsubsection Additions to Ada
+@cindex Ada, deviations from
+
+As it does for other languages, @value{GDBN} makes certain generic
+extensions to Ada (@pxref{Expressions}):
+
+@itemize @bullet
+@item
+If the expression @var{E} is a variable residing in memory
+(typically a local variable or array element) and @var{N} is
+a positive integer, then @code{@var{E}@@@var{N}} displays the values of
+@var{E} and the @var{N}-1 adjacent variables following it in memory as an array.
+In Ada, this operator is generally not necessary, since its prime use
+is in displaying parts of an array, and slicing will usually do this in Ada.
+However, there are occasional uses when debugging programs
+in which certain debugging information has been optimized away.
+
+@item
+@code{@var{B}::@var{var}} means ``the variable named @var{var} that appears
+in function or file @var{B}.'' When @var{B} is a file name, you must typically
+surround it in single quotes.
+
+@item
+The expression @code{@{@var{type}@} @var{addr}} means ``the variable of type
+@var{type} that appears at address @var{addr}.''
+
+@item
+A name starting with @code{$} is a convenience variable
+(@pxref{Convenience Vars}) or a machine register (@pxref{Registers}).
+@end itemize
+
+In addition, GDB provides a few other shortcuts and outright additions specific
+to Ada:
+
+@itemize @bullet
+@item
+The assignment statement is allowed as an expression, returning
+its right-hand operand as its value. Thus, you may enter
+
+@example
+set x := y + 3
+print A(tmp := y + 1)
+@end example
+
+@item
+The semicolon is allowed as an ``operator,'' returning as its value
+the value of its right-hand operand.
+This allows, for example,
+complex conditional breaks:
+
+@example
+break f
+condition 1 (report(i); k += 1; A(k) > 100)
+@end example
+
+@item
+Rather than use catenation and symbolic character names to introduce special
+characters into strings, one may instead use a special bracket notation,
+which is also used to print strings. A sequence of characters of the form
+@samp{["@var{XX}"]} within a string or character literal denotes the
+(single) character whose numeric encoding is @var{XX} in hexadecimal. The
+sequence of characters @samp{["""]} also denotes a single quotation mark
+in strings. For example,
+@example
+ "One line.["0a"]Next line.["0a"]"
+@end example
+Contains an ASCII newline character (Ada.Characters.Latin_1.LF) after each
+period.
+
+@item
+The subtype used as a prefix for the attributes @t{'Pos}, @t{'Min}, and
+@t{'Max} is optional (and is ignored in any case). For example, it is legal
+to write
+
+@example
+print 'max(x, y)
+@end example
+
+@item
+When printing arrays, @value{GDBN} uses positional notation when the
+array has a lower bound of 1, and uses a modified named notation otherwise.
+For example, a one-dimensional array of three integers with a lower bound of 3 might print as
+
+@example
+(3 => 10, 17, 1)
+@end example
+
+@noindent
+That is, in contrast to valid Ada, only the first component has a @code{=>}
+clause.
+
+@item
+You may abbreviate attributes in expressions with any unique,
+multi-character subsequence of
+their names (an exact match gets preference).
+For example, you may use @code{a'len}, @code{a'gth}, or @code{a'lh}
+in place of @code{a'length}.
+
+@item
+Since Ada is case-insensitive, the debugger normally maps identifiers you type
+to lower case. The GNAT compiler uses upper-case characters for
+some of its internal identifiers, which are normally of no interest to users.
+For the rare occasions when you actually have to look at them,
+enclose them in angle brackets to avoid the lower-case mapping.
+For example,
+@example
+(gdb) print <JMPBUF_SAVE>[0]
+@end example
+
+@item
+Printing an object of class-wide type or dereferencing an
+access-to-class-wide value will display all the components of the object's
+specific type (as indicated by its run-time tag). Likewise, component
+selection on such a value will operate on the specific type of the
+object.
+
+@end itemize
+
+@node Stopping Before Main Program
+@subsubsection Stopping at the Very Beginning
+
+It is sometimes necessary to debug the program during elaboration, and
+before reaching the main procedure.
+As defined in the Ada Reference
+Manual, the elaboration code is invoked from a procedure called
+@code{adainit}. To start your program until the beginning of the
+elaboration, simply use the following two commands:
+@code{tbreak adainit} and @code{run}.
+
+@node Ada Exceptions
+@subsubsection Breaking on Ada Exceptions
+@cindex Ada, exceptions
+
+In Ada mode, you can set breakpoints that trip when your program raises
+selected exceptions.
+
+@table @code
+@item break exception
+Set a breakpoint that trips whenever (any task in the) program raises
+any exception.
+
+@item break exception @var{name}
+Set a breakpoint that trips whenever (any task in the) program raises
+the exception @var{name}.
+
+When inserting a breakpoint on a specific exception for which an
+homonym entity exists in the application, it is necessary to prefix
+the exception name with its package name. In particular, if an entity
+sharing the same name as one of the standard exceptions has been defined,
+the exception name must be prefixed with package @code{Standard} when
+setting a breakpoint on this exception.
+
+@smallexample
+@iftex
+@leftskip=0.5cm
+@end iftex
+(gdb) break exception Standard.Constraint_Error
+@end smallexample
+
+@item break exception unhandled
+Set a breakpoint that trips whenever (any task in the) program raises an
+exception for which there is no handler.
+At the moment,
+depending on the implementation of exceptions used on your platform,
+this may not have quite the desired effect. Other forms of
+exception breaking stop the program at the point the exception is raised.
+On Ada implementations that use setjmp and longjmp to implement exception
+handling, however, unhandled exceptions are not detected until the
+affected task's stack is completely unwound. Thus, you find out that a
+task has terminated with an exception, but you aren't told where it was
+raised.
+
+@kindex info exceptions
+@item info exceptions
+@itemx info exceptions @var{regexp}
+The @code{info exceptions} command permits the user to examine all defined
+exceptions within Ada programs. With a regular expression, @var{regexp}, as
+argument, prints out only those exceptions whose name matches @var{regexp}.
+@end table
+
+@node Ada Tasks
+@subsubsection Extensions for Ada Tasks
+@cindex Ada, tasking
+
+[This section is not yet applicable to the public version.]
+
+@node Ada Tasks and Core Files
+@subsubsection Tasking Support when Debugging Core Files
+@cindex Ada, tasking, core
+
+[This section is not yet applicable to the public version.]
+
+@node Ada Generic Units
+@subsubsection Debugging Generic Units
+@cindex Ada, generic units
+
+[This section is only partially implemented in the current public version.]
+
+GNAT always uses code expansion for generic instantiation. This means that
+each time an instantiation occurs, a complete copy of the original code is
+made with appropriate substitutions.
+
+It is not possible to refer to the original generic entities themselves
+in GDB (there is no code to refer to), but it
+is certainly possible to debug a particular instance of a generic, simply by
+using the appropriate expanded names. For example, suppose that
+@code{Gen} is a generic package:
+
+@smallexample
+-- In file gen.ads:
+generic package Gen is
+ function F (v1 : Integer) return Integer;
+end Gen;
+
+-- In file gen.adb:
+package body Gen is
+ function F (v1 : Integer) return Integer is
+ begin
+ return v1+1; -- Line 5
+ end F;
+end Gen;
+@end smallexample
+
+@noindent
+and we have the following expansions
+
+@smallexample
+with Gen;
+procedure G is
+ package Gen1 is new Gen;
+ package Gen2 is new Gen;
+
+ I : Integer := 0;
+begin
+ I := Gen1.F (I);
+ I := Gen2.F (I);
+ I := Gen1.F (I);
+ I := Gen2.F (I);
+end;
+@end smallexample
+
+@noindent
+Then to break on a call to procedure @code{F} in the @code{Gen2} instance, simply
+use the command:
+
+@example
+break G.Gen2.F
+@end example
+
+When a breakpoint occurs, you can step through the code of the generic
+instance in the normal manner. You can also examine values of data in the
+normal manner, providing the appropriate generic package qualification to
+refer to non-local entities.
+
+@node Ada Set Commands
+@subsubsection Set commands for Ada
+
+[This section is not yet applicable to the public version.]
+
+@node Ada Glitches
+@subsubsection Known Peculiarities of Ada Mode
+@cindex Ada, problems
+
+Besides the omissions listed previously (@pxref{Omissions from Ada}),
+we know of several problems with and limitations of Ada mode in @value{GDBN},
+some of which will be fixed with planned future releases of the debugger
+and the GNU Ada compiler.
+
+@itemize @bullet
+@item
+Currently, the debugger
+has insufficient information to determine whether certain pointers represent
+pointers to objects or the objects themselves.
+Thus, the user may have to tack an extra @b{.all} after an expression
+to get it printed properly.
+
+@item
+Static constants that the compiler chooses not to materialize as objects in
+storage are invisible to the debugger.
+
+@item
+Named parameter associations in function argument lists are ignored (the
+argument lists are treated as positional).
+
+@item
+Many useful library packages are currently invisible to the debugger.
+
+@item
+Fixed-point arithmetic, conversions, input, and output is carried out using
+floating-point arithmetic, and may give results that only approximate those on
+the host machine.
+
+@item
+The type of the @t{'Address} attribute may not be @t{System.Address}.
+
+@item
+When stopped in a particular subprogram, you can access variables defined
+in other, lexically
+enclosing subprograms by their simple names. At the moment, however, this
+may not always work; it depends on whether the compiler happens to have
+made the necessary information (the ``static link'') available
+at execution time, which it can sometimes avoid. Of course,
+even in those cases where
+the compiler does not provide the information, you can still look at such
+variables by issuing the appropriate number of @code{up} commands to get to
+frame containing the variable you wish to see.
+Access to non-local variables does not, at the moment, work in
+the test expressions for conditional breakpoints
+(@pxref{Conditions, ,Break conditions}) unless you happen to specify these
+while stopped in the subprogram in which they are to be applied.
+
+@item
+Depending on the platform, it is not always possible to set breakpoints
+on nested functions by name (e.g., @code{break foo}). In effect, the
+nested functions act like local variables of the enclosing function.
+On these platforms, you must wait until @value{GDBN} is stopped in
+the enclosing function before using this form of @code{break} command.
+This is not much of a limitation, since you can still set a breakpoint on
+the first line of the desired function using the usual
+@code{break @var{file}:@var{line}} syntax.
+
+@item
+The GNAT compiler never generates the prefix @code{Standard} for any of
+the standard symbols defined by the Ada language. @value{GDBN} knows about
+this: it will strip the prefix from names when you use it, and will never
+look for a name you have so qualified among local symbols, nor match against
+symbols in other packages or subprograms. If you have
+defined entities anywhere in your program other than parameters and
+local variables whose simple names match names in @code{Standard},
+GNAT's lack of qualification here can cause confusion. When this happens,
+you can usually resolve the confusion
+by qualifying the problematic names with package
+@code{Standard} explicitly.
+@end itemize
@node Unsupported languages
@section Unsupported languages
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [RFA]: Turn on Ada support 2004-06-08 9:08 [RFA]: Turn on Ada support Paul Hilfinger @ 2004-06-08 22:15 ` Eli Zaretskii 2004-06-09 9:23 ` Paul Hilfinger 2004-06-09 7:24 ` Jim Blandy 1 sibling, 1 reply; 21+ messages in thread From: Eli Zaretskii @ 2004-06-08 22:15 UTC (permalink / raw) To: Paul Hilfinger; +Cc: gdb-patches > From: Paul Hilfinger <hilfingr@gnat.com> > Date: Tue, 8 Jun 2004 05:07:58 -0400 (EDT) > > Eli, I have also included the relevant extract from our gdb.texinfo file. Thanks. A few minor comments are below. > Not being sure how you'd like this handled, I have kept all our section > headers and inserted little bracketed comments to indicate missing portions. I don't mind, provided that those placebos never see a GDB release: I don't want to have a manual released with empty sections/nodes. So if you plan to finish them up before the next release, it's okay in the meantime to have them in the form you left them. > +While in Ada mode, you may use `@t{-}@t{-}' for comments. Please say ``@t{--}'' here. > +The other component-by-component array operations (@b{and}, @b{or}, > +@b{xor}, @b{not}, and relational tests other than equality) > +are not implemented. Shouldn't we use @code instead of @b here? These are operators, i.e. symbols, right? > +@code{@var{B}::@var{var}} means ``the variable named @var{var} that appears > +in function or file @var{B}.'' When @var{B} is a file name, you must typically > +surround it in single quotes. What else can B be in this context? > +in strings. For example, > +@example > + "One line.["0a"]Next line.["0a"]" > +@end example > +Contains an ASCII newline character (Ada.Characters.Latin_1.LF) after each > +period. You need a @noindent (alone on a separate line) after @end example, and the text after that should begin with a lower-case letter, since it's not a new sentence. Also, we use @smallexample throughout the manual, so please change all @example's to @smallexample. > +@item > +The subtype used as a prefix for the attributes @t{'Pos}, @t{'Min}, and > +@t{'Max} is optional (and is ignored in any case). For example, it is legal > +to write Please don't use "legal" here (or anywhere else in the manual), as nothing in GDB usage can ever be against the law ;-). The word ``valid'' is usually a good replacement. > +@item > +Since Ada is case-insensitive, the debugger normally maps identifiers you type > +to lower case. The GNAT compiler uses upper-case characters for > +some of its internal identifiers, which are normally of no interest to users. > +For the rare occasions when you actually have to look at them, > +enclose them in angle brackets to avoid the lower-case mapping. This warrants a @cindex entry: people are bound to look for this trick when they need it, so let's help them. > +@node Stopping Before Main Program > +@subsubsection Stopping at the Very Beginning > + > +It is sometimes necessary to debug the program during elaboration, and > +before reaching the main procedure. > +As defined in the Ada Reference > +Manual, the elaboration code is invoked from a procedure called > +@code{adainit}. To start your program until the beginning of the > +elaboration, simply use the following two commands: > +@code{tbreak adainit} and @code{run}. Same here: let's index this. > +@table @code > +@item break exception Every user command should be indexed with a @kindex. (In this case, it's sufficient to have a single "@kindex break exception" rather than 2 entries, as these are variations of the same command.) > +the exception name with its package name. In particular, if an entity Please make sure there are 2 blanks after each dot that ends a sentence. > +On Ada implementations that use setjmp and longjmp Shouldn't this be "In Ada implementations ..."? > +@node Ada Tasks and Core Files > +@subsubsection Tasking Support when Debugging Core Files > +@cindex Ada, tasking, core This cindex entry is better spelled "@cindex Ada, tasking, and core files debugging". > +It is not possible to refer to the original generic entities themselves > +in GDB (there is no code to refer to), but it ^^^ This should be @value{GDBN}. > +Besides the omissions listed previously (@pxref{Omissions from Ada}), > +we know of several problems with and limitations of Ada mode in @value{GDBN}, > +some of which will be fixed with planned future releases of the debugger > +and the GNU Ada compiler. This should say "as of @value{GDBN} version X.YY". A year or two from now, someone will have hard time updating this verbiage given the changes in Ada support. > +The type of the @t{'Address} attribute may not be @t{System.Address}. I think you should use @code instead of @t in this and similar cases. Thanks again for documenting the Ada support in such detailed form. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFA]: Turn on Ada support 2004-06-08 22:15 ` Eli Zaretskii @ 2004-06-09 9:23 ` Paul Hilfinger 2004-06-09 18:25 ` Eli Zaretskii 0 siblings, 1 reply; 21+ messages in thread From: Paul Hilfinger @ 2004-06-09 9:23 UTC (permalink / raw) To: eliz; +Cc: gdb-patches Eli, Thanks for your comments. I have adopted most of them. Comments on your comments follow. > I don't mind, provided that those placebos never see a GDB release: I > don't want to have a manual released with empty sections/nodes. So if > you plan to finish them up before the next release, it's okay in the > meantime to have them in the form you left them. In that case, I think I'll just remove these stubs. They're easy enough to insert when implemented. > > +in function or file @var{B}.'' When @var{B} is a file name, you must typically > > +surround it in single quotes. > > What else can B be in this context? A function name. I take it "function or file @var{B}" is too terse for you? > > +@table @code > > +@item break exception > > Every user command should be indexed with a @kindex. (In this case, > it's sufficient to have a single "@kindex break exception" rather > than 2 entries, as these are variations of the same command.) Actually, we'll remove this, because it isn't yet implemented and its syntax going to be changed anyway. > This should say "as of @value{GDBN} version X.YY". A year or two from > now, someone will have hard time updating this verbiage given the > changes in Ada support. OK, but I am not sure what editorial comment you are implying with the word "verbiage" (:->). > > +The type of the @t{'Address} attribute may not be @t{System.Address}. > > I think you should use @code instead of @t in this and similar cases. Umph. The problem is that @code{'Address} generates `'Address' in Info files, which looks odd. Paul ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFA]: Turn on Ada support 2004-06-09 9:23 ` Paul Hilfinger @ 2004-06-09 18:25 ` Eli Zaretskii 2004-06-10 9:40 ` Paul Hilfinger 0 siblings, 1 reply; 21+ messages in thread From: Eli Zaretskii @ 2004-06-09 18:25 UTC (permalink / raw) To: Paul Hilfinger; +Cc: gdb-patches > From: Paul Hilfinger <hilfingr@gnat.com> > Date: Wed, 9 Jun 2004 05:23:55 -0400 (EDT) > > > > What else can B be in this context? > > A function name. I take it "function or file @var{B}" is too terse for you? No, I simply missed that, sorry. > > This should say "as of @value{GDBN} version X.YY". A year or two from > > now, someone will have hard time updating this verbiage given the > > changes in Ada support. > > OK, but I am not sure what editorial comment you are implying with the > word "verbiage" (:->). A bad way to say "wording"... ;-) > > > +The type of the @t{'Address} attribute may not be @t{System.Address}. > > > > I think you should use @code instead of @t in this and similar cases. > > Umph. The problem is that @code{'Address} generates `'Address' in Info files, > which looks odd. That's true, but isn't that a problem in all Ada-related documentation? ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFA]: Turn on Ada support 2004-06-09 18:25 ` Eli Zaretskii @ 2004-06-10 9:40 ` Paul Hilfinger 0 siblings, 0 replies; 21+ messages in thread From: Paul Hilfinger @ 2004-06-10 9:40 UTC (permalink / raw) To: eliz; +Cc: gdb-patches Eli, > > > > +The type of the @t{'Address} attribute may not be @t{System.Address}. > > > > > > I think you should use @code instead of @t in this and similar cases. > > > > Umph. The problem is that @code{'Address} generates `'Address' in Info files, > > which looks odd. > > That's true, but isn't that a problem in all Ada-related > documentation? Not quite sure of your point here. In info files, just plain 'Address, without bracketing quotation marks, seems (to me anyway) to work just fine. It also seems readable in the TeX version (moreso, due to the change in font). Yeah, I know that @code is the right mark to use, semantically speaking, but this seems to be one of those awkward cases where aesthetics conflict with strict correctness. Paul Hilfinger ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFA]: Turn on Ada support 2004-06-08 9:08 [RFA]: Turn on Ada support Paul Hilfinger 2004-06-08 22:15 ` Eli Zaretskii @ 2004-06-09 7:24 ` Jim Blandy 2004-06-09 9:40 ` Paul Hilfinger ` (2 more replies) 1 sibling, 3 replies; 21+ messages in thread From: Jim Blandy @ 2004-06-09 7:24 UTC (permalink / raw) To: Paul Hilfinger; +Cc: gdb-patches The changes to symtab.c, symfile.c, defs.h, and gdbtypes.h are fine. I don't like the braces around the lone 'return' statements in symtab.c, though. I don't think they add much, although what's probably more germane is that it's not the typical practice elsewhere in the code. > gdb/ChangeLog: > > 2004-06-03 Paul N. Hilfinger <Hilfinger@gnat.com> > > Turn on initial Ada support (mainly expression evaluation). > > * Makefile.in (ada_lex_c): Define > (HFILES_NO_SRCDIR): Add ada-lang.h. > (COMMON_OBS): Add ada-lang.o, ada-typeprint.o, ada-valprint.o, > ada-tasks.o. > (YYOBJ): Add ada-exp.o. > (rule .l.c): Generalize to not mention ada. > (ada-lex.o): Remove (ada-lex.c is included by ada-exp.y). > (ada-lang.o): Add dependencies on completer.h, gdb_obstack.h, > hashtab.h. > (ada-tasks.o): Add dependency on gdb_string.h. > (ada-valprint.o): Add dependency on gdb_string.h. > > * symtab.c: Add dependency on ada-lang.h. > (symbol_natural_name): Add Ada case. > (symbol_demangled_name): Add Ada case. > (symbol_search_name): Add Ada case. > > * symfile.c (init_filename_language_table): Add extensions for > Ada. > > * defs.h (enum language): Add language_ada. > > * gdbtypes.h (TYPE_FLAG_FIXED_INSTANCE): Define. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFA]: Turn on Ada support 2004-06-09 7:24 ` Jim Blandy @ 2004-06-09 9:40 ` Paul Hilfinger 2004-06-09 13:12 ` Daniel Jacobowitz 2004-06-16 8:34 ` [PATCH]: Further updates to ada-* files Paul Hilfinger 2 siblings, 0 replies; 21+ messages in thread From: Paul Hilfinger @ 2004-06-09 9:40 UTC (permalink / raw) To: jimb; +Cc: gdb-patches > The changes to symtab.c, symfile.c, defs.h, and gdbtypes.h are fine. > > I don't like the braces around the lone 'return' statements in > symtab.c, though. I don't think they add much, although what's > probably more germane is that it's not the typical practice elsewhere > in the code. Jim, Great! I'll remove the braces; they're probably an artifact of some internal change sequence anyway. Paul ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFA]: Turn on Ada support 2004-06-09 7:24 ` Jim Blandy 2004-06-09 9:40 ` Paul Hilfinger @ 2004-06-09 13:12 ` Daniel Jacobowitz 2004-06-09 13:40 ` Andrew Cagney ` (3 more replies) 2004-06-16 8:34 ` [PATCH]: Further updates to ada-* files Paul Hilfinger 2 siblings, 4 replies; 21+ messages in thread From: Daniel Jacobowitz @ 2004-06-09 13:12 UTC (permalink / raw) To: Jim Blandy; +Cc: Paul Hilfinger, gdb-patches On Wed, Jun 09, 2004 at 02:23:18AM -0500, Jim Blandy wrote: > > The changes to symtab.c, symfile.c, defs.h, and gdbtypes.h are fine. > > I don't like the braces around the lone 'return' statements in > symtab.c, though. I don't think they add much, although what's > probably more germane is that it's not the typical practice elsewhere > in the code. I'm not sure if those parts will work without the Makefile.in changes, and I'm not in favor of the Makefile.in changes yet. The problem is that the Ada language support has never been reviewed. It's in the repository as a code dump under the assumption that it will be reviewed before we start actively using it. So in my opinion, to review this patch we first have to review those files. -- Daniel Jacobowitz ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFA]: Turn on Ada support 2004-06-09 13:12 ` Daniel Jacobowitz @ 2004-06-09 13:40 ` Andrew Cagney 2004-06-09 16:21 ` Jim Blandy ` (2 subsequent siblings) 3 siblings, 0 replies; 21+ messages in thread From: Andrew Cagney @ 2004-06-09 13:40 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: Jim Blandy, Paul Hilfinger, gdb-patches > On Wed, Jun 09, 2004 at 02:23:18AM -0500, Jim Blandy wrote: > >>> >>> The changes to symtab.c, symfile.c, defs.h, and gdbtypes.h are fine. >>> >>> I don't like the braces around the lone 'return' statements in >>> symtab.c, though. I don't think they add much, although what's >>> probably more germane is that it's not the typical practice elsewhere >>> in the code. > > > I'm not sure if those parts will work without the Makefile.in changes, > and I'm not in favor of the Makefile.in changes yet. > > The problem is that the Ada language support has never been reviewed. > It's in the repository as a code dump under the assumption that it will > be reviewed before we start actively using it. So in my opinion, to > review this patch we first have to review those files. Correct. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFA]: Turn on Ada support 2004-06-09 13:12 ` Daniel Jacobowitz 2004-06-09 13:40 ` Andrew Cagney @ 2004-06-09 16:21 ` Jim Blandy 2004-06-10 9:50 ` Paul Hilfinger 2004-06-16 8:42 ` [RFA]: Turn on Ada support, take 2 Paul Hilfinger 3 siblings, 0 replies; 21+ messages in thread From: Jim Blandy @ 2004-06-09 16:21 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: Paul Hilfinger, gdb-patches Daniel Jacobowitz <drow@false.org> writes: > On Wed, Jun 09, 2004 at 02:23:18AM -0500, Jim Blandy wrote: > > > > The changes to symtab.c, symfile.c, defs.h, and gdbtypes.h are fine. > > > > I don't like the braces around the lone 'return' statements in > > symtab.c, though. I don't think they add much, although what's > > probably more germane is that it's not the typical practice elsewhere > > in the code. > > I'm not sure if those parts will work without the Makefile.in changes, > and I'm not in favor of the Makefile.in changes yet. > > The problem is that the Ada language support has never been reviewed. > It's in the repository as a code dump under the assumption that it will > be reviewed before we start actively using it. So in my opinion, to > review this patch we first have to review those files. Okay, that makes sense. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFA]: Turn on Ada support 2004-06-09 13:12 ` Daniel Jacobowitz 2004-06-09 13:40 ` Andrew Cagney 2004-06-09 16:21 ` Jim Blandy @ 2004-06-10 9:50 ` Paul Hilfinger 2004-06-16 8:42 ` [RFA]: Turn on Ada support, take 2 Paul Hilfinger 3 siblings, 0 replies; 21+ messages in thread From: Paul Hilfinger @ 2004-06-10 9:50 UTC (permalink / raw) To: drow; +Cc: jimb, gdb-patches > I'm not sure if those parts will work without the Makefile.in changes, > and I'm not in favor of the Makefile.in changes yet. > > The problem is that the Ada language support has never been reviewed. > It's in the repository as a code dump under the assumption that it will > be reviewed before we start actively using it. So in my opinion, to > review this patch we first have to review those files. Well, we merge and test against the CVS head frequently, so we're sure it "works", but I certainly agree that review is necessary. For those eager to start (:->) I suggest waiting for a day or so, until my next check-in of Ada sources. I will save (or rather, postpone) some of the reviewers' work by marking (with distinctive conditionalization) some substantial sections that we have not turned on yet in the public version, so that they may be skipped for the time being. Paul Hilfinger ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFA]: Turn on Ada support, take 2 2004-06-09 13:12 ` Daniel Jacobowitz ` (2 preceding siblings ...) 2004-06-10 9:50 ` Paul Hilfinger @ 2004-06-16 8:42 ` Paul Hilfinger 2004-06-16 18:07 ` Eli Zaretskii 3 siblings, 1 reply; 21+ messages in thread From: Paul Hilfinger @ 2004-06-16 8:42 UTC (permalink / raw) To: gdb-patches; +Cc: drow, jimb, eliz Here is an update to the patch I sent previously. In this version, I have 1. Removed the compilation of ada-tasks.o, since we have not yet turned on any of it in the public version. 2. Responded to most of Eli's comments. I will have to consider the issue of formating things like 'Address, since the standard rendering in info files provided by the technically appropriate marker, @code, looks rather bad (in my opinion), due to the adjacent quotes at the beginning. A previous patch to the Ada sources added some conditionalization to mark code that is not yet used in the public version (for the benefit of reviewers). ChangeLogs: 2004-06-16 Paul N. Hilfinger <Hilfinger@gnat.com> Turn on initial Ada support (mainly expression evaluation). * Makefile.in (ada_lex_c): Define (HFILES_NO_SRCDIR): Add ada-lang.h. (COMMON_OBS): Add ada-lang.o, ada-typeprint.o, ada-valprint.o. (YYOBJ): Add ada-exp.o. (rule .l.c): Generalize to not mention ada. (ada-lex.o): Remove (ada-lex.c is included by ada-exp.y). (ada-lang.o): Add dependencies on completer.h, gdb_obstack.h, hashtab.h. (ada-tasks.o): Add dependency on gdb_string.h. (ada-valprint.o): Add dependency on gdb_string.h. * symtab.c: Add dependency on ada-lang.h. (symbol_natural_name): Add Ada case. (symbol_demangled_name): Add Ada case. (symbol_search_name): Add Ada case. * symfile.c (init_filename_language_table): Add extensions for Ada. * defs.h (enum language): Add language_ada. * gdbtypes.h (TYPE_FLAG_FIXED_INSTANCE): Define. 2004-06-09 Paul N. Hilfinger <hilfinger@gnat.com> * doc/gdb.texinfo (Filenames): Add Ada suffixes. (Ada) New section. Index: gdb/Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.587 diff -u -p -r1.587 Makefile.in --- gdb/Makefile.in 14 Jun 2004 20:40:39 -0000 1.587 +++ gdb/Makefile.in 16 Jun 2004 08:23:45 -0000 @@ -616,6 +616,7 @@ nm_h = @nm_h@ # gdb/ headers # +ada_lex_c = ada-lex.c ada_lang_h = ada-lang.h $(value_h) $(gdbtypes_h) alphabsd_tdep_h = alphabsd-tdep.h alpha_tdep_h = alpha-tdep.h @@ -833,7 +834,7 @@ HFILES_NO_SRCDIR = bcache.h buildsym.h c symfile.h symfile-mem.h stabsread.h target.h terminal.h typeprint.h \ xcoffsolib.h \ macrotab.h macroexp.h macroscope.h \ - c-lang.h f-lang.h \ + ada-lang.h c-lang.h f-lang.h \ jv-lang.h \ m2-lang.h p-lang.h \ complaints.h valprint.h \ @@ -894,7 +895,7 @@ COMMON_OBS = $(DEPFILES) $(YYOBJ) \ dbxread.o coffread.o coff-pe-read.o elfread.o \ dwarfread.o dwarf2read.o mipsread.o stabsread.o corefile.o \ dwarf2expr.o dwarf2loc.o dwarf2-frame.o \ - c-lang.o f-lang.o objc-lang.o \ + ada-lang.o c-lang.o f-lang.o objc-lang.o \ ui-out.o cli-out.o \ varobj.o wrapper.o \ jv-lang.o jv-valprint.o jv-typeprint.o \ @@ -902,8 +903,8 @@ COMMON_OBS = $(DEPFILES) $(YYOBJ) \ scm-exp.o scm-lang.o scm-valprint.o \ sentinel-frame.o \ complaints.o typeprint.o \ - c-typeprint.o f-typeprint.o m2-typeprint.o \ - c-valprint.o cp-valprint.o f-valprint.o m2-valprint.o \ + ada-typeprint.o c-typeprint.o f-typeprint.o m2-typeprint.o \ + ada-valprint.o c-valprint.o cp-valprint.o f-valprint.o m2-valprint.o \ nlmread.o serial.o mdebugread.o top.o utils.o \ ui-file.o \ user-regs.o \ @@ -927,6 +928,7 @@ YYFILES = c-exp.c \ f-exp.c m2-exp.c p-exp.c YYOBJ = c-exp.o \ objc-exp.o \ + ada-exp.o \ jv-exp.o \ f-exp.o m2-exp.o p-exp.o @@ -1495,7 +1497,7 @@ valprint.o: $(srcdir)/valprint.c echo $(FLEX) -Isit $< ">" $@; \ $(FLEX) -Isit $< > $@; \ elif [ ! -f $@ -a ! -f $< ]; then \ - echo "ada-lex.c missing and flex not available."; \ + echo "$< missing and flex not available."; \ false; \ elif [ ! -f $@ ]; then \ echo "Warning: $*.c older than $*.l and flex not available."; \ @@ -1522,18 +1524,18 @@ ada-lang.o: ada-lang.c $(gdb_string_h) $ $(gdbtypes_h) $(gdbcmd_h) $(expression_h) $(parser_defs_h) \ $(language_h) $(c_lang_h) $(inferior_h) $(symfile_h) $(objfiles_h) \ $(breakpoint_h) $(gdbcore_h) $(ada_lang_h) $(ui_out_h) $(block_h) \ - $(infcall_h) $(dictionary_h) -ada-lex.o: ada-lex.c + $(completer_h) $(infcall_h) $(gdb_obstack_h) $(dictionary_h) \ + $(hashtab_h) ada-tasks.o: ada-tasks.c $(defs_h) $(command_h) $(value_h) $(language_h) \ $(inferior_h) $(symtab_h) $(target_h) $(regcache_h) $(gdbcore_h) \ - $(gregset_h) $(ada_lang_h) + $(gregset_h) $(gdb_string_h) $(ada_lang_h) ada-typeprint.o: ada-typeprint.c $(defs_h) $(gdb_obstack_h) $(bfd_h) \ $(symtab_h) $(gdbtypes_h) $(expression_h) $(value_h) $(gdbcore_h) \ $(target_h) $(command_h) $(gdbcmd_h) $(language_h) $(demangle_h) \ $(c_lang_h) $(typeprint_h) $(ada_lang_h) $(gdb_string_h) ada-valprint.o: ada-valprint.c $(defs_h) $(symtab_h) $(gdbtypes_h) \ $(expression_h) $(value_h) $(demangle_h) $(valprint_h) $(language_h) \ - $(annotate_h) $(ada_lang_h) $(c_lang_h) $(infcall_h) + $(annotate_h) $(ada_lang_h) $(c_lang_h) $(gdb_string_h) $(infcall_h) aix-thread.o: aix-thread.c $(defs_h) $(gdb_assert_h) $(gdbthread_h) \ $(target_h) $(inferior_h) $(regcache_h) $(gdbcmd_h) $(language_h) \ $(ppc_tdep_h) $(gdb_string_h) Index: gdb/defs.h =================================================================== RCS file: /cvs/src/src/gdb/defs.h,v retrieving revision 1.147 diff -u -p -r1.147 defs.h --- gdb/defs.h 10 Jun 2004 20:05:43 -0000 1.147 +++ gdb/defs.h 16 Jun 2004 08:23:45 -0000 @@ -220,6 +220,7 @@ enum language language_asm, /* Assembly language */ language_scm, /* Scheme / Guile */ language_pascal, /* Pascal */ + language_ada, /* Ada */ language_minimal /* All other languages, minimal support only */ }; Index: gdb/gdbtypes.h =================================================================== RCS file: /cvs/src/src/gdb/gdbtypes.h,v retrieving revision 1.53 diff -u -p -r1.53 gdbtypes.h --- gdb/gdbtypes.h 2 Jun 2004 21:01:55 -0000 1.53 +++ gdb/gdbtypes.h 16 Jun 2004 08:23:45 -0000 @@ -273,6 +273,17 @@ enum type_code #define TYPE_ADDRESS_CLASS_ALL(t) (TYPE_INSTANCE_FLAGS(t) \ & TYPE_FLAG_ADDRESS_CLASS_ALL) +/* The debugging formats (especially STABS) do not contain enough information + to represent all Ada types---especially those whose size depends on + dynamic quantities. Therefore, the GNAT Ada compiler includes + extra information in the form of additional type definitions + connected by naming conventions. This flag indicates that the + type is an ordinary (unencoded) GDB type that has been created from + the necessary run-time information, and does not need further + interpretation. Optionally marks ordinary, fixed-size GDB type. */ + +#define TYPE_FLAG_FIXED_INSTANCE (1 << 15) + /* Array bound type. */ enum array_bound_type { Index: gdb/symfile.c =================================================================== RCS file: /cvs/src/src/gdb/symfile.c,v retrieving revision 1.132 diff -u -p -r1.132 symfile.c --- gdb/symfile.c 15 Jun 2004 01:04:20 -0000 1.132 +++ gdb/symfile.c 16 Jun 2004 08:23:46 -0000 @@ -2158,6 +2158,10 @@ init_filename_language_table (void) add_filename_language (".pas", language_pascal); add_filename_language (".p", language_pascal); add_filename_language (".pp", language_pascal); + add_filename_language (".adb", language_ada); + add_filename_language (".ads", language_ada); + add_filename_language (".a", language_ada); + add_filename_language (".ada", language_ada); } } Index: gdb/symtab.c =================================================================== RCS file: /cvs/src/src/gdb/symtab.c,v retrieving revision 1.132 diff -u -p -r1.132 symtab.c --- gdb/symtab.c 10 Jun 2004 20:05:44 -0000 1.132 +++ gdb/symtab.c 16 Jun 2004 08:23:47 -0000 @@ -41,6 +41,7 @@ #include "source.h" #include "filenames.h" /* for FILENAME_CMP */ #include "objc-lang.h" +#include "ada-lang.h" #include "hashtab.h" @@ -632,17 +633,24 @@ symbol_init_demangled_name (struct gener char * symbol_natural_name (const struct general_symbol_info *gsymbol) { - if ((gsymbol->language == language_cplus - || gsymbol->language == language_java - || gsymbol->language == language_objc) - && (gsymbol->language_specific.cplus_specific.demangled_name != NULL)) + switch (gsymbol->language) { - return gsymbol->language_specific.cplus_specific.demangled_name; - } - else - { - return gsymbol->name; + case language_cplus: + case language_java: + case language_objc: + if (gsymbol->language_specific.cplus_specific.demangled_name != NULL) + return gsymbol->language_specific.cplus_specific.demangled_name; + break; + case language_ada: + if (gsymbol->language_specific.cplus_specific.demangled_name != NULL) + return gsymbol->language_specific.cplus_specific.demangled_name; + else + return ada_decode_symbol (gsymbol); + break; + default: + break; } + return gsymbol->name; } /* Return the demangled name for a symbol based on the language for @@ -650,13 +658,24 @@ symbol_natural_name (const struct genera char * symbol_demangled_name (struct general_symbol_info *gsymbol) { - if (gsymbol->language == language_cplus - || gsymbol->language == language_java - || gsymbol->language == language_objc) - return gsymbol->language_specific.cplus_specific.demangled_name; - - else - return NULL; + switch (gsymbol->language) + { + case language_cplus: + case language_java: + case language_objc: + if (gsymbol->language_specific.cplus_specific.demangled_name != NULL) + return gsymbol->language_specific.cplus_specific.demangled_name; + break; + case language_ada: + if (gsymbol->language_specific.cplus_specific.demangled_name != NULL) + return gsymbol->language_specific.cplus_specific.demangled_name; + else + return ada_decode_symbol (gsymbol); + break; + default: + break; + } + return NULL; } /* Return the search name of a symbol---generally the demangled or @@ -664,7 +683,10 @@ symbol_demangled_name (struct general_sy If there is no distinct demangled name, then returns the same value (same pointer) as SYMBOL_LINKAGE_NAME. */ char *symbol_search_name (const struct general_symbol_info *gsymbol) { - return symbol_natural_name (gsymbol); + if (gsymbol->language == language_ada) + return gsymbol->name; + else + return symbol_natural_name (gsymbol); } /* Initialize the structure fields to zero values. */ Index: gdb/doc/gdb.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.206 diff -u -p -r1.206 gdb.texinfo --- gdb/doc/gdb.texinfo 14 Jun 2004 22:26:33 -0000 1.206 +++ gdb/doc/gdb.texinfo 16 Jun 2004 08:23:53 -0000 @@ -7741,6 +7741,11 @@ If a source file name ends in one of the @value{GDBN} infers that its language is the one indicated. @table @file +@item .ada +@itemx .ads +@itemx .adb +@itemx .a +Ada source file. @item .c C source file @@ -8031,7 +8036,7 @@ being set automatically by @value{GDBN}. @node Support @section Supported languages -@value{GDBN} supports C, C@t{++}, Objective-C, Fortran, Java, assembly, and Modula-2. +@value{GDBN} supports C, C@t{++}, Objective-C, Fortran, Java, assembly, Modula-2, and Ada. @c This is false ... Some @value{GDBN} features may be used in expressions regardless of the language you use: the @value{GDBN} @code{@@} and @code{::} operators, @@ -8051,6 +8056,7 @@ language reference or tutorial. * C:: C and C@t{++} * Objective-C:: Objective-C * Modula-2:: Modula-2 +* Ada:: Ada @end menu @node C @@ -8666,7 +8672,7 @@ the description of an object. However, with certain Objective-C libraries that have a particular hook function, @code{_NSPrintForDebugger}, defined. -@node Modula-2, , Objective-C, Support +@node Modula-2, Ada, Objective-C, Support @subsection Modula-2 @cindex Modula-2, @value{GDBN} support @@ -9109,6 +9115,481 @@ address can be specified by an integral In @value{GDBN} scripts, the Modula-2 inequality operator @code{#} is interpreted as the beginning of a comment. Use @code{<>} instead. +@node Ada +@subsection Ada +@cindex Ada + +The extensions made to @value{GDBN} for Ada only support +output from the @sc{gnu} Ada (GNAT) compiler. +Other Ada compilers are not currently supported, and +attempting to debug executables produced by them is most likely +to be difficult. + + +@cindex expressions in Ada +@menu +* Ada Mode Intro:: General remarks on the Ada syntax + and semantics supported by Ada mode + in @value{GDBN} +* Omissions from Ada:: Restrictions on the Ada expression syntax. +* Additions to Ada:: Extensions of the Ada expression syntax. +* Stopping Before Main Program:: Debugging the program during elaboration. +* Ada Exceptions:: Setting breakpoints on exception handlers. +* Ada Generic Units:: Dealing with generic instantiations. +* Ada Glitches:: Known peculiarities of Ada mode. +@end menu + +@node Ada Mode Intro +@subsubsection Introduction +@cindex Ada mode, general + +The Ada mode of @value{GDBN} supports a fairly large subset of Ada expression +syntax, with some extensions. +The philosophy behind the design of this subset is + +@itemize @bullet +@item +That @value{GDBN} should provide basic literals and access to operations for +arithmetic, dereferencing, field selection, indexing, and subprogram calls, +leaving more sophisticated computations to subprograms written into the +program (which therefore may be called from @value{GDBN}). + +@item +That type safety and strict adherence to Ada language restrictions +are not particularly important to the @value{GDBN} user. + +@item +That brevity is important to the @value{GDBN} user. +@end itemize + +Thus, for brevity, the debugger acts as if there were +implicit @code{with} and @code{use} clauses in effect for all user-written +packages, making it unnecessary to fully qualify most names with +their packages, regardless of context. Where this causes ambiguity, +@value{GDBN} asks the user's intent. + +The debugger will start in Ada mode if it detects an Ada main program. +As for other languages, it will enter Ada mode when stopped in a program that +was translated from an Ada source file. + +While in Ada mode, you may use `@t{--}' for comments. This is useful +mostly for documenting command files. The standard @value{GDBN} comment +(@samp{#}) still works at the beginning of a line in Ada mode, but not in the +middle (to allow based literals). + +The debugger supports limited overloading. Given a subprogram call in which +the function symbol has multiple definitions, it will use the number of +actual parameters and some information about their types to attempt to narrow +the set of definitions. It also makes very limited use of context, preferring +procedures to functions in the context of the @code{call} command, and +functions to procedures elsewhere. + +@node Omissions from Ada +@subsubsection Omissions from Ada +@cindex Ada, omissions from + +Here are the notable omissions from the subset: + +@itemize @bullet +@item +Only a subset of the attributes are supported: + +@itemize @minus +@item +@t{'First}, @t{'Last}, and @t{'Length} + on array objects (not on types and subtypes). + +@item +@t{'Min} and @t{'Max}. + +@item +@t{'Pos} and @t{'Val}. + +@item +@t{'Tag}. + +@item +@t{'Range} on array objects (not subtypes), but only as the right +operand of the membership (@code{in}) operator. + +@item +@t{'Access}, @t{'Unchecked_Access}, and +@t{'Unrestricted_Access} (a GNAT extension). + +@item +@t{'Address}. +@end itemize + +@item +The names in +@code{Characters.Latin_1} are not available and +concatenation is not implemented. Thus, escape characters in strings are +not currently available. + +@item +Equality tests (@samp{=} and @samp{/=}) on arrays test for bitwise +equality of representations. They will generally work correctly +for strings and arrays whose elements have integer or enumeration types. +They may not work correctly for arrays whose element +types have user-defined equality, for arrays of real values +(in particular, IEEE-conformant floating point, because of negative +zeroes and NaNs), and for arrays whose elements contain unused bits with +indeterminate values. + +@item +The other component-by-component array operations (@code{and}, @code{or}, +@code{xor}, @code{not}, and relational tests other than equality) +are not implemented. + +@item +There are no record or array aggregates. + +@item +Dispatching subprogram calls are not implemented. + +@item +The overloading algorithm is much more limited (i.e., less selective) +than that of real Ada. It makes only limited use of the context in which a subexpression +appears to resolve its meaning, and it is much looser in its rules for allowing +type matches. As a result, some function calls will be ambiguous, and the user +will be asked to choose the proper resolution. + +@item +The @code{new} operator is not implemented. + +@item +Entry calls are not implemented. + +@item +Aside from printing, arithmetic operations on the native VAX floating-point +formats are not supported. + +@item +It is not possible to slice a packed array. +@end itemize + +@node Additions to Ada +@subsubsection Additions to Ada +@cindex Ada, deviations from + +As it does for other languages, @value{GDBN} makes certain generic +extensions to Ada (@pxref{Expressions}): + +@itemize @bullet +@item +If the expression @var{E} is a variable residing in memory +(typically a local variable or array element) and @var{N} is +a positive integer, then @code{@var{E}@@@var{N}} displays the values of +@var{E} and the @var{N}-1 adjacent variables following it in memory as an array. +In Ada, this operator is generally not necessary, since its prime use +is in displaying parts of an array, and slicing will usually do this in Ada. +However, there are occasional uses when debugging programs +in which certain debugging information has been optimized away. + +@item +@code{@var{B}::@var{var}} means ``the variable named @var{var} that appears +in function or file @var{B}.'' When @var{B} is a file name, you must typically +surround it in single quotes. + +@item +The expression @code{@{@var{type}@} @var{addr}} means ``the variable of type +@var{type} that appears at address @var{addr}.'' + +@item +A name starting with @samp{$} is a convenience variable +(@pxref{Convenience Vars}) or a machine register (@pxref{Registers}). +@end itemize + +In addition, @value{GDBN} provides a few other shortcuts and outright additions specific +to Ada: + +@itemize @bullet +@item +The assignment statement is allowed as an expression, returning +its right-hand operand as its value. Thus, you may enter + +@smallexample +set x := y + 3 +print A(tmp := y + 1) +@end smallexample + +@item +The semicolon is allowed as an ``operator,'' returning as its value +the value of its right-hand operand. +This allows, for example, +complex conditional breaks: + +@smallexample +break f +condition 1 (report(i); k += 1; A(k) > 100) +@end smallexample + +@item +Rather than use catenation and symbolic character names to introduce special +characters into strings, one may instead use a special bracket notation, +which is also used to print strings. A sequence of characters of the form +@samp{["@var{XX}"]} within a string or character literal denotes the +(single) character whose numeric encoding is @var{XX} in hexadecimal. The +sequence of characters @samp{["""]} also denotes a single quotation mark +in strings. For example, +@smallexample + "One line.["0a"]Next line.["0a"]" +@end smallexample +@noindent +Contains an ASCII newline character (@code{Ada.Characters.Latin_1.LF}) after each +period. + +@item +The subtype used as a prefix for the attributes @t{'Pos}, @t{'Min}, and +@t{'Max} is optional (and is ignored in any case). For example, it is valid +to write + +@smallexample +print 'max(x, y) +@end smallexample + +@item +When printing arrays, @value{GDBN} uses positional notation when the +array has a lower bound of 1, and uses a modified named notation otherwise. +For example, a one-dimensional array of three integers with a lower bound of 3 might print as + +@smallexample +(3 => 10, 17, 1) +@end smallexample + +@noindent +That is, in contrast to valid Ada, only the first component has a @code{=>} +clause. + +@item +You may abbreviate attributes in expressions with any unique, +multi-character subsequence of +their names (an exact match gets preference). +For example, you may use @t{a'len}, @t{a'gth}, or @t{a'lh} +in place of @t{a'length}. + +@item +@cindex quoting Ada internal identifiers +Since Ada is case-insensitive, the debugger normally maps identifiers you type +to lower case. The GNAT compiler uses upper-case characters for +some of its internal identifiers, which are normally of no interest to users. +For the rare occasions when you actually have to look at them, +enclose them in angle brackets to avoid the lower-case mapping. +For example, +@smallexample +(gdb) print <JMPBUF_SAVE>[0] +@end smallexample + +@item +Printing an object of class-wide type or dereferencing an +access-to-class-wide value will display all the components of the object's +specific type (as indicated by its run-time tag). Likewise, component +selection on such a value will operate on the specific type of the +object. + +@end itemize + +@node Stopping Before Main Program +@subsubsection Stopping at the Very Beginning + +@cindex breakpointing Ada elaboration code +It is sometimes necessary to debug the program during elaboration, and +before reaching the main procedure. +As defined in the Ada Reference +Manual, the elaboration code is invoked from a procedure called +@code{adainit}. To run your program up to the beginning of +elaboration, simply use the following two commands: +@code{tbreak adainit} and @code{run}. + +@node Ada Exceptions +@subsubsection Breaking on Ada Exceptions +@cindex Ada, exceptions + +In Ada mode, you can set breakpoints that trip when your program raises +selected exceptions. + +@table @code +@kindex break exception +@item break exception +Set a breakpoint that trips whenever (any task in the) program raises +any exception. + +@item break exception @var{name} +Set a breakpoint that trips whenever (any task in the) program raises +the exception @var{name}. + +When inserting a breakpoint on a specific exception for which an +homonym entity exists in the application, it is necessary to prefix +the exception name with its package name. In particular, if an entity +sharing the same name as one of the standard exceptions has been defined, +the exception name must be prefixed with package @code{Standard} when +setting a breakpoint on this exception. + +@smallexample +@iftex +@leftskip=0.5cm +@end iftex +(gdb) break exception Standard.Constraint_Error +@end smallexample + +@item break exception unhandled +Set a breakpoint that trips whenever (any task in the) program raises an +exception for which there is no handler. +At the moment, +depending on the implementation of exceptions used on your platform, +this may not have quite the desired effect. Other forms of +exception breaking stop the program at the point the exception is raised. +In Ada implementations that use setjmp and longjmp to implement exception +handling, however, unhandled exceptions are not detected until the +affected task's stack is completely unwound. Thus, you find out that a +task has terminated with an exception, but you aren't told where it was +raised. + +@kindex info exceptions +@item info exceptions +@itemx info exceptions @var{regexp} +The @code{info exceptions} command permits the user to examine all defined +exceptions within Ada programs. With a regular expression, @var{regexp}, as +argument, prints out only those exceptions whose name matches @var{regexp}. +@end table + +@node Ada Generic Units +@subsubsection Debugging Generic Units +@cindex Ada, generic units + +GNAT always uses code expansion for generic instantiation. This means that +each time an instantiation occurs, a complete copy of the original code is +made with appropriate substitutions. + +It is not possible to refer to the original generic entities themselves +in @value{GDBN} (there is no code to refer to), but it +is certainly possible to debug a particular instance of a generic, simply by +using the appropriate expanded names. For example, suppose that +@code{Gen} is a generic package: + +@smallexample +-- In file gen.ads: +generic package Gen is + function F (v1 : Integer) return Integer; +end Gen; + +-- In file gen.adb: +package body Gen is + function F (v1 : Integer) return Integer is + begin + return v1+1; -- Line 5 + end F; +end Gen; +@end smallexample + +@noindent +and we have the following expansions + +@smallexample +with Gen; +procedure G is + package Gen1 is new Gen; + package Gen2 is new Gen; + + I : Integer := 0; +begin + I := Gen1.F (I); + I := Gen2.F (I); + I := Gen1.F (I); + I := Gen2.F (I); +end; +@end smallexample + +@noindent +Then to break on a call to procedure @code{F} in the @code{Gen2} instance, simply +use the command: + +@smallexample +break G.Gen2.F +@end smallexample + +When a breakpoint occurs, you can step through the code of the generic +instance in the normal manner. You can also examine values of data in the +normal manner, providing the appropriate generic package qualification to +refer to non-local entities. + +@node Ada Glitches +@subsubsection Known Peculiarities of Ada Mode +@cindex Ada, problems + +Besides the omissions listed previously (@pxref{Omissions from Ada}), +we know of several problems with and limitations of Ada mode in +@value{GDBN}, +some of which will be fixed with planned future releases of the debugger +and the GNU Ada compiler. + +@itemize @bullet +@item +Currently, the debugger +has insufficient information to determine whether certain pointers represent +pointers to objects or the objects themselves. +Thus, the user may have to tack an extra @code{.all} after an expression +to get it printed properly. + +@item +Static constants that the compiler chooses not to materialize as objects in +storage are invisible to the debugger. + +@item +Named parameter associations in function argument lists are ignored (the +argument lists are treated as positional). + +@item +Many useful library packages are currently invisible to the debugger. + +@item +Fixed-point arithmetic, conversions, input, and output is carried out using +floating-point arithmetic, and may give results that only approximate those on +the host machine. + +@item +The type of the @t{'Address} attribute may not be @code{System.Address}. + +@item +When stopped in a particular subprogram, you can access variables defined +in other, lexically +enclosing subprograms by their simple names. At the moment, however, this +may not always work; it depends on whether the compiler happens to have +made the necessary information (the ``static link'') available +at execution time, which it can sometimes avoid. Of course, +even in those cases where +the compiler does not provide the information, you can still look at such +variables by issuing the appropriate number of @code{up} commands to get to +frame containing the variable you wish to see. +Access to non-local variables does not, at the moment, work in +the test expressions for conditional breakpoints +(@pxref{Conditions, ,Break conditions}) unless you happen to specify these +while stopped in the subprogram in which they are to be applied. + +@item +Depending on the platform, it is not always possible to set breakpoints +on nested functions by name (e.g., @code{break foo}). In effect, the +nested functions act like local variables of the enclosing function. +On these platforms, you must wait until @value{GDBN} is stopped in +the enclosing function before using this form of @code{break} command. +This is not much of a limitation, since you can still set a breakpoint on +the first line of the desired function using the usual +@code{break @var{file}:@var{line}} syntax. + +@item +The GNAT compiler never generates the prefix @code{Standard} for any of +the standard symbols defined by the Ada language. @value{GDBN} knows about +this: it will strip the prefix from names when you use it, and will never +look for a name you have so qualified among local symbols, nor match against +symbols in other packages or subprograms. If you have +defined entities anywhere in your program other than parameters and +local variables whose simple names match names in @code{Standard}, +GNAT's lack of qualification here can cause confusion. When this happens, +you can usually resolve the confusion +by qualifying the problematic names with package +@code{Standard} explicitly. +@end itemize + @node Unsupported languages @section Unsupported languages ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFA]: Turn on Ada support, take 2 2004-06-16 8:42 ` [RFA]: Turn on Ada support, take 2 Paul Hilfinger @ 2004-06-16 18:07 ` Eli Zaretskii 2004-06-17 5:24 ` Paul Hilfinger 0 siblings, 1 reply; 21+ messages in thread From: Eli Zaretskii @ 2004-06-16 18:07 UTC (permalink / raw) To: Paul Hilfinger; +Cc: gdb-patches, drow, jimb > From: Paul Hilfinger <hilfingr@gnat.com> > Date: Wed, 16 Jun 2004 04:42:37 -0400 (EDT) > > [...] I will have to consider the > issue of formating things like 'Address, since the standard rendering > in info files provided by the technically appropriate marker, > @code, looks rather bad (in my opinion), due to the adjacent quotes > at the beginning. If you feel strongly about this, I won't object to use of @t{'Address} in those cases where you think the standard markup looks bad. I have a couple more comments about the patch to gdb.texinfo; sorry if I missed those in the first reading. > +@node Ada Mode Intro > +@subsubsection Introduction > +@cindex Ada mode, general There's no need to add the "general" qualifier here, since you have no other index entry that begins with "Ada mode". So simply say "@cindex Ada mode". > +While in Ada mode, you may use `@t{--}' for comments. Is there a reason for using a @t here? Why not @samp{--}? Thanks. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFA]: Turn on Ada support, take 2 2004-06-16 18:07 ` Eli Zaretskii @ 2004-06-17 5:24 ` Paul Hilfinger 2004-06-17 17:48 ` Eli Zaretskii 0 siblings, 1 reply; 21+ messages in thread From: Paul Hilfinger @ 2004-06-17 5:24 UTC (permalink / raw) To: eliz; +Cc: gdb-patches, drow, jimb > > [...] I will have to consider the > > issue of formating things like 'Address, since the standard rendering > > in info files provided by the technically appropriate marker, > > @code, looks rather bad (in my opinion), due to the adjacent quotes > > at the beginning. > > If you feel strongly about this, I won't object to use of @t{'Address} > in those cases where you think the standard markup looks bad. Eli, Well, I feel strongly that the result of @code{'Address} looks really cruddy in an .info file. However, it occurs to me that if I rewrote the section a little to supply dummy prefixes (e.g., @code{Obj'Address}), the result would not be so bad and would use the right markup command. > I have a couple more comments about the patch to gdb.texinfo; sorry > if I missed those in the first reading. > > > +@node Ada Mode Intro > > +@subsubsection Introduction > > +@cindex Ada mode, general > > There's no need to add the "general" qualifier here, since you have > no other index entry that begins with "Ada mode". So simply say > "@cindex Ada mode". > > > +While in Ada mode, you may use `@t{--}' for comments. > > Is there a reason for using a @t here? Why not @samp{--}? OK on both. Paul Hilfinger ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFA]: Turn on Ada support, take 2 2004-06-17 5:24 ` Paul Hilfinger @ 2004-06-17 17:48 ` Eli Zaretskii 0 siblings, 0 replies; 21+ messages in thread From: Eli Zaretskii @ 2004-06-17 17:48 UTC (permalink / raw) To: Paul Hilfinger; +Cc: gdb-patches, drow, jimb > From: Paul Hilfinger <hilfingr@gnat.com> > Date: Thu, 17 Jun 2004 01:24:51 -0400 (EDT) > > > > If you feel strongly about this, I won't object to use of @t{'Address} > > in those cases where you think the standard markup looks bad. > > Eli, > > Well, I feel strongly that the result of @code{'Address} looks really > cruddy in an .info file. However, it occurs to me that if I rewrote > the section a little to supply dummy prefixes (e.g., @code{Obj'Address}), > the result would not be so bad and would use the right markup command. If @code{Obj'Address} would look natural for Ada users, please use that. Otherwise, @t{'Address} is okay wherever you need it. ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH]: Further updates to ada-* files 2004-06-09 7:24 ` Jim Blandy 2004-06-09 9:40 ` Paul Hilfinger 2004-06-09 13:12 ` Daniel Jacobowitz @ 2004-06-16 8:34 ` Paul Hilfinger 2004-06-27 0:10 ` Andrew Cagney 2 siblings, 1 reply; 21+ messages in thread From: Paul Hilfinger @ 2004-06-16 8:34 UTC (permalink / raw) To: gdb-patches I have committed the following patch to some Ada files, first to keep up-to-date with ACT's sources, and second to conditionalize out a bunch of source code that we are not yet using in the public version for the benefit of reviewers. Paul Hilfinger ACT, Inc. 2004-06-16 Paul N. Hilfinger <Hilfinger@gnat.com> * ada-tasks.c: Rename build_task_list to ada_build_task_list, and make it non-static. * ada-lang.h (task_control_block): declaration moved from ada-task.c to ada-lang.h; this is needed to be able to implement the kill command in multi-task mode. (task_ptid): Ditto. (task_entry): Ditto. (task_list): Ditto. (ada_build_task_list): Ditto. * ada-lang.c: Conditionalize routines and data structures related to breakpoints, exceptions, completion, and symbol caching on GNAT_GDB, since these are not yet used in the submitted public sources. (ada_main_name): Editorial: Move definition out of exception-related code. Index: gdb/ada-lang.c =================================================================== RCS file: /cvs/src/src/gdb/ada-lang.c,v retrieving revision 1.37 diff -u -p -r1.37 ada-lang.c --- gdb/ada-lang.c 8 Jun 2004 08:42:03 -0000 1.37 +++ gdb/ada-lang.c 16 Jun 2004 08:10:22 -0000 @@ -18,6 +18,19 @@ You should have received a copy of the G along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Sections of code marked + + #ifdef GNAT_GDB + ... + #endif + + indicate sections that are used in sources distributed by + ACT, Inc., but not yet integrated into the public tree (where + GNAT_GDB is not defined). They are retained here nevertheless + to minimize the problems of maintaining different versions + of the source and to make the full source available. */ + #include "defs.h" #include <stdio.h> #include "gdb_string.h" @@ -62,6 +75,7 @@ Foundation, Inc., 675 Mass Ave, Cambridg #define TRUNCATION_TOWARDS_ZERO ((-5 / 2) == -2) #endif +#ifdef GNAT_GDB /* A structure that contains a vector of strings. The main purpose of this type is to group the vector and its associated parameters in one structure. This makes it easier @@ -76,6 +90,7 @@ struct string_vector static struct string_vector xnew_string_vector (int initial_size); static void string_vector_append (struct string_vector *sv, char *str); +#endif /* GNAT_GDB */ static const char *ada_unqualified_name (const char *decoded_name); static char *add_angle_brackets (const char *str); @@ -332,6 +347,8 @@ static struct obstack symbol_list_obstac /* Utilities */ +#ifdef GNAT_GDB + /* Create a new empty string_vector struct with an initial size of INITIAL_SIZE. */ @@ -392,6 +409,8 @@ add_angle_brackets (const char *str) return result; } +#endif /* GNAT_GDB */ + static char * ada_get_gdb_completer_word_break_characters (void) { @@ -705,6 +724,37 @@ ada_update_initial_language (enum langua return lang; } + +/* If the main procedure is written in Ada, then return its name. + The result is good until the next call. Return NULL if the main + procedure doesn't appear to be in Ada. */ + +char * +ada_main_name (void) +{ + struct minimal_symbol *msym; + CORE_ADDR main_program_name_addr; + static char main_program_name[1024]; + /* For Ada, the name of the main procedure is stored in a specific + string constant, generated by the binder. Look for that symbol, + extract its address, and then read that string. If we didn't find + that string, then most probably the main procedure is not written + in Ada. */ + msym = lookup_minimal_symbol (ADA_MAIN_PROGRAM_SYMBOL_NAME, NULL, NULL); + + if (msym != NULL) + { + main_program_name_addr = SYMBOL_VALUE_ADDRESS (msym); + if (main_program_name_addr == 0) + error ("Invalid address for Ada main program name."); + + extract_string (main_program_name_addr, main_program_name); + return main_program_name; + } + + /* The main procedure doesn't seem to be in Ada. */ + return NULL; +} \f /* Symbols */ @@ -3597,6 +3647,13 @@ ada_convert_actuals (struct value *func, \f /* Experimental Symbol Cache Module */ +/* This module may well have been OBE, due to improvements in the + symbol-table module. So until proven otherwise, it is disabled in + the submitted public code, and may be removed from all sources + in the future. */ + +#ifdef GNAT_GDB + /* This section implements a simple, fixed-sized hash table for those Ada-mode symbols that get looked up in the course of executing the user's commands. The size is fixed on the grounds that there are not @@ -3686,6 +3743,22 @@ cache_symbol (const char *name, domain_e e->symtab = symtab; e->block = block; } + +#else +static int +lookup_cached_symbol (const char *name, domain_enum namespace, + struct symbol **sym, struct block **block, + struct symtab **symtab) +{ + return 0; +} + +static void +cache_symbol (const char *name, domain_enum namespace, struct symbol *sym, + struct block *block, struct symtab *symtab) +{ +} +#endif /* GNAT_GDB */ \f /* Symbol Lookup */ @@ -3841,817 +3914,530 @@ defns_collected (struct obstack *obstack return (struct ada_symbol_info *) obstack_base (obstackp); } -/* If SYM_NAME is a completion candidate for TEXT, return this symbol - name in a form that's appropriate for the completion. The result - does not need to be deallocated, but is only good until the next call. - - TEXT_LEN is equal to the length of TEXT. - Perform a wild match if WILD_MATCH is set. - ENCODED should be set if TEXT represents the start of a symbol name - in its encoded form. */ +/* Look, in partial_symtab PST, for symbol NAME in given namespace. + Check the global symbols if GLOBAL, the static symbols if not. + Do wild-card match if WILD. */ -static const char * -symbol_completion_match (const char *sym_name, - const char *text, int text_len, - int wild_match, int encoded) +static struct partial_symbol * +ada_lookup_partial_symbol (struct partial_symtab *pst, const char *name, + int global, domain_enum namespace, int wild) { - char *result; - const int verbatim_match = (text[0] == '<'); - int match = 0; + struct partial_symbol **start; + int name_len = strlen (name); + int length = (global ? pst->n_global_syms : pst->n_static_syms); + int i; - if (verbatim_match) + if (length == 0) { - /* Strip the leading angle bracket. */ - text = text + 1; - text_len--; + return (NULL); } - /* First, test against the fully qualified name of the symbol. */ - - if (strncmp (sym_name, text, text_len) == 0) - match = 1; - - if (match && !encoded) - { - /* One needed check before declaring a positive match is to verify - that iff we are doing a verbatim match, the decoded version - of the symbol name starts with '<'. Otherwise, this symbol name - is not a suitable completion. */ - const char *sym_name_copy = sym_name; - int has_angle_bracket; - - sym_name = ada_decode (sym_name); - has_angle_bracket = (sym_name [0] == '<'); - match = (has_angle_bracket == verbatim_match); - sym_name = sym_name_copy; - } + start = (global ? + pst->objfile->global_psymbols.list + pst->globals_offset : + pst->objfile->static_psymbols.list + pst->statics_offset); - if (match && !verbatim_match) + if (wild) { - /* When doing non-verbatim match, another check that needs to - be done is to verify that the potentially matching symbol name - does not include capital letters, because the ada-mode would - not be able to understand these symbol names without the - angle bracket notation. */ - const char *tmp; + for (i = 0; i < length; i += 1) + { + struct partial_symbol *psym = start[i]; - for (tmp = sym_name; *tmp != '\0' && !isupper (*tmp); tmp++); - if (*tmp != '\0') - match = 0; + if (SYMBOL_DOMAIN (psym) == namespace && + wild_match (name, name_len, SYMBOL_LINKAGE_NAME (psym))) + return psym; + } + return NULL; } + else + { + if (global) + { + int U; + i = 0; + U = length - 1; + while (U - i > 4) + { + int M = (U + i) >> 1; + struct partial_symbol *psym = start[M]; + if (SYMBOL_LINKAGE_NAME (psym)[0] < name[0]) + i = M + 1; + else if (SYMBOL_LINKAGE_NAME (psym)[0] > name[0]) + U = M - 1; + else if (strcmp (SYMBOL_LINKAGE_NAME (psym), name) < 0) + i = M + 1; + else + U = M; + } + } + else + i = 0; - /* Second: Try wild matching... */ + while (i < length) + { + struct partial_symbol *psym = start[i]; - if (!match && wild_match) - { - /* Since we are doing wild matching, this means that TEXT - may represent an unqualified symbol name. We therefore must - also compare TEXT against the unqualified name of the symbol. */ - sym_name = ada_unqualified_name (ada_decode (sym_name)); + if (SYMBOL_DOMAIN (psym) == namespace) + { + int cmp = strncmp (name, SYMBOL_LINKAGE_NAME (psym), name_len); - if (strncmp (sym_name, text, text_len) == 0) - match = 1; - } + if (cmp < 0) + { + if (global) + break; + } + else if (cmp == 0 + && is_name_suffix (SYMBOL_LINKAGE_NAME (psym) + + name_len)) + return psym; + } + i += 1; + } - /* Finally: If we found a mach, prepare the result to return. */ + if (global) + { + int U; + i = 0; + U = length - 1; + while (U - i > 4) + { + int M = (U + i) >> 1; + struct partial_symbol *psym = start[M]; + if (SYMBOL_LINKAGE_NAME (psym)[0] < '_') + i = M + 1; + else if (SYMBOL_LINKAGE_NAME (psym)[0] > '_') + U = M - 1; + else if (strcmp (SYMBOL_LINKAGE_NAME (psym), "_ada_") < 0) + i = M + 1; + else + U = M; + } + } + else + i = 0; - if (!match) - return NULL; + while (i < length) + { + struct partial_symbol *psym = start[i]; - if (verbatim_match) - sym_name = add_angle_brackets (sym_name); + if (SYMBOL_DOMAIN (psym) == namespace) + { + int cmp; - if (!encoded) - sym_name = ada_decode (sym_name); + cmp = (int) '_' - (int) SYMBOL_LINKAGE_NAME (psym)[0]; + if (cmp == 0) + { + cmp = strncmp ("_ada_", SYMBOL_LINKAGE_NAME (psym), 5); + if (cmp == 0) + cmp = strncmp (name, SYMBOL_LINKAGE_NAME (psym) + 5, + name_len); + } - return sym_name; + if (cmp < 0) + { + if (global) + break; + } + else if (cmp == 0 + && is_name_suffix (SYMBOL_LINKAGE_NAME (psym) + + name_len + 5)) + return psym; + } + i += 1; + } + } + return NULL; } -/* A companion function to ada_make_symbol_completion_list(). - Check if SYM_NAME represents a symbol which name would be suitable - to complete TEXT (TEXT_LEN is the length of TEXT), in which case - it is appended at the end of the given string vector SV. +/* Find a symbol table containing symbol SYM or NULL if none. */ - ORIG_TEXT is the string original string from the user command - that needs to be completed. WORD is the entire command on which - completion should be performed. These two parameters are used to - determine which part of the symbol name should be added to the - completion vector. - if WILD_MATCH is set, then wild matching is performed. - ENCODED should be set if TEXT represents a symbol name in its - encoded formed (in which case the completion should also be - encoded). */ - -static void -symbol_completion_add (struct string_vector *sv, - const char *sym_name, - const char *text, int text_len, - const char *orig_text, const char *word, - int wild_match, int encoded) +static struct symtab * +symtab_for_sym (struct symbol *sym) { - const char *match = symbol_completion_match (sym_name, text, text_len, - wild_match, encoded); - char *completion; - - if (match == NULL) - return; - - /* We found a match, so add the appropriate completion to the given - string vector. */ - - if (word == orig_text) - { - completion = xmalloc (strlen (match) + 5); - strcpy (completion, match); - } - else if (word > orig_text) - { - /* Return some portion of sym_name. */ - completion = xmalloc (strlen (match) + 5); - strcpy (completion, match + (word - orig_text)); - } - else - { - /* Return some of ORIG_TEXT plus sym_name. */ - completion = xmalloc (strlen (match) + (orig_text - word) + 5); - strncpy (completion, word, orig_text - word); - completion[orig_text - word] = '\0'; - strcat (completion, match); - } + struct symtab *s; + struct objfile *objfile; + struct block *b; + struct symbol *tmp_sym; + struct dict_iterator iter; + int j; - string_vector_append (sv, completion); + ALL_SYMTABS (objfile, s) + { + switch (SYMBOL_CLASS (sym)) + { + case LOC_CONST: + case LOC_STATIC: + case LOC_TYPEDEF: + case LOC_REGISTER: + case LOC_LABEL: + case LOC_BLOCK: + case LOC_CONST_BYTES: + b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK); + ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym) + return s; + b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK); + ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym) + return s; + break; + default: + break; + } + switch (SYMBOL_CLASS (sym)) + { + case LOC_REGISTER: + case LOC_ARG: + case LOC_REF_ARG: + case LOC_REGPARM: + case LOC_REGPARM_ADDR: + case LOC_LOCAL: + case LOC_TYPEDEF: + case LOC_LOCAL_ARG: + case LOC_BASEREG: + case LOC_BASEREG_ARG: + case LOC_COMPUTED: + case LOC_COMPUTED_ARG: + for (j = FIRST_LOCAL_BLOCK; + j < BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (s)); j += 1) + { + b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), j); + ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym) + return s; + } + break; + default: + break; + } + } + return NULL; } -/* Return a list of possible symbol names completing TEXT0. The list - is NULL terminated. WORD is the entire command on which completion - is made. */ +/* Return a minimal symbol matching NAME according to Ada decoding + rules. Returns NULL if there is no such minimal symbol. Names + prefixed with "standard__" are handled specially: "standard__" is + first stripped off, and only static and global symbols are searched. */ -char ** -ada_make_symbol_completion_list (const char *text0, const char *word) +struct minimal_symbol * +ada_lookup_simple_minsym (const char *name) { - /* Note: This function is almost a copy of make_symbol_completion_list(), - except it has been adapted for Ada. It is somewhat of a shame to - duplicate so much code, but we don't really have the infrastructure - yet to develop a language-aware version of he symbol completer... */ - char *text; - int text_len; - int wild_match; - int encoded; - struct string_vector result = xnew_string_vector (128); - struct symbol *sym; - struct symtab *s; - struct partial_symtab *ps; - struct minimal_symbol *msymbol; struct objfile *objfile; - struct block *b, *surrounding_static_block = 0; - int i; - struct dict_iterator iter; + struct minimal_symbol *msymbol; + int wild_match; - if (text0[0] == '<') + if (strncmp (name, "standard__", sizeof ("standard__") - 1) == 0) { - text = xstrdup (text0); - make_cleanup (xfree, text); - text_len = strlen (text); + name += sizeof ("standard__") - 1; wild_match = 0; - encoded = 1; } else - { - text = xstrdup (ada_encode (text0)); - make_cleanup (xfree, text); - text_len = strlen (text); - for (i = 0; i < text_len; i++) - text[i] = tolower (text[i]); + wild_match = (strstr (name, "__") == NULL); - /* FIXME: brobecker/2003-09-17: When we get rid of ADA_RETAIN_DOTS, - we can restrict the wild_match check to searching "__" only. */ - wild_match = (strstr (text0, "__") == NULL - && strchr (text0, '.') == NULL); - encoded = (strstr (text0, "__") != NULL); - } + ALL_MSYMBOLS (objfile, msymbol) + { + if (ada_match_name (SYMBOL_LINKAGE_NAME (msymbol), name, wild_match) + && MSYMBOL_TYPE (msymbol) != mst_solib_trampoline) + return msymbol; + } - /* First, look at the partial symtab symbols. */ - ALL_PSYMTABS (objfile, ps) - { - struct partial_symbol **psym; + return NULL; +} - /* If the psymtab's been read in we'll get it when we search - through the blockvector. */ - if (ps->readin) - continue; +/* Return up minimal symbol for NAME, folded and encoded according to + Ada conventions, or NULL if none. The last two arguments are ignored. */ - for (psym = objfile->global_psymbols.list + ps->globals_offset; - psym < (objfile->global_psymbols.list + ps->globals_offset - + ps->n_global_syms); - psym++) - { - QUIT; - symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (*psym), - text, text_len, text0, word, - wild_match, encoded); - } +static struct minimal_symbol * +ada_lookup_minimal_symbol (const char *name, const char *sfile, + struct objfile *objf) +{ + return ada_lookup_simple_minsym (ada_encode (name)); +} - for (psym = objfile->static_psymbols.list + ps->statics_offset; - psym < (objfile->static_psymbols.list + ps->statics_offset - + ps->n_static_syms); - psym++) - { - QUIT; - symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (*psym), - text, text_len, text0, word, - wild_match, encoded); - } - } +/* For all subprograms that statically enclose the subprogram of the + selected frame, add symbols matching identifier NAME in DOMAIN + and their blocks to the list of data in OBSTACKP, as for + ada_add_block_symbols (q.v.). If WILD, treat as NAME with a + wildcard prefix. */ - /* At this point scan through the misc symbol vectors and add each - symbol you find to the list. Eventually we want to ignore - anything that isn't a text symbol (everything else will be - handled by the psymtab code above). */ +static void +add_symbols_from_enclosing_procs (struct obstack *obstackp, + const char *name, domain_enum namespace, + int wild_match) +{ +#ifdef HAVE_ADD_SYMBOLS_FROM_ENCLOSING_PROCS + /* Use a heuristic to find the frames of enclosing subprograms: treat the + pointer-sized value at location 0 from the local-variable base of a + frame as a static link, and then search up the call stack for a + frame with that same local-variable base. */ + static struct symbol static_link_sym; + static struct symbol *static_link; + struct value *target_link_val; - ALL_MSYMBOLS (objfile, msymbol) - { - QUIT; - symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (msymbol), - text, text_len, text0, word, - wild_match, encoded); - } + struct cleanup *old_chain = make_cleanup (null_cleanup, NULL); + struct frame_info *frame; - /* Search upwards from currently selected frame (so that we can - complete on local vars. */ + if (! target_has_stack) + return; - for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b)) + if (static_link == NULL) { - if (!BLOCK_SUPERBLOCK (b)) - surrounding_static_block = b; /* For elmin of dups */ - - ALL_BLOCK_SYMBOLS (b, iter, sym) - { - symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (sym), - text, text_len, text0, word, - wild_match, encoded); - } + /* Initialize the local variable symbol that stands for the + static link (when there is one). */ + static_link = &static_link_sym; + SYMBOL_LINKAGE_NAME (static_link) = ""; + SYMBOL_LANGUAGE (static_link) = language_unknown; + SYMBOL_CLASS (static_link) = LOC_LOCAL; + SYMBOL_DOMAIN (static_link) = VAR_DOMAIN; + SYMBOL_TYPE (static_link) = lookup_pointer_type (builtin_type_void); + SYMBOL_VALUE (static_link) = + -(long) TYPE_LENGTH (SYMBOL_TYPE (static_link)); } - /* Go through the symtabs and check the externs and statics for - symbols which match. */ - - ALL_SYMTABS (objfile, s) - { - QUIT; - b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK); - ALL_BLOCK_SYMBOLS (b, iter, sym) - { - symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (sym), - text, text_len, text0, word, - wild_match, encoded); - } - } + frame = get_selected_frame (); + if (frame == NULL + || inside_main_func (get_frame_address_in_block (frame))) + return; - ALL_SYMTABS (objfile, s) - { - QUIT; - b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK); - /* Don't do this block twice. */ - if (b == surrounding_static_block) - continue; - ALL_BLOCK_SYMBOLS (b, iter, sym) - { - symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (sym), - text, text_len, text0, word, - wild_match, encoded); - } - } - - /* Append the closing NULL entry. */ - string_vector_append (&result, NULL); + target_link_val = read_var_value (static_link, frame); + while (target_link_val != NULL + && num_defns_collected (obstackp) == 0 + && frame_relative_level (frame) <= MAX_ENCLOSING_FRAME_LEVELS) + { + CORE_ADDR target_link = value_as_address (target_link_val); - return (result.array); -} + frame = get_prev_frame (frame); + if (frame == NULL) + break; -/* Look, in partial_symtab PST, for symbol NAME in given namespace. - Check the global symbols if GLOBAL, the static symbols if not. - Do wild-card match if WILD. */ + if (get_frame_locals_address (frame) == target_link) + { + struct block *block; + + QUIT; -static struct partial_symbol * -ada_lookup_partial_symbol (struct partial_symtab *pst, const char *name, - int global, domain_enum namespace, int wild) -{ - struct partial_symbol **start; - int name_len = strlen (name); - int length = (global ? pst->n_global_syms : pst->n_static_syms); - int i; + block = get_frame_block (frame, 0); + while (block != NULL && block_function (block) != NULL + && num_defns_collected (obstackp) == 0) + { + QUIT; - if (length == 0) - { - return (NULL); + ada_add_block_symbols (obstackp, block, name, namespace, + NULL, NULL, wild_match); + + block = BLOCK_SUPERBLOCK (block); + } + } } - start = (global ? - pst->objfile->global_psymbols.list + pst->globals_offset : - pst->objfile->static_psymbols.list + pst->statics_offset); - - if (wild) - { - for (i = 0; i < length; i += 1) - { - struct partial_symbol *psym = start[i]; + do_cleanups (old_chain); +#endif +} - if (SYMBOL_DOMAIN (psym) == namespace && - wild_match (name, name_len, SYMBOL_LINKAGE_NAME (psym))) - return psym; - } - return NULL; - } - else - { - if (global) - { - int U; - i = 0; - U = length - 1; - while (U - i > 4) - { - int M = (U + i) >> 1; - struct partial_symbol *psym = start[M]; - if (SYMBOL_LINKAGE_NAME (psym)[0] < name[0]) - i = M + 1; - else if (SYMBOL_LINKAGE_NAME (psym)[0] > name[0]) - U = M - 1; - else if (strcmp (SYMBOL_LINKAGE_NAME (psym), name) < 0) - i = M + 1; - else - U = M; - } - } - else - i = 0; +/* FIXME: The next two routines belong in symtab.c */ - while (i < length) - { - struct partial_symbol *psym = start[i]; +static void restore_language (void* lang) +{ + set_language ((enum language) lang); +} - if (SYMBOL_DOMAIN (psym) == namespace) - { - int cmp = strncmp (name, SYMBOL_LINKAGE_NAME (psym), name_len); +/* As for lookup_symbol, but performed as if the current language + were LANG. */ - if (cmp < 0) - { - if (global) - break; - } - else if (cmp == 0 - && is_name_suffix (SYMBOL_LINKAGE_NAME (psym) - + name_len)) - return psym; - } - i += 1; - } +struct symbol * +lookup_symbol_in_language (const char *name, const struct block *block, + domain_enum domain, enum language lang, + int *is_a_field_of_this, struct symtab **symtab) +{ + struct cleanup *old_chain + = make_cleanup (restore_language, (void*) current_language->la_language); + struct symbol *result; + set_language (lang); + result = lookup_symbol (name, block, domain, is_a_field_of_this, symtab); + do_cleanups (old_chain); + return result; +} - if (global) - { - int U; - i = 0; - U = length - 1; - while (U - i > 4) - { - int M = (U + i) >> 1; - struct partial_symbol *psym = start[M]; - if (SYMBOL_LINKAGE_NAME (psym)[0] < '_') - i = M + 1; - else if (SYMBOL_LINKAGE_NAME (psym)[0] > '_') - U = M - 1; - else if (strcmp (SYMBOL_LINKAGE_NAME (psym), "_ada_") < 0) - i = M + 1; - else - U = M; - } - } - else - i = 0; +/* True if TYPE is definitely an artificial type supplied to a symbol + for which no debugging information was given in the symbol file. */ - while (i < length) - { - struct partial_symbol *psym = start[i]; +static int +is_nondebugging_type (struct type *type) +{ + char *name = ada_type_name (type); + return (name != NULL && strcmp (name, "<variable, no debug info>") == 0); +} - if (SYMBOL_DOMAIN (psym) == namespace) - { - int cmp; +/* Remove any non-debugging symbols in SYMS[0 .. NSYMS-1] that definitely + duplicate other symbols in the list (The only case I know of where + this happens is when object files containing stabs-in-ecoff are + linked with files containing ordinary ecoff debugging symbols (or no + debugging symbols)). Modifies SYMS to squeeze out deleted entries. + Returns the number of items in the modified list. */ - cmp = (int) '_' - (int) SYMBOL_LINKAGE_NAME (psym)[0]; - if (cmp == 0) - { - cmp = strncmp ("_ada_", SYMBOL_LINKAGE_NAME (psym), 5); - if (cmp == 0) - cmp = strncmp (name, SYMBOL_LINKAGE_NAME (psym) + 5, - name_len); - } +static int +remove_extra_symbols (struct ada_symbol_info *syms, int nsyms) +{ + int i, j; - if (cmp < 0) + i = 0; + while (i < nsyms) + { + if (SYMBOL_LINKAGE_NAME (syms[i].sym) != NULL + && SYMBOL_CLASS (syms[i].sym) == LOC_STATIC + && is_nondebugging_type (SYMBOL_TYPE (syms[i].sym))) + { + for (j = 0; j < nsyms; j += 1) + { + if (i != j + && SYMBOL_LINKAGE_NAME (syms[j].sym) != NULL + && strcmp (SYMBOL_LINKAGE_NAME (syms[i].sym), + SYMBOL_LINKAGE_NAME (syms[j].sym)) == 0 + && SYMBOL_CLASS (syms[i].sym) == SYMBOL_CLASS (syms[j].sym) + && SYMBOL_VALUE_ADDRESS (syms[i].sym) + == SYMBOL_VALUE_ADDRESS (syms[j].sym)) { - if (global) - break; + int k; + for (k = i + 1; k < nsyms; k += 1) + syms[k - 1] = syms[k]; + nsyms -= 1; + goto NextSymbol; } - else if (cmp == 0 - && is_name_suffix (SYMBOL_LINKAGE_NAME (psym) - + name_len + 5)) - return psym; } - i += 1; } + i += 1; + NextSymbol: + ; } - return NULL; + return nsyms; } -/* Find a symbol table containing symbol SYM or NULL if none. */ +/* Given a type that corresponds to a renaming entity, use the type name + to extract the scope (package name or function name, fully qualified, + and following the GNAT encoding convention) where this renaming has been + defined. The string returned needs to be deallocated after use. */ -static struct symtab * -symtab_for_sym (struct symbol *sym) +static char * +xget_renaming_scope (struct type *renaming_type) { - struct symtab *s; - struct objfile *objfile; - struct block *b; - struct symbol *tmp_sym; - struct dict_iterator iter; - int j; + /* The renaming types adhere to the following convention: + <scope>__<rename>___<XR extension>. + So, to extract the scope, we search for the "___XR" extension, + and then backtrack until we find the first "__". */ + + const char *name = type_name_no_tag (renaming_type); + char *suffix = strstr (name, "___XR"); + char *last; + int scope_len; + char *scope; - ALL_SYMTABS (objfile, s) - { - switch (SYMBOL_CLASS (sym)) - { - case LOC_CONST: - case LOC_STATIC: - case LOC_TYPEDEF: - case LOC_REGISTER: - case LOC_LABEL: - case LOC_BLOCK: - case LOC_CONST_BYTES: - b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK); - ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym) - return s; - b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK); - ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym) - return s; - break; - default: - break; - } - switch (SYMBOL_CLASS (sym)) - { - case LOC_REGISTER: - case LOC_ARG: - case LOC_REF_ARG: - case LOC_REGPARM: - case LOC_REGPARM_ADDR: - case LOC_LOCAL: - case LOC_TYPEDEF: - case LOC_LOCAL_ARG: - case LOC_BASEREG: - case LOC_BASEREG_ARG: - case LOC_COMPUTED: - case LOC_COMPUTED_ARG: - for (j = FIRST_LOCAL_BLOCK; - j < BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (s)); j += 1) - { - b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), j); - ALL_BLOCK_SYMBOLS (b, iter, tmp_sym) if (sym == tmp_sym) - return s; - } - break; - default: - break; - } - } - return NULL; -} - -/* Return a minimal symbol matching NAME according to Ada decoding - rules. Returns NULL if there is no such minimal symbol. Names - prefixed with "standard__" are handled specially: "standard__" is - first stripped off, and only static and global symbols are searched. */ - -struct minimal_symbol * -ada_lookup_simple_minsym (const char *name) -{ - struct objfile *objfile; - struct minimal_symbol *msymbol; - int wild_match; - - if (strncmp (name, "standard__", sizeof ("standard__") - 1) == 0) - { - name += sizeof ("standard__") - 1; - wild_match = 0; - } - else - wild_match = (strstr (name, "__") == NULL); + /* Now, backtrack a bit until we find the first "__". Start looking + at suffix - 3, as the <rename> part is at least one character long. */ - ALL_MSYMBOLS (objfile, msymbol) - { - if (ada_match_name (SYMBOL_LINKAGE_NAME (msymbol), name, wild_match) - && MSYMBOL_TYPE (msymbol) != mst_solib_trampoline) - return msymbol; - } + for (last = suffix - 3; last > name; last--) + if (last[0] == '_' && last[1] == '_') + break; + + /* Make a copy of scope and return it. */ - return NULL; -} + scope_len = last - name; + scope = (char *) xmalloc ((scope_len + 1) * sizeof (char)); -/* Return up minimal symbol for NAME, folded and encoded according to - Ada conventions, or NULL if none. The last two arguments are ignored. */ + strncpy (scope, name, scope_len); + scope[scope_len] = '\0'; -static struct minimal_symbol * -ada_lookup_minimal_symbol (const char *name, const char *sfile, - struct objfile *objf) -{ - return ada_lookup_simple_minsym (ada_encode (name)); + return scope; } -/* For all subprograms that statically enclose the subprogram of the - selected frame, add symbols matching identifier NAME in DOMAIN - and their blocks to the list of data in OBSTACKP, as for - ada_add_block_symbols (q.v.). If WILD, treat as NAME with a - wildcard prefix. */ +/* Return nonzero if NAME corresponds to a package name. */ -static void -add_symbols_from_enclosing_procs (struct obstack *obstackp, - const char *name, domain_enum namespace, - int wild_match) +static int +is_package_name (const char *name) { -#ifdef HAVE_ADD_SYMBOLS_FROM_ENCLOSING_PROCS - /* Use a heuristic to find the frames of enclosing subprograms: treat the - pointer-sized value at location 0 from the local-variable base of a - frame as a static link, and then search up the call stack for a - frame with that same local-variable base. */ - static struct symbol static_link_sym; - static struct symbol *static_link; - struct value *target_link_val; - - struct cleanup *old_chain = make_cleanup (null_cleanup, NULL); - struct frame_info *frame; + /* Here, We take advantage of the fact that no symbols are generated + for packages, while symbols are generated for each function. + So the condition for NAME represent a package becomes equivalent + to NAME not existing in our list of symbols. There is only one + small complication with library-level functions (see below). */ - if (! target_has_stack) - return; + char *fun_name; + + /* If it is a function that has not been defined at library level, + then we should be able to look it up in the symbols. */ + if (standard_lookup (name, NULL, VAR_DOMAIN) != NULL) + return 0; - if (static_link == NULL) - { - /* Initialize the local variable symbol that stands for the - static link (when there is one). */ - static_link = &static_link_sym; - SYMBOL_LINKAGE_NAME (static_link) = ""; - SYMBOL_LANGUAGE (static_link) = language_unknown; - SYMBOL_CLASS (static_link) = LOC_LOCAL; - SYMBOL_DOMAIN (static_link) = VAR_DOMAIN; - SYMBOL_TYPE (static_link) = lookup_pointer_type (builtin_type_void); - SYMBOL_VALUE (static_link) = - -(long) TYPE_LENGTH (SYMBOL_TYPE (static_link)); - } + /* Library-level function names start with "_ada_". See if function + "_ada_" followed by NAME can be found. */ - frame = get_selected_frame (); - if (frame == NULL - || inside_main_func (get_frame_address_in_block (frame))) - return; + /* Do a quick check that NAME does not contain "__", since library-level + functions names can not contain "__" in them. */ + if (strstr (name, "__") != NULL) + return 0; - target_link_val = read_var_value (static_link, frame); - while (target_link_val != NULL - && num_defns_collected (obstackp) == 0 - && frame_relative_level (frame) <= MAX_ENCLOSING_FRAME_LEVELS) - { - CORE_ADDR target_link = value_as_address (target_link_val); + fun_name = (char *) alloca (strlen (name) + 5 + 1); + xasprintf (&fun_name, "_ada_%s", name); - frame = get_prev_frame (frame); - if (frame == NULL) - break; + return (standard_lookup (fun_name, NULL, VAR_DOMAIN) == NULL); +} - if (get_frame_locals_address (frame) == target_link) - { - struct block *block; - - QUIT; +/* Return nonzero if SYM corresponds to a renaming entity that is + visible from FUNCTION_NAME. */ - block = get_frame_block (frame, 0); - while (block != NULL && block_function (block) != NULL - && num_defns_collected (obstackp) == 0) - { - QUIT; +static int +renaming_is_visible (const struct symbol *sym, char *function_name) +{ + char *scope = xget_renaming_scope (SYMBOL_TYPE (sym)); - ada_add_block_symbols (obstackp, block, name, namespace, - NULL, NULL, wild_match); - - block = BLOCK_SUPERBLOCK (block); - } - } - } + make_cleanup (xfree, scope); - do_cleanups (old_chain); -#endif -} + /* If the rename has been defined in a package, then it is visible. */ + if (is_package_name (scope)) + return 1; -/* FIXME: The next two routines belong in symtab.c */ + /* Check that the rename is in the current function scope by checking + that its name starts with SCOPE. */ + + /* If the function name starts with "_ada_", it means that it is + a library-level function. Strip this prefix before doing the + comparison, as the encoding for the renaming does not contain + this prefix. */ + if (strncmp (function_name, "_ada_", 5) == 0) + function_name += 5; -static void restore_language (void* lang) -{ - set_language ((enum language) lang); + return (strncmp (function_name, scope, strlen (scope)) == 0); } -/* As for lookup_symbol, but performed as if the current language - were LANG. */ - -struct symbol * -lookup_symbol_in_language (const char *name, const struct block *block, - domain_enum domain, enum language lang, - int *is_a_field_of_this, struct symtab **symtab) -{ - struct cleanup *old_chain - = make_cleanup (restore_language, (void*) current_language->la_language); - struct symbol *result; - set_language (lang); - result = lookup_symbol (name, block, domain, is_a_field_of_this, symtab); - do_cleanups (old_chain); - return result; -} +/* Iterates over the SYMS list and remove any entry that corresponds to + a renaming entity that is not visible from the function associated + with CURRENT_BLOCK. + + Rationale: + GNAT emits a type following a specified encoding for each renaming + entity. Unfortunately, STABS currently does not support the definition + of types that are local to a given lexical block, so all renamings types + are emitted at library level. As a consequence, if an application + contains two renaming entities using the same name, and a user tries to + print the value of one of these entities, the result of the ada symbol + lookup will also contain the wrong renaming type. -/* True if TYPE is definitely an artificial type supplied to a symbol - for which no debugging information was given in the symbol file. */ + This function partially covers for this limitation by attempting to + remove from the SYMS list renaming symbols that should be visible + from CURRENT_BLOCK. However, there does not seem be a 100% reliable + method with the current information available. The implementation + below has a couple of limitations (FIXME: brobecker-2003-05-12): + + - When the user tries to print a rename in a function while there + is another rename entity defined in a package: Normally, the + rename in the function has precedence over the rename in the + package, so the latter should be removed from the list. This is + currently not the case. + + - This function will incorrectly remove valid renames if + the CURRENT_BLOCK corresponds to a function which symbol name + has been changed by an "Export" pragma. As a consequence, + the user will be unable to print such rename entities. */ static int -is_nondebugging_type (struct type *type) -{ - char *name = ada_type_name (type); - return (name != NULL && strcmp (name, "<variable, no debug info>") == 0); -} - -/* Remove any non-debugging symbols in SYMS[0 .. NSYMS-1] that definitely - duplicate other symbols in the list (The only case I know of where - this happens is when object files containing stabs-in-ecoff are - linked with files containing ordinary ecoff debugging symbols (or no - debugging symbols)). Modifies SYMS to squeeze out deleted entries. - Returns the number of items in the modified list. */ - -static int -remove_extra_symbols (struct ada_symbol_info *syms, int nsyms) -{ - int i, j; - - i = 0; - while (i < nsyms) - { - if (SYMBOL_LINKAGE_NAME (syms[i].sym) != NULL - && SYMBOL_CLASS (syms[i].sym) == LOC_STATIC - && is_nondebugging_type (SYMBOL_TYPE (syms[i].sym))) - { - for (j = 0; j < nsyms; j += 1) - { - if (i != j - && SYMBOL_LINKAGE_NAME (syms[j].sym) != NULL - && strcmp (SYMBOL_LINKAGE_NAME (syms[i].sym), - SYMBOL_LINKAGE_NAME (syms[j].sym)) == 0 - && SYMBOL_CLASS (syms[i].sym) == SYMBOL_CLASS (syms[j].sym) - && SYMBOL_VALUE_ADDRESS (syms[i].sym) - == SYMBOL_VALUE_ADDRESS (syms[j].sym)) - { - int k; - for (k = i + 1; k < nsyms; k += 1) - syms[k - 1] = syms[k]; - nsyms -= 1; - goto NextSymbol; - } - } - } - i += 1; - NextSymbol: - ; - } - return nsyms; -} - -/* Given a type that corresponds to a renaming entity, use the type name - to extract the scope (package name or function name, fully qualified, - and following the GNAT encoding convention) where this renaming has been - defined. The string returned needs to be deallocated after use. */ - -static char * -xget_renaming_scope (struct type *renaming_type) -{ - /* The renaming types adhere to the following convention: - <scope>__<rename>___<XR extension>. - So, to extract the scope, we search for the "___XR" extension, - and then backtrack until we find the first "__". */ - - const char *name = type_name_no_tag (renaming_type); - char *suffix = strstr (name, "___XR"); - char *last; - int scope_len; - char *scope; - - /* Now, backtrack a bit until we find the first "__". Start looking - at suffix - 3, as the <rename> part is at least one character long. */ - - for (last = suffix - 3; last > name; last--) - if (last[0] == '_' && last[1] == '_') - break; - - /* Make a copy of scope and return it. */ - - scope_len = last - name; - scope = (char *) xmalloc ((scope_len + 1) * sizeof (char)); - - strncpy (scope, name, scope_len); - scope[scope_len] = '\0'; - - return scope; -} - -/* Return nonzero if NAME corresponds to a package name. */ - -static int -is_package_name (const char *name) -{ - /* Here, We take advantage of the fact that no symbols are generated - for packages, while symbols are generated for each function. - So the condition for NAME represent a package becomes equivalent - to NAME not existing in our list of symbols. There is only one - small complication with library-level functions (see below). */ - - char *fun_name; - - /* If it is a function that has not been defined at library level, - then we should be able to look it up in the symbols. */ - if (standard_lookup (name, NULL, VAR_DOMAIN) != NULL) - return 0; - - /* Library-level function names start with "_ada_". See if function - "_ada_" followed by NAME can be found. */ - - /* Do a quick check that NAME does not contain "__", since library-level - functions names can not contain "__" in them. */ - if (strstr (name, "__") != NULL) - return 0; - - fun_name = (char *) alloca (strlen (name) + 5 + 1); - xasprintf (&fun_name, "_ada_%s", name); - - return (standard_lookup (fun_name, NULL, VAR_DOMAIN) == NULL); -} - -/* Return nonzero if SYM corresponds to a renaming entity that is - visible from FUNCTION_NAME. */ - -static int -renaming_is_visible (const struct symbol *sym, char *function_name) -{ - char *scope = xget_renaming_scope (SYMBOL_TYPE (sym)); - - make_cleanup (xfree, scope); - - /* If the rename has been defined in a package, then it is visible. */ - if (is_package_name (scope)) - return 1; - - /* Check that the rename is in the current function scope by checking - that its name starts with SCOPE. */ - - /* If the function name starts with "_ada_", it means that it is - a library-level function. Strip this prefix before doing the - comparison, as the encoding for the renaming does not contain - this prefix. */ - if (strncmp (function_name, "_ada_", 5) == 0) - function_name += 5; - - return (strncmp (function_name, scope, strlen (scope)) == 0); -} - -/* Iterates over the SYMS list and remove any entry that corresponds to - a renaming entity that is not visible from the function associated - with CURRENT_BLOCK. - - Rationale: - GNAT emits a type following a specified encoding for each renaming - entity. Unfortunately, STABS currently does not support the definition - of types that are local to a given lexical block, so all renamings types - are emitted at library level. As a consequence, if an application - contains two renaming entities using the same name, and a user tries to - print the value of one of these entities, the result of the ada symbol - lookup will also contain the wrong renaming type. - - This function partially covers for this limitation by attempting to - remove from the SYMS list renaming symbols that should be visible - from CURRENT_BLOCK. However, there does not seem be a 100% reliable - method with the current information available. The implementation - below has a couple of limitations (FIXME: brobecker-2003-05-12): - - - When the user tries to print a rename in a function while there - is another rename entity defined in a package: Normally, the - rename in the function has precedence over the rename in the - package, so the latter should be removed from the list. This is - currently not the case. - - - This function will incorrectly remove valid renames if - the CURRENT_BLOCK corresponds to a function which symbol name - has been changed by an "Export" pragma. As a consequence, - the user will be unable to print such rename entities. */ - -static int -remove_out_of_scope_renamings (struct ada_symbol_info *syms, - int nsyms, - struct block *current_block) +remove_out_of_scope_renamings (struct ada_symbol_info *syms, + int nsyms, + struct block *current_block) { struct symbol *current_function; char *current_function_name; @@ -5179,166 +4965,460 @@ wild_match (const char *patn0, int patn_ name += 1; name_len -= 1; } - } - - return 0; -} + } + + return 0; +} + + +/* Add symbols from BLOCK matching identifier NAME in DOMAIN to + vector *defn_symbols, updating the list of symbols in OBSTACKP + (if necessary). If WILD, treat as NAME with a wildcard prefix. + OBJFILE is the section containing BLOCK. + SYMTAB is recorded with each symbol added. */ + +static void +ada_add_block_symbols (struct obstack *obstackp, + struct block *block, const char *name, + domain_enum domain, struct objfile *objfile, + struct symtab *symtab, int wild) +{ + struct dict_iterator iter; + int name_len = strlen (name); + /* A matching argument symbol, if any. */ + struct symbol *arg_sym; + /* Set true when we find a matching non-argument symbol. */ + int found_sym; + struct symbol *sym; + + arg_sym = NULL; + found_sym = 0; + if (wild) + { + struct symbol *sym; + ALL_BLOCK_SYMBOLS (block, iter, sym) + { + if (SYMBOL_DOMAIN (sym) == domain && + wild_match (name, name_len, SYMBOL_LINKAGE_NAME (sym))) + { + switch (SYMBOL_CLASS (sym)) + { + case LOC_ARG: + case LOC_LOCAL_ARG: + case LOC_REF_ARG: + case LOC_REGPARM: + case LOC_REGPARM_ADDR: + case LOC_BASEREG_ARG: + case LOC_COMPUTED_ARG: + arg_sym = sym; + break; + case LOC_UNRESOLVED: + continue; + default: + found_sym = 1; + add_defn_to_vec (obstackp, + fixup_symbol_section (sym, objfile), + block, symtab); + break; + } + } + } + } + else + { + ALL_BLOCK_SYMBOLS (block, iter, sym) + { + if (SYMBOL_DOMAIN (sym) == domain) + { + int cmp = strncmp (name, SYMBOL_LINKAGE_NAME (sym), name_len); + if (cmp == 0 + && is_name_suffix (SYMBOL_LINKAGE_NAME (sym) + name_len)) + { + switch (SYMBOL_CLASS (sym)) + { + case LOC_ARG: + case LOC_LOCAL_ARG: + case LOC_REF_ARG: + case LOC_REGPARM: + case LOC_REGPARM_ADDR: + case LOC_BASEREG_ARG: + case LOC_COMPUTED_ARG: + arg_sym = sym; + break; + case LOC_UNRESOLVED: + break; + default: + found_sym = 1; + add_defn_to_vec (obstackp, + fixup_symbol_section (sym, objfile), + block, symtab); + break; + } + } + } + } + } + + if (!found_sym && arg_sym != NULL) + { + add_defn_to_vec (obstackp, + fixup_symbol_section (arg_sym, objfile), + block, symtab); + } + + if (!wild) + { + arg_sym = NULL; + found_sym = 0; + + ALL_BLOCK_SYMBOLS (block, iter, sym) + { + if (SYMBOL_DOMAIN (sym) == domain) + { + int cmp; + + cmp = (int) '_' - (int) SYMBOL_LINKAGE_NAME (sym)[0]; + if (cmp == 0) + { + cmp = strncmp ("_ada_", SYMBOL_LINKAGE_NAME (sym), 5); + if (cmp == 0) + cmp = strncmp (name, SYMBOL_LINKAGE_NAME (sym) + 5, + name_len); + } + + if (cmp == 0 + && is_name_suffix (SYMBOL_LINKAGE_NAME (sym) + name_len + 5)) + { + switch (SYMBOL_CLASS (sym)) + { + case LOC_ARG: + case LOC_LOCAL_ARG: + case LOC_REF_ARG: + case LOC_REGPARM: + case LOC_REGPARM_ADDR: + case LOC_BASEREG_ARG: + case LOC_COMPUTED_ARG: + arg_sym = sym; + break; + case LOC_UNRESOLVED: + break; + default: + found_sym = 1; + add_defn_to_vec (obstackp, + fixup_symbol_section (sym, objfile), + block, symtab); + break; + } + } + } + end_loop2: ; + } + + /* NOTE: This really shouldn't be needed for _ada_ symbols. + They aren't parameters, right? */ + if (!found_sym && arg_sym != NULL) + { + add_defn_to_vec (obstackp, + fixup_symbol_section (arg_sym, objfile), + block, symtab); + } + } +} +\f +#ifdef GNAT_GDB + + /* Symbol Completion */ + +/* If SYM_NAME is a completion candidate for TEXT, return this symbol + name in a form that's appropriate for the completion. The result + does not need to be deallocated, but is only good until the next call. + + TEXT_LEN is equal to the length of TEXT. + Perform a wild match if WILD_MATCH is set. + ENCODED should be set if TEXT represents the start of a symbol name + in its encoded form. */ + +static const char * +symbol_completion_match (const char *sym_name, + const char *text, int text_len, + int wild_match, int encoded) +{ + char *result; + const int verbatim_match = (text[0] == '<'); + int match = 0; + + if (verbatim_match) + { + /* Strip the leading angle bracket. */ + text = text + 1; + text_len--; + } + + /* First, test against the fully qualified name of the symbol. */ + + if (strncmp (sym_name, text, text_len) == 0) + match = 1; + + if (match && !encoded) + { + /* One needed check before declaring a positive match is to verify + that iff we are doing a verbatim match, the decoded version + of the symbol name starts with '<'. Otherwise, this symbol name + is not a suitable completion. */ + const char *sym_name_copy = sym_name; + int has_angle_bracket; + + sym_name = ada_decode (sym_name); + has_angle_bracket = (sym_name [0] == '<'); + match = (has_angle_bracket == verbatim_match); + sym_name = sym_name_copy; + } + + if (match && !verbatim_match) + { + /* When doing non-verbatim match, another check that needs to + be done is to verify that the potentially matching symbol name + does not include capital letters, because the ada-mode would + not be able to understand these symbol names without the + angle bracket notation. */ + const char *tmp; + + for (tmp = sym_name; *tmp != '\0' && !isupper (*tmp); tmp++); + if (*tmp != '\0') + match = 0; + } + + /* Second: Try wild matching... */ + + if (!match && wild_match) + { + /* Since we are doing wild matching, this means that TEXT + may represent an unqualified symbol name. We therefore must + also compare TEXT against the unqualified name of the symbol. */ + sym_name = ada_unqualified_name (ada_decode (sym_name)); + + if (strncmp (sym_name, text, text_len) == 0) + match = 1; + } + + /* Finally: If we found a mach, prepare the result to return. */ + + if (!match) + return NULL; + + if (verbatim_match) + sym_name = add_angle_brackets (sym_name); + + if (!encoded) + sym_name = ada_decode (sym_name); + + return sym_name; +} + +/* A companion function to ada_make_symbol_completion_list(). + Check if SYM_NAME represents a symbol which name would be suitable + to complete TEXT (TEXT_LEN is the length of TEXT), in which case + it is appended at the end of the given string vector SV. + + ORIG_TEXT is the string original string from the user command + that needs to be completed. WORD is the entire command on which + completion should be performed. These two parameters are used to + determine which part of the symbol name should be added to the + completion vector. + if WILD_MATCH is set, then wild matching is performed. + ENCODED should be set if TEXT represents a symbol name in its + encoded formed (in which case the completion should also be + encoded). */ + +static void +symbol_completion_add (struct string_vector *sv, + const char *sym_name, + const char *text, int text_len, + const char *orig_text, const char *word, + int wild_match, int encoded) +{ + const char *match = symbol_completion_match (sym_name, text, text_len, + wild_match, encoded); + char *completion; + + if (match == NULL) + return; + + /* We found a match, so add the appropriate completion to the given + string vector. */ + + if (word == orig_text) + { + completion = xmalloc (strlen (match) + 5); + strcpy (completion, match); + } + else if (word > orig_text) + { + /* Return some portion of sym_name. */ + completion = xmalloc (strlen (match) + 5); + strcpy (completion, match + (word - orig_text)); + } + else + { + /* Return some of ORIG_TEXT plus sym_name. */ + completion = xmalloc (strlen (match) + (orig_text - word) + 5); + strncpy (completion, word, orig_text - word); + completion[orig_text - word] = '\0'; + strcat (completion, match); + } + + string_vector_append (sv, completion); +} + +/* Return a list of possible symbol names completing TEXT0. The list + is NULL terminated. WORD is the entire command on which completion + is made. */ + +char ** +ada_make_symbol_completion_list (const char *text0, const char *word) +{ + /* Note: This function is almost a copy of make_symbol_completion_list(), + except it has been adapted for Ada. It is somewhat of a shame to + duplicate so much code, but we don't really have the infrastructure + yet to develop a language-aware version of he symbol completer... */ + char *text; + int text_len; + int wild_match; + int encoded; + struct string_vector result = xnew_string_vector (128); + struct symbol *sym; + struct symtab *s; + struct partial_symtab *ps; + struct minimal_symbol *msymbol; + struct objfile *objfile; + struct block *b, *surrounding_static_block = 0; + int i; + struct dict_iterator iter; + + if (text0[0] == '<') + { + text = xstrdup (text0); + make_cleanup (xfree, text); + text_len = strlen (text); + wild_match = 0; + encoded = 1; + } + else + { + text = xstrdup (ada_encode (text0)); + make_cleanup (xfree, text); + text_len = strlen (text); + for (i = 0; i < text_len; i++) + text[i] = tolower (text[i]); + + /* FIXME: brobecker/2003-09-17: When we get rid of ADA_RETAIN_DOTS, + we can restrict the wild_match check to searching "__" only. */ + wild_match = (strstr (text0, "__") == NULL + && strchr (text0, '.') == NULL); + encoded = (strstr (text0, "__") != NULL); + } + + /* First, look at the partial symtab symbols. */ + ALL_PSYMTABS (objfile, ps) + { + struct partial_symbol **psym; + + /* If the psymtab's been read in we'll get it when we search + through the blockvector. */ + if (ps->readin) + continue; + + for (psym = objfile->global_psymbols.list + ps->globals_offset; + psym < (objfile->global_psymbols.list + ps->globals_offset + + ps->n_global_syms); + psym++) + { + QUIT; + symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (*psym), + text, text_len, text0, word, + wild_match, encoded); + } + + for (psym = objfile->static_psymbols.list + ps->statics_offset; + psym < (objfile->static_psymbols.list + ps->statics_offset + + ps->n_static_syms); + psym++) + { + QUIT; + symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (*psym), + text, text_len, text0, word, + wild_match, encoded); + } + } + /* At this point scan through the misc symbol vectors and add each + symbol you find to the list. Eventually we want to ignore + anything that isn't a text symbol (everything else will be + handled by the psymtab code above). */ -/* Add symbols from BLOCK matching identifier NAME in DOMAIN to - vector *defn_symbols, updating the list of symbols in OBSTACKP - (if necessary). If WILD, treat as NAME with a wildcard prefix. - OBJFILE is the section containing BLOCK. - SYMTAB is recorded with each symbol added. */ + ALL_MSYMBOLS (objfile, msymbol) + { + QUIT; + symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (msymbol), + text, text_len, text0, word, + wild_match, encoded); + } -static void -ada_add_block_symbols (struct obstack *obstackp, - struct block *block, const char *name, - domain_enum domain, struct objfile *objfile, - struct symtab *symtab, int wild) -{ - struct dict_iterator iter; - int name_len = strlen (name); - /* A matching argument symbol, if any. */ - struct symbol *arg_sym; - /* Set true when we find a matching non-argument symbol. */ - int found_sym; - struct symbol *sym; + /* Search upwards from currently selected frame (so that we can + complete on local vars. */ - arg_sym = NULL; - found_sym = 0; - if (wild) - { - struct symbol *sym; - ALL_BLOCK_SYMBOLS (block, iter, sym) - { - if (SYMBOL_DOMAIN (sym) == domain && - wild_match (name, name_len, SYMBOL_LINKAGE_NAME (sym))) - { - switch (SYMBOL_CLASS (sym)) - { - case LOC_ARG: - case LOC_LOCAL_ARG: - case LOC_REF_ARG: - case LOC_REGPARM: - case LOC_REGPARM_ADDR: - case LOC_BASEREG_ARG: - case LOC_COMPUTED_ARG: - arg_sym = sym; - break; - case LOC_UNRESOLVED: - continue; - default: - found_sym = 1; - add_defn_to_vec (obstackp, - fixup_symbol_section (sym, objfile), - block, symtab); - break; - } - } - } - } - else + for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b)) { - ALL_BLOCK_SYMBOLS (block, iter, sym) + if (!BLOCK_SUPERBLOCK (b)) + surrounding_static_block = b; /* For elmin of dups */ + + ALL_BLOCK_SYMBOLS (b, iter, sym) { - if (SYMBOL_DOMAIN (sym) == domain) - { - int cmp = strncmp (name, SYMBOL_LINKAGE_NAME (sym), name_len); - if (cmp == 0 - && is_name_suffix (SYMBOL_LINKAGE_NAME (sym) + name_len)) - { - switch (SYMBOL_CLASS (sym)) - { - case LOC_ARG: - case LOC_LOCAL_ARG: - case LOC_REF_ARG: - case LOC_REGPARM: - case LOC_REGPARM_ADDR: - case LOC_BASEREG_ARG: - case LOC_COMPUTED_ARG: - arg_sym = sym; - break; - case LOC_UNRESOLVED: - break; - default: - found_sym = 1; - add_defn_to_vec (obstackp, - fixup_symbol_section (sym, objfile), - block, symtab); - break; - } - } - } + symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (sym), + text, text_len, text0, word, + wild_match, encoded); } } - if (!found_sym && arg_sym != NULL) - { - add_defn_to_vec (obstackp, - fixup_symbol_section (arg_sym, objfile), - block, symtab); - } - - if (!wild) - { - arg_sym = NULL; - found_sym = 0; + /* Go through the symtabs and check the externs and statics for + symbols which match. */ - ALL_BLOCK_SYMBOLS (block, iter, sym) - { - if (SYMBOL_DOMAIN (sym) == domain) - { - int cmp; + ALL_SYMTABS (objfile, s) + { + QUIT; + b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK); + ALL_BLOCK_SYMBOLS (b, iter, sym) + { + symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (sym), + text, text_len, text0, word, + wild_match, encoded); + } + } - cmp = (int) '_' - (int) SYMBOL_LINKAGE_NAME (sym)[0]; - if (cmp == 0) - { - cmp = strncmp ("_ada_", SYMBOL_LINKAGE_NAME (sym), 5); - if (cmp == 0) - cmp = strncmp (name, SYMBOL_LINKAGE_NAME (sym) + 5, - name_len); - } + ALL_SYMTABS (objfile, s) + { + QUIT; + b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK); + /* Don't do this block twice. */ + if (b == surrounding_static_block) + continue; + ALL_BLOCK_SYMBOLS (b, iter, sym) + { + symbol_completion_add (&result, SYMBOL_LINKAGE_NAME (sym), + text, text_len, text0, word, + wild_match, encoded); + } + } - if (cmp == 0 - && is_name_suffix (SYMBOL_LINKAGE_NAME (sym) + name_len + 5)) - { - switch (SYMBOL_CLASS (sym)) - { - case LOC_ARG: - case LOC_LOCAL_ARG: - case LOC_REF_ARG: - case LOC_REGPARM: - case LOC_REGPARM_ADDR: - case LOC_BASEREG_ARG: - case LOC_COMPUTED_ARG: - arg_sym = sym; - break; - case LOC_UNRESOLVED: - break; - default: - found_sym = 1; - add_defn_to_vec (obstackp, - fixup_symbol_section (sym, objfile), - block, symtab); - break; - } - } - } - end_loop2: ; - } + /* Append the closing NULL entry. */ + string_vector_append (&result, NULL); - /* NOTE: This really shouldn't be needed for _ada_ symbols. - They aren't parameters, right? */ - if (!found_sym && arg_sym != NULL) - { - add_defn_to_vec (obstackp, - fixup_symbol_section (arg_sym, objfile), - block, symtab); - } - } + return (result.array); } + +#endif /* GNAT_GDB */ \f +#ifdef GNAT_GDB /* Breakpoint-related */ /* Import message from symtab.c. */ @@ -6041,37 +6121,6 @@ extended_canonical_line_spec (struct sym return r; } -/* If the main procedure is written in Ada, then return its name. - The result is good until the next call. Return NULL if the main - procedure doesn't appear to be in Ada. */ - -char * -ada_main_name (void) -{ - struct minimal_symbol *msym; - CORE_ADDR main_program_name_addr; - static char main_program_name[1024]; - /* For Ada, the name of the main procedure is stored in a specific - string constant, generated by the binder. Look for that symbol, - extract its address, and then read that string. If we didn't find - that string, then most probably the main procedure is not written - in Ada. */ - msym = lookup_minimal_symbol (ADA_MAIN_PROGRAM_SYMBOL_NAME, NULL, NULL); - - if (msym != NULL) - { - main_program_name_addr = SYMBOL_VALUE_ADDRESS (msym); - if (main_program_name_addr == 0) - error ("Invalid address for Ada main program name."); - - extract_string (main_program_name_addr, main_program_name); - return main_program_name; - } - - /* The main procedure doesn't seem to be in Ada. */ - return NULL; -} - /* Return type of Ada breakpoint associated with bp_stat: 0 if not an Ada-specific breakpoint, 1 for break on specific exception, 2 for break on unhandled exception, 3 for assert. */ @@ -6079,12 +6128,8 @@ ada_main_name (void) static int ada_exception_breakpoint_type (bpstat bs) { -#ifdef GNAT_GDB return ((! bs || ! bs->breakpoint_at) ? 0 : bs->breakpoint_at->break_on_exception); -#else - return 0; -#endif } /* True iff FRAME is very likely to be that of a function that is @@ -6285,7 +6330,6 @@ exception_name_from_cond (const char *co int ada_print_exception_breakpoint_nontask (struct breakpoint *b) { -#ifdef GNAT_GDB if (b->break_on_exception == 1) { if (b->cond_string) /* the breakpoint is on a specific exception. */ @@ -6314,9 +6358,6 @@ ada_print_exception_breakpoint_nontask ( else return 0; return 1; -#else - return 0; -#endif } /* Print task identifier for breakpoint B, if it is an Ada-specific @@ -6325,13 +6366,11 @@ ada_print_exception_breakpoint_nontask ( void ada_print_exception_breakpoint_task (struct breakpoint *b) { -#ifdef GNAT_GDB if (b->task != 0) { ui_out_text (uiout, " task "); ui_out_field_int (uiout, "task", b->task); } -#endif } int @@ -6476,8 +6515,8 @@ ada_breakpoint_rewrite (char *arg, int * } return arg; } +#endif \f - /* Field Access */ /* True if field number FIELD_NUM in struct or union type TYPE is supposed @@ -10098,7 +10137,7 @@ const struct language_defn ada_language_ #ifdef GNAT_GDB ada_lookup_symbol, ada_lookup_minimal_symbol, -#endif +#endif /* GNAT_GDB */ &ada_exp_descriptor, parse, ada_error, @@ -10134,7 +10173,7 @@ const struct language_defn ada_language_ #ifdef GNAT_GDB ada_translate_error_message, /* Substitute Ada-specific terminology in errors and warnings. */ -#endif +#endif /* GNAT_GDB */ LANG_MAGIC }; @@ -10186,17 +10225,17 @@ _initialize_ada_language (void) deprecated_register_gdbarch_swap (NULL, 0, build_ada_types); add_language (&ada_language_defn); + varsize_limit = 65536; #ifdef GNAT_GDB add_show_from_set (add_set_cmd ("varsize-limit", class_support, var_uinteger, (char *) &varsize_limit, "Set maximum bytes in dynamic-sized object.", &setlist), &showlist); -#endif - varsize_limit = 65536; + obstack_init (&cache_space); +#endif /* GNAT_GDB */ obstack_init (&symbol_list_obstack); - obstack_init (&cache_space); decoded_names_store = htab_create_alloc_ex (256, htab_hash_string, (int (*) (const void *, const void *)) streq, Index: gdb/ada-lang.h =================================================================== RCS file: /cvs/src/src/gdb/ada-lang.h,v retrieving revision 1.8 diff -u -p -r1.8 ada-lang.h --- gdb/ada-lang.h 8 Jun 2004 08:42:04 -0000 1.8 +++ gdb/ada-lang.h 16 Jun 2004 08:10:22 -0000 @@ -124,6 +124,41 @@ struct ada_symbol_info { struct symtab* symtab; }; +/* Ada task structures. */ + +/* Ada task control block, as defined in the GNAT runt-time library. */ + +struct task_control_block +{ + char state; + CORE_ADDR parent; + int priority; + char image [32]; + int image_len; /* This field is not always present in the ATCB. */ + CORE_ADDR call; + CORE_ADDR thread; + CORE_ADDR lwp; /* This field is not always present in the ATCB. */ +}; + +struct task_ptid +{ + int pid; /* The Process id */ + long lwp; /* The Light Weight Process id */ + long tid; /* The Thread id */ +}; +typedef struct task_ptid task_ptid_t; + +struct task_entry +{ + CORE_ADDR task_id; + struct task_control_block atcb; + int task_num; + int known_tasks_index; + struct task_entry *next_task; + task_ptid_t task_ptid; + int stack_per; +}; + extern struct type *builtin_type_ada_int; extern struct type *builtin_type_ada_short; extern struct type *builtin_type_ada_long; @@ -136,9 +171,13 @@ extern struct type *builtin_type_ada_nat extern struct type *builtin_type_ada_positive; extern struct type *builtin_type_ada_system_address; -/* The maximum number of tasks known to the Ada runtime */ +/* The maximum number of tasks known to the Ada runtime. */ extern const int MAX_NUMBER_OF_KNOWN_TASKS; +/* task entry list. */ +extern struct task_entry *task_list; + + /* Assuming V points to an array of S objects, make sure that it contains at least M objects, updating V and S as necessary. */ @@ -393,6 +432,8 @@ extern void ada_find_printable_frame (st extern void ada_reset_thread_registers (void); +extern int ada_build_task_list (void); + /* Look up a symbol by name using the search conventions of a specific language (optional block, optional symtab). FIXME: Should be symtab.h. */ @@ -403,5 +444,4 @@ extern struct symbol *lookup_symbol_in_l enum language, int *, struct symtab **); - #endif Index: gdb/ada-tasks.c =================================================================== RCS file: /cvs/src/src/gdb/ada-tasks.c,v retrieving revision 1.9 diff -u -p -r1.9 ada-tasks.c --- gdb/ada-tasks.c 2 Jun 2004 09:55:36 -0000 1.9 +++ gdb/ada-tasks.c 16 Jun 2004 08:10:22 -0000 @@ -62,18 +62,6 @@ enum task_states Master_Phase_2_Sleep }; -struct task_control_block -{ - char state; - CORE_ADDR parent; - int priority; - char image [32]; - int image_len; /* This field is not always present in the ATCB. */ - CORE_ADDR call; - CORE_ADDR thread; - CORE_ADDR lwp; /* This field is not always present in the ATCB. */ -}; - /* The index of certain important fields in the Ada Task Control Block record and sub-records. */ @@ -102,25 +90,6 @@ struct tcb_fieldnos #define TASK_LWP(atcb) extract_unsigned_integer (&(atcb).lwp, sizeof ((atcb).lwp)) #endif -struct task_ptid -{ - int pid; /* The Process id */ - long lwp; /* The Light Weight Process id */ - long tid; /* The Thread id */ -}; -typedef struct task_ptid task_ptid_t; - -struct task_entry -{ - CORE_ADDR task_id; - struct task_control_block atcb; - int task_num; - int known_tasks_index; - struct task_entry *next_task; - task_ptid_t task_ptid; - int stack_per; -}; - /* FIXME: move all this conditional compilation in description files or in configure.in */ @@ -267,7 +236,6 @@ static void get_tcb_call_type_info (stru int *atcb_call_self_fieldno); static CORE_ADDR get_known_tasks_addr (void); static int read_known_tasks_array (void); -static int build_task_list (void); static void value_as_string (char *dest, struct value *val, int length); static struct task_control_block read_atcb (CORE_ADDR atcb_addr); static CORE_ADDR read_caller (const CORE_ADDR call); @@ -283,9 +251,9 @@ static void ada_tasks_attach_observers ( int ada__tasks_check_symbol_table = 1; CORE_ADDR pthread_kern_addr = 0; +struct task_entry *task_list = NULL; /* Local global variables. */ -static struct task_entry *task_list = NULL; /* When non-zero, this flag indicates that the current task_list is obsolete, and should be recomputed before it is accessed. */ @@ -850,8 +818,8 @@ read_known_tasks_array (void) the inferior. Prints an appropriate message and returns non-zero if it failed to build this list. */ -static int -build_task_list (void) +int +ada_build_task_list (void) { if (!target_has_stack) error ("No stack"); @@ -1306,7 +1274,7 @@ info_tasks (char *arg, int from_tty) static void info_tasks_command (char *arg, int from_tty) { - const int task_list_built = build_task_list (); + const int task_list_built = ada_build_task_list (); if (!task_list_built) return; @@ -1358,13 +1326,10 @@ switch_to_task (struct task_entry *new_t select_frame (get_current_frame ()); return ret_code; } - else if (task_ptid_get_pid (new_task->task_ptid) != 0) /* ?? */ - { - switch_to_thread (task_ptid_get_ptid (new_task->task_ptid)); - return 0; - } + + switch_to_thread (task_ptid_get_ptid (new_task->task_ptid)); #endif - return -1; + return 0; } /* Print a message telling the user id of the current task. @@ -1412,7 +1377,7 @@ task_command_1 (char *tidstr, int from_t static void task_command (char *tidstr, int from_tty) { - const int task_list_built = build_task_list (); + const int task_list_built = ada_build_task_list (); if (!task_list_built) return; ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH]: Further updates to ada-* files 2004-06-16 8:34 ` [PATCH]: Further updates to ada-* files Paul Hilfinger @ 2004-06-27 0:10 ` Andrew Cagney 2004-06-27 8:56 ` Paul Hilfinger 0 siblings, 1 reply; 21+ messages in thread From: Andrew Cagney @ 2004-06-27 0:10 UTC (permalink / raw) To: Paul Hilfinger; +Cc: gdb-patches > I have committed the following patch to some Ada files, first to keep > up-to-date with ACT's sources, and second to conditionalize out a > bunch of source code that we are not yet using in the public version > for the benefit of reviewers. (It seems everyone else has taken a step back :-/ ) Lets start with the obvious, can you fix the ARI problems (Run 'gdb_ari.sh -Wari' from http://sources.redhat.com/gdb/ari/)? Looking over the code, ada-tasks.c is going to be a problem. Can we ignore that for now (removing it?) and just focus on getting basic language support enabled? Once that's done, we can start working through the underlying issues that prompted ACT to add ada-tasks.c. Did that previous ChangeLog problem get fixed? Andrew ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH]: Further updates to ada-* files 2004-06-27 0:10 ` Andrew Cagney @ 2004-06-27 8:56 ` Paul Hilfinger 2004-06-28 14:47 ` Andrew Cagney 0 siblings, 1 reply; 21+ messages in thread From: Paul Hilfinger @ 2004-06-27 8:56 UTC (permalink / raw) To: cagney; +Cc: gdb-patches Andrew, > Lets start with the obvious, can you fix the ARI problems (Run > 'gdb_ari.sh -Wari' from http://sources.redhat.com/gdb/ari/)? OK > Looking over the code, ada-tasks.c is going to be a problem. Can we > ignore that for now (removing it?) and just focus on getting basic > language support enabled? Once that's done, we can start working > through the underlying issues that prompted ACT to add ada-tasks.c. Right. I disabled it (i.e., it's not compiled) in the latest version of the patch I sent, and do not expect it to be reviewed. We've decided that now is as good a time as any to do a much-needed major revision of ada-tasks.c; I'm not sure right now if I want to remove the source entirely from the repository. Depends on how major a change I need. The "underlying issues" are that Ada has tasks and they are (in general) built on top of, but in principle distinct from threads. As for why to put it in a separate file---well it's messy, due to the fact that tasks map onto threads differently on every single confounded platform, it seems. > Did that previous ChangeLog problem get fixed? Not yet, but I haven't forgotten it. It must go in, but I fear it will be of no help for the current task. Paul Hilfinger ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH]: Further updates to ada-* files 2004-06-27 8:56 ` Paul Hilfinger @ 2004-06-28 14:47 ` Andrew Cagney 0 siblings, 0 replies; 21+ messages in thread From: Andrew Cagney @ 2004-06-28 14:47 UTC (permalink / raw) To: Paul Hilfinger; +Cc: gdb-patches > Andrew, > > >>> Lets start with the obvious, can you fix the ARI problems (Run >>> 'gdb_ari.sh -Wari' from http://sources.redhat.com/gdb/ari/)? > > > OK > > >>> Looking over the code, ada-tasks.c is going to be a problem. Can we >>> ignore that for now (removing it?) and just focus on getting basic >>> language support enabled? Once that's done, we can start working >>> through the underlying issues that prompted ACT to add ada-tasks.c. > > > Right. I disabled it (i.e., it's not compiled) in the latest version > of the patch I sent, and do not expect it to be reviewed. We've > decided that now is as good a time as any to do a much-needed major > revision of ada-tasks.c; I'm not sure right now if I want to remove > the source entirely from the repository. Depends on how major a > change I need. Lets remove it. The question is how big a thread model change GDB is going to get (and regardless of Ada's task model) and how much having that dead code would confuse things. > The "underlying issues" are that Ada has tasks and they are (in general) > built on top of, but in principle distinct from threads. As for why to > put it in a separate file---well it's messy, due to the fact that > tasks map onto threads differently on every single confounded platform, > it seems. It's messy because the underlying thread model is bug---d. >>> Did that previous ChangeLog problem get fixed? > > > Not yet, but I haven't forgotten it. It must go in, but I fear it will be > of no help for the current task. Andrew ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFA]: Turn on Ada support, take 2 @ 2004-08-11 10:42 Paul Hilfinger 2004-08-11 23:08 ` Andrew Cagney 0 siblings, 1 reply; 21+ messages in thread From: Paul Hilfinger @ 2004-08-11 10:42 UTC (permalink / raw) To: gdb-patches Ping. The current status of this patch is that review of the ada-* files themselves is still pending. If Joel and I need to do anything to them, we'll be happy to do so, but we can't review them. Paul Hilfinger ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [RFA]: Turn on Ada support, take 2 2004-08-11 10:42 [RFA]: Turn on Ada support, take 2 Paul Hilfinger @ 2004-08-11 23:08 ` Andrew Cagney 0 siblings, 0 replies; 21+ messages in thread From: Andrew Cagney @ 2004-08-11 23:08 UTC (permalink / raw) To: Paul Hilfinger; +Cc: gdb-patches FYI, I was working through the #ifdef's, knocking each off in turn. Andrew ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2004-08-11 23:08 UTC | newest] Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-06-08 9:08 [RFA]: Turn on Ada support Paul Hilfinger 2004-06-08 22:15 ` Eli Zaretskii 2004-06-09 9:23 ` Paul Hilfinger 2004-06-09 18:25 ` Eli Zaretskii 2004-06-10 9:40 ` Paul Hilfinger 2004-06-09 7:24 ` Jim Blandy 2004-06-09 9:40 ` Paul Hilfinger 2004-06-09 13:12 ` Daniel Jacobowitz 2004-06-09 13:40 ` Andrew Cagney 2004-06-09 16:21 ` Jim Blandy 2004-06-10 9:50 ` Paul Hilfinger 2004-06-16 8:42 ` [RFA]: Turn on Ada support, take 2 Paul Hilfinger 2004-06-16 18:07 ` Eli Zaretskii 2004-06-17 5:24 ` Paul Hilfinger 2004-06-17 17:48 ` Eli Zaretskii 2004-06-16 8:34 ` [PATCH]: Further updates to ada-* files Paul Hilfinger 2004-06-27 0:10 ` Andrew Cagney 2004-06-27 8:56 ` Paul Hilfinger 2004-06-28 14:47 ` Andrew Cagney 2004-08-11 10:42 [RFA]: Turn on Ada support, take 2 Paul Hilfinger 2004-08-11 23:08 ` Andrew Cagney
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox