* ui-file.c: Comment cleanup, mostly periods and spaces.
* ui-file.h: Ditto.
* ui-out.c: Ditto.
* ui-out.h: Ditto.
* utils.c: Ditto.
* v850-tdep.c: Ditto.
* valarith.c: Ditto.
* valops.c: Ditto.
* valprint.c: Ditto.
* valprint.h: Ditto.
* value.c: Ditto.
* value.h: Ditto.
* varobj.c: Ditto.
* varobj.h: Ditto.
* vax-tdep.c: Ditto.
* vec.c: Ditto.
* vec.h: Ditto.
* version.h: Ditto.
* windows-nat.c: Ditto.
* windows-tdep.c: Ditto.
* xcoffread.c: Ditto.
* xcoffsolib.c: Ditto.
* xml-support.c: Ditto.
* xstormy16-tdep.c: Ditto.
* xtensa-tdep.c: Ditto.
* xtensa-tdep.h: Ditto.
* trad-frame.h: Ditto.
* typeprint.c: Ditto.
+2011-01-11 Michael Snyder <msnyder@vmware.com>
+
+ * ui-file.c: Comment cleanup, mostly periods and spaces.
+ * ui-file.h: Ditto.
+ * ui-out.c: Ditto.
+ * ui-out.h: Ditto.
+ * utils.c: Ditto.
+ * v850-tdep.c: Ditto.
+ * valarith.c: Ditto.
+ * valops.c: Ditto.
+ * valprint.c: Ditto.
+ * valprint.h: Ditto.
+ * value.c: Ditto.
+ * value.h: Ditto.
+ * varobj.c: Ditto.
+ * varobj.h: Ditto.
+ * vax-tdep.c: Ditto.
+ * vec.c: Ditto.
+ * vec.h: Ditto.
+ * version.h: Ditto.
+ * windows-nat.c: Ditto.
+ * windows-tdep.c: Ditto.
+ * xcoffread.c: Ditto.
+ * xcoffsolib.c: Ditto.
+ * xml-support.c: Ditto.
+ * xstormy16-tdep.c: Ditto.
+ * xtensa-tdep.c: Ditto.
+ * xtensa-tdep.h: Ditto.
+
2011-01-11 Thiago Jung Bauermann <bauerman@br.ibm.com>
* breakpoint.c (resources_needed_watchpoint): Fix indentation.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-/* Implement the ``struct ui_file'' object. */
+/* Implement the ``struct ui_file'' object. */
#include "defs.h"
#include "ui-file.h"
long sizeof_buf)
{
if (file->to_fputs == null_file_fputs)
- /* Both the write and fputs methods are null. Discard the
- request. */
+ /* Both the write and fputs methods are null. Discard the
+ request. */
return;
else
{
null_file_fputs (const char *buf, struct ui_file *file)
{
if (file->to_write == null_file_write)
- /* Both the write and fputs methods are null. Discard the
- request. */
+ /* Both the write and fputs methods are null. Discard the
+ request. */
return;
else
{
- /* The write method was implemented, use that. */
+ /* The write method was implemented, use that. */
file->to_write (file, buf, strlen (buf));
}
}
}
/* ui_file utility function for converting a ``struct ui_file'' into
- a memory buffer. */
+ a memory buffer. */
struct accumulated_ui_file
{
}
\f
/* A pure memory based ``struct ui_file'' that can be used an output
- buffer. The buffers accumulated contents are available via
- ui_file_put(). */
+ buffer. The buffers accumulated contents are available via
+ ui_file_put(). */
struct mem_file
{
}
\f
/* ``struct ui_file'' implementation that maps directly onto
- <stdio.h>'s FILE. */
+ <stdio.h>'s FILE. */
static ui_file_write_ftype stdio_file_write;
static ui_file_fputs_ftype stdio_file_fputs;
return (isatty (fileno (stdio->file)));
}
-/* Like fdopen(). Create a ui_file from a previously opened FILE. */
+/* Like fdopen(). Create a ui_file from a previously opened FILE. */
struct ui_file *
stdio_fileopen (FILE *file)
struct obstack;
struct ui_file;
-/* Create a generic ui_file object with null methods. */
+/* Create a generic ui_file object with null methods. */
extern struct ui_file *ui_file_new (void);
/* Override methods used by specific implementations of a UI_FILE
- object. */
+ object. */
typedef void (ui_file_flush_ftype) (struct ui_file *stream);
extern void set_ui_file_flush (struct ui_file *stream,
ui_file_flush_ftype *flush);
-/* NOTE: Both fputs and write methods are available. Default
- implementations that mapping one onto the other are included. */
+/* NOTE: Both fputs and write methods are available. Default
+ implementations that mapping one onto the other are included. */
typedef void (ui_file_write_ftype) (struct ui_file *stream,
const char *buf, long length_buf);
extern void set_ui_file_write (struct ui_file *stream,
extern void ui_file_write (struct ui_file *file, const char *buf,
long length_buf);
-/* NOTE: copies left to right */
+/* NOTE: copies left to right. */
extern void ui_file_put (struct ui_file *src,
ui_file_put_method_ftype *write, void *dest);
/* Returns a freshly allocated buffer containing the entire contents
of FILE (as determined by ui_file_put()) with a NUL character
appended. LENGTH, if not NULL, is set to the size of the buffer
- minus that appended NUL. */
+ minus that appended NUL. */
extern char *ui_file_xstrdup (struct ui_file *file, long *length);
/* Similar to ui_file_xstrdup, but return a new string allocated on
extern long ui_file_read (struct ui_file *file, char *buf, long length_buf);
-/* Create/open a memory based file. Can be used as a scratch buffer
- for collecting output. */
+/* Create/open a memory based file. Can be used as a scratch buffer
+ for collecting output. */
extern struct ui_file *mem_fileopen (void);
-/* Open/create a an STDIO based UI_FILE using the already open FILE. */
+/* Open/create a an STDIO based UI_FILE using the already open FILE. */
extern struct ui_file *stdio_fileopen (FILE *file);
-/* Open NAME returning an STDIO based UI_FILE. */
+/* Open NAME returning an STDIO based UI_FILE. */
extern struct ui_file *gdb_fopen (char *name, char *mode);
/* Create a file which writes to both ONE and TWO. CLOSE_ONE
/* Maintain a stack so that the info applicable to the inner most list
is always available. Stack/nested level 0 is reserved for the
- top-level result. */
+ top-level result. */
enum { MAX_UI_OUT_LEVELS = 8 };
struct ui_out_level
{
- /* Count each field; the first element is for non-list fields */
+ /* Count each field; the first element is for non-list fields. */
int field_count;
- /* The type of this level. */
+ /* The type of this level. */
enum ui_out_type type;
};
/* The ui_out structure */
/* Any change here requires a corresponding one in the initialization
- of the default uiout, which is statically initialized */
+ of the default uiout, which is statically initialized. */
struct ui_out
{
int flags;
- /* specific implementation of ui-out */
+ /* Specific implementation of ui-out. */
struct ui_out_impl *impl;
void *data;
struct ui_out_table table;
};
-/* The current (inner most) level. */
+/* The current (inner most) level. */
static struct ui_out_level *
current_level (struct ui_out *uiout)
{
return &uiout->levels[uiout->level];
}
-/* Create a new level, of TYPE. Return the new level's index. */
+/* Create a new level, of TYPE. Return the new level's index. */
static int
push_level (struct ui_out *uiout,
enum ui_out_type type,
{
struct ui_out_level *current;
- /* We had better not overflow the buffer. */
+ /* We had better not overflow the buffer. */
uiout->level++;
gdb_assert (uiout->level >= 0 && uiout->level < MAX_UI_OUT_LEVELS);
current = current_level (uiout);
}
/* Discard the current level, return the discarded level's index.
- TYPE is the type of the level being discarded. */
+ TYPE is the type of the level being discarded. */
static int
pop_level (struct ui_out *uiout,
enum ui_out_type type)
{
- /* We had better not underflow the buffer. */
+ /* We had better not underflow the buffer. */
gdb_assert (uiout->level > 0 && uiout->level < MAX_UI_OUT_LEVELS);
gdb_assert (current_level (uiout)->type == type);
uiout->level--;
}
-/* These are the default implementation functions */
+/* These are the default implementation functions. */
static void default_table_begin (struct ui_out *uiout, int nbrofcols,
int nr_rows, const char *tblid);
static void default_wrap_hint (struct ui_out *uiout, char *identstring);
static void default_flush (struct ui_out *uiout);
-/* This is the default ui-out implementation functions vector */
+/* This is the default ui-out implementation functions vector. */
struct ui_out_impl default_ui_out_impl =
{
/* Pointer to current ui_out */
/* FIXME: This should not be a global, but something passed down from main.c
- or top.c */
+ or top.c. */
struct ui_out *uiout = &def_uiout;
-/* These are the interfaces to implementation functions */
+/* These are the interfaces to implementation functions. */
static void uo_table_begin (struct ui_out *uiout, int nbrofcols,
int nr_rows, const char *tblid);
/* exported functions (ui_out API) */
-/* Mark beginning of a table */
+/* Mark beginning of a table. */
static void
ui_out_table_begin (struct ui_out *uiout, int nbrofcols,
do_cleanups (old_cleanup);
}
-/* used to ommit a field */
+/* Used to omit a field. */
void
ui_out_field_skip (struct ui_out *uiout,
int width;
int align;
- /* will not align, but has to call anyway */
+ /* Will not align, but has to call anyway. */
verify_field (uiout, &fldno, &width, &align);
va_start (args, format);
return uo_redirect (uiout, outstream);
}
-/* set the flags specified by the mask given */
+/* Set the flags specified by the mask given. */
int
ui_out_set_flags (struct ui_out *uiout, int mask)
{
return oldflags;
}
-/* clear the flags specified by the mask given */
+/* Clear the flags specified by the mask given. */
int
ui_out_clear_flags (struct ui_out *uiout, int mask)
{
return oldflags;
}
-/* test the flags against the mask given */
+/* Test the flags against the mask given. */
int
ui_out_test_flags (struct ui_out *uiout, int mask)
{
return (uiout->flags & mask);
}
-/* obtain the current verbosity level (as stablished by the
- 'set verbositylevel' command */
+/* Obtain the current verbosity level (as stablished by the
+ 'set verbositylevel' command. */
int
ui_out_get_verblvl (struct ui_out *uiout)
{
- /* FIXME: not implemented yet */
+ /* FIXME: not implemented yet. */
return 0;
}
return uiout->impl->is_mi_like_p;
}
-/* default gdb-out hook functions */
+/* Default gdb-out hook functions. */
static void
default_table_begin (struct ui_out *uiout, int nbrofcols,
{
}
-/* Interface to the implementation functions */
+/* Interface to the implementation functions. */
void
uo_table_begin (struct ui_out *uiout, int nbrofcols,
/* local functions */
-/* list of column headers manipulation routines */
+/* List of column headers manipulation routines. */
static void
clear_header_list (struct ui_out *uiout)
}
-/* access to ui_out format private members */
+/* Access to ui_out format private members. */
void
ui_out_get_field_separator (struct ui_out *uiout)
{
}
-/* Access to ui-out members data */
+/* Access to ui-out members data. */
void *
ui_out_data (struct ui_out *uiout)
return uiout->data;
}
-/* initalize private members at startup */
+/* Initalize private members at startup. */
struct ui_out *
ui_out_new (struct ui_out_impl *impl, void *data,
return uiout;
}
-/* standard gdb initialization hook */
+/* Standard gdb initialization hook. */
void
_initialize_ui_out (void)
/* the current ui_out */
/* FIXME: This should not be a global but something passed down from main.c
- or top.c */
+ or top.c. */
extern struct ui_out *uiout;
/* alignment enum */
};
-/* The ui_out stream structure. */
+/* The ui_out stream structure. */
/* NOTE: cagney/2000-02-01: The ui_stream object can be subsumed by
the more generic ui_file object. */
};
-/* Prototypes for ui-out API. */
+/* Prototypes for ui-out API. */
/* A result is a recursive data structure consisting of lists and
- tuples. */
+ tuples. */
enum ui_out_type
{
/* A table can be considered a special tuple/list combination with the
implied structure: ``table = { hdr = { header, ... } , body = [ {
- field, ... }, ... ] }''. If NR_ROWS is negative then there is at
- least one row. */
+ field, ... }, ... ] }''. If NR_ROWS is negative then there is at
+ least one row. */
extern void ui_out_table_header (struct ui_out *uiout, int width,
enum ui_align align, const char *col_name,
const char *colhdr);
/* From here on we have things that are only needed by implementation
routines and main.c. We should pehaps have a separate file for that,
- like a ui-out-impl.h file */
+ like a ui-out-impl.h file. */
/* User Interface Output Implementation Function Table */
-/* Type definition of all implementation functions. */
+/* Type definition of all implementation functions. */
typedef void (table_begin_ftype) (struct ui_out * uiout,
int nbrofcols, int nr_rows,
enum ui_align align, const char *col_name,
const char *colhdr);
/* Note: level 0 is the top-level so LEVEL is always greater than
- zero. */
+ zero. */
typedef void (ui_out_begin_ftype) (struct ui_out *uiout,
enum ui_out_type type,
int level, const char *id);
/* ui-out-impl */
/* IMPORTANT: If you change this structure, make sure to change the default
- initialization in ui-out.c */
+ initialization in ui-out.c. */
struct ui_out_impl
{
#include <pc.h>
#endif
-/* SunOS's curses.h has a '#define reg register' in it. Thank you Sun. */
+/* SunOS's curses.h has a '#define reg register' in it. Thank you Sun. */
#ifdef reg
#undef reg
#endif
static struct cleanup *cleanup_chain; /* cleaned up after a failed command */
static struct cleanup *final_cleanup_chain; /* cleaned up when gdb exits */
-/* Nonzero if we have job control. */
+/* Nonzero if we have job control. */
int job_control;
use the cleanup chain for handling normal cleanups as well as dealing
with cleanups that need to be done as a result of a call to error().
In such cases, we may not be certain where the first cleanup is, unless
- we have a do-nothing one to always use as the base. */
+ we have a do-nothing one to always use as the base. */
void
null_cleanup (void *arg)
/* As indicated by display_time and display_space, report GDB's elapsed time
and space usage from the base time and space provided in ARG, which
- must be a pointer to a struct cmd_stat. This function is intended
- to be called as a cleanup. */
+ must be a pointer to a struct cmd_stat. This function is intended
+ to be called as a cleanup. */
static void
report_command_stats (void *arg)
{
}
/* Walk down the cmd_continuation list, and execute all the
- continuations. There is a problem though. In some cases new
+ continuations. There is a problem though. In some cases new
continuations may be added while we are in the middle of this
- loop. If this happens they will be added in the front, and done
+ loop. If this happens they will be added in the front, and done
before we have a chance of exhausting those that were already
- there. We need to then save the beginning of the list in a pointer
+ there. We need to then save the beginning of the list in a pointer
and do the continuations from there on, instead of using the
- global beginning of list as our iteration pointer.*/
+ global beginning of list as our iteration pointer. */
static int
do_all_intermediate_continuations_thread_callback (struct thread_info *thread,
void *data)
else
{
target_terminal_ours ();
- wrap_here (""); /* Force out any buffered output */
+ wrap_here (""); /* Force out any buffered output. */
gdb_flush (gdb_stdout);
if (warning_pre_print)
fputs_unfiltered (warning_pre_print, gdb_stderr);
NULL
};
-/* Print a message reporting an internal error/warning. Ask the user
+/* Print a message reporting an internal error/warning. Ask the user
if they want to continue, dump core, or just exit. Return
something to indicate a quit. */
/* I understand setting these is a matter of taste. Still, some people
may clear errno but not know about bfd_error. Doing this here is not
- unreasonable. */
+ unreasonable. */
bfd_set_error (bfd_error_no_error);
errno = 0;
\f
/* Called when a memory allocation fails, with the number of bytes of
- memory requested in SIZE. */
+ memory requested in SIZE. */
void
nomem (long size)
\f
/* Like asprintf/vasprintf but get an internal_error if the call
- fails. */
+ fails. */
char *
xstrprintf (const char *format, ...)
while (1)
{
- wrap_here (""); /* Flush any buffered output */
+ wrap_here (""); /* Flush any buffered output. */
gdb_flush (gdb_stdout);
if (annotation_level > 1)
retval = def_value;
break;
}
- /* Eat rest of input line, to EOF or newline */
+ /* Eat rest of input line, to EOF or newline. */
if (answer != '\n')
do
{
int
parse_escape (struct gdbarch *gdbarch, char **string_ptr)
{
- int target_char = -2; /* initialize to avoid GCC warnings */
+ int target_char = -2; /* Initialize to avoid GCC warnings. */
int c = *(*string_ptr)++;
switch (c)
/* Print the character C on STREAM as part of the contents of a literal
string whose delimiter is QUOTER. Note that this routine should only
be call for printing things which are independent of the language
- of the program being debugged. */
+ of the program being debugged. */
static void
printchar (int c, void (*do_fputs) (const char *, struct ui_file *),
/* Print the character C on STREAM as part of the contents of a
literal string whose delimiter is QUOTER. Note that these routines
should only be call for printing things which are independent of
- the language of the program being debugged. */
+ the language of the program being debugged. */
void
fputstr_filtered (const char *str, int quoter, struct ui_file *stream)
need to save the ---Type <return>--- line at the top of the screen. */
reinitialize_more_filter ();
- dont_repeat (); /* Forget prev cmd -- CR won't repeat it. */
+ dont_repeat (); /* Forget prev cmd -- CR won't repeat it. */
}
/* Reinitialize filter; ie. tell it to reset to original values. */
}
/* Indicate that if the next sequence of characters overflows the line,
- a newline should be inserted here rather than when it hits the end.
+ a newline should be inserted here rather than when it hits the end.
If INDENT is non-null, it is a string to be printed to indent the
wrapped part on the next line. INDENT must remain accessible until
the next call to wrap_here() or until a newline is printed through
void
wrap_here (char *indent)
{
- /* This should have been allocated, but be paranoid anyway. */
+ /* This should have been allocated, but be paranoid anyway. */
if (!wrap_buffer)
internal_error (__FILE__, __LINE__,
_("failed internal consistency check"));
}
/* Print input string to gdb_stdout, filtered, with wrap,
- arranging strings in columns of n chars. String can be
+ arranging strings in columns of n chars. String can be
right or left justified in the column. Never prints
trailing spaces. String should never be longer than
width. FIXME: this could be useful for the EXAMINE
- command, which currently doesn't tabulate very well */
+ command, which currently doesn't tabulate very well. */
void
puts_filtered_tabular (char *string, int width, int right)
/* Ensure that whatever gets printed next, using the filtered output
- commands, starts at the beginning of the line. I.E. if there is
+ commands, starts at the beginning of the line. I.e. if there is
any pending output for the current line, flush it and start a new
- line. Otherwise do nothing. */
+ line. Otherwise do nothing. */
void
begin_line (void)
if (lines_printed >= lines_per_page - 1)
prompt_for_continue ();
- /* Now output indentation and wrapped string */
+ /* Now output indentation and wrapped string. */
if (wrap_column)
{
fputs_unfiltered (wrap_indent, stream);
- *wrap_pointer = '\0'; /* Null-terminate saved stuff */
- fputs_unfiltered (wrap_buffer, stream); /* and eject it */
+ *wrap_pointer = '\0'; /* Null-terminate saved stuff, */
+ fputs_unfiltered (wrap_buffer, stream); /* and eject it. */
/* FIXME, this strlen is what prevents wrap_indent from
containing tabs. However, if we recurse to print it
and count its chars, we risk trouble if wrap_indent is
- longer than (the user settable) chars_per_line.
+ longer than (the user settable) chars_per_line.
Note also that this can set chars_printed > chars_per_line
if we are printing a long string. */
chars_printed = strlen (wrap_indent)
/* fprintf_symbol_filtered attempts to demangle NAME, a symbol in language
LANG, using demangling args ARG_MODE, and print it filtered to STREAM.
If the name is not mangled, or the language for the name is unknown, or
- demangling is off, the name is printed in its "raw" form. */
+ demangling is off, the name is printed in its "raw" form. */
void
fprintf_symbol_filtered (struct ui_file *stream, char *name,
As an extra hack, string1=="FOO(ARGS)" matches string2=="FOO".
This "feature" is useful when searching for matching C++ function names
(such as if the user types 'break FOO', where FOO is a mangled C++
- function). */
+ function). */
int
strcmp_iw (const char *string1, const char *string2)
&setdebuglist, &showdebuglist);
}
-/* Machine specific function to handle SIGWINCH signal. */
+/* Machine specific function to handle SIGWINCH signal. */
#ifdef SIGWINCH_HANDLER_BODY
SIGWINCH_HANDLER_BODY
#endif
-/* print routines to handle variable size regs, etc. */
-/* temporary storage using circular buffer */
+/* Print routines to handle variable size regs, etc. */
+/* Temporary storage using circular buffer. */
#define NUMCELLS 16
#define CELLSIZE 50
static char *
/* Truncate address to the size of a target address, avoiding shifts
larger or equal than the width of a CORE_ADDR. The local
variable ADDR_BIT stops the compiler reporting a shift overflow
- when it won't occur. */
+ when it won't occur. */
/* NOTE: This assumes that the significant address information is
kept in the least significant bits of ADDR - the upper bits were
either zero or sign extended. Should gdbarch_address_to_pointer or
decimal2str (char *sign, ULONGEST addr, int width)
{
/* Steal code from valprint.c:print_decimal(). Should this worry
- about the real size of addr as the above does? */
+ about the real size of addr as the above does? */
unsigned long temp[3];
char *str = get_cell ();
int i = 0;
* otherwise VAL is interpreted as unsigned. If WIDTH is supplied,
* it is the minimum width (0-padded if needed). USE_C_FORMAT means
* to use C format in all cases. If it is false, then 'x'
- * and 'o' formats do not include a prefix (0x or leading 0). */
+ * and 'o' formats do not include a prefix (0x or leading 0). */
char *
int_string (LONGEST val, int radix, int is_signed, int width,
char *result;
/* Extract the basename of filename, and return immediately
- a copy of filename if it does not contain any directory prefix. */
+ a copy of filename if it does not contain any directory prefix. */
if (base_name == filename)
return xstrdup (filename);
dir_name = alloca ((size_t) (base_name - filename + 2));
/* Allocate enough space to store the dir_name + plus one extra
character sometimes needed under Windows (see below), and
- then the closing \000 character */
+ then the closing \000 character. */
strncpy (dir_name, filename, base_name - filename);
dir_name[base_name - filename] = '\000';
#endif
/* Canonicalize the directory prefix, and build the resulting
- filename. If the dirname realpath already contains an ending
+ filename. If the dirname realpath already contains an ending
directory separator, avoid doubling it. */
real_path = gdb_realpath (dir_name);
if (IS_DIR_SEPARATOR (real_path[strlen (real_path) - 1]))
return 0;
}
- /* The value is a union which contains at least one field which would be
- returned in registers according to these rules -> returned in register. */
+ /* The value is a union which contains at least one field which
+ would be returned in registers according to these rules ->
+ returned in register. */
if (TYPE_CODE (type) == TYPE_CODE_UNION)
{
for (i = 0; i < TYPE_NFIELDS (type); ++i)
{
/* The caller-save registers are R2, R20 - R29 and R31. All other
registers are either special purpose (PC, SP), argument registers,
- or just considered free for use in the caller. */
+ or just considered free for use in the caller. */
return reg == E_R2_REGNUM
|| (reg >= E_R20_REGNUM && reg <= E_R29_REGNUM)
|| reg == E_R31_REGNUM;
insn = read_memory_integer (current_pc, 2, byte_order);
current_pc += 2;
- if ((insn & 0x0780) >= 0x0600) /* Four byte instruction? */
+ if ((insn & 0x0780) >= 0x0600) /* Four byte instruction? */
{
insn2 = read_memory_integer (current_pc, 2, byte_order);
current_pc += 2;
|| (insn & 0xffe0) == 0x0060 /* jmp */
|| (insn & 0x0780) == 0x0580) /* branch */
{
- break; /* Ran into end of prologue */
+ break; /* Ran into end of prologue. */
}
else if ((insn & 0xffe0) == ((E_SP_REGNUM << 11) | 0x0240))
{
CORE_ADDR func_addr, func_end;
- /* See what the symbol table says */
+ /* See what the symbol table says. */
if (find_pc_partial_function (pc, NULL, &func_addr, &func_end))
{
return pc;
}
- /* We can't find the start of this function, so there's nothing we can do. */
+ /* We can't find the start of this function, so there's nothing we
+ can do. */
return pc;
}
#include "exceptions.h"
/* Define whether or not the C operator '/' truncates towards zero for
- differently signed operands (truncation direction is undefined in C). */
+ differently signed operands (truncation direction is undefined in C). */
#ifndef TRUNCATION_TOWARDS_ZERO
#define TRUNCATION_TOWARDS_ZERO ((-5 / 2) == -2)
If the pointer type is void *, then return 1.
If the target type is incomplete, then error out.
This isn't a general purpose function, but just a
- helper for value_ptradd.
-*/
+ helper for value_ptradd. */
static LONGEST
find_size_for_pointer_math (struct type *ptr_type)
See comments in value_coerce_array() for rationale for reason for
doing lower bounds adjustment here rather than there.
FIXME: Perhaps we should validate that the index is valid and if
- verbosity is set, warn about invalid indices (but still use them). */
+ verbosity is set, warn about invalid indices (but still use them). */
struct value *
value_subscript (struct value *array, LONGEST index)
int i;
arg_types = (struct type **) alloca (nargs * (sizeof (struct type *)));
- /* Prepare list of argument types for overload resolution */
+ /* Prepare list of argument types for overload resolution. */
for (i = 0; i < nargs; i++)
arg_types[i] = value_type (args[i]);
argvec[2] = arg2;
argvec[3] = 0;
- /* make the right function name up */
+ /* Make the right function name up. */
strcpy (tstr, "operator__");
ptr = tstr + 8;
switch (op)
}
/* We know that arg1 is a structure, so try to find a unary user
- defined operator that matches the operator in question.
+ defined operator that matches the operator in question.
Create an argument vector that calls arg1.operator @ (arg1)
and return that value (where '@' is (almost) any unary operator which
is legal for GNU C++). */
nargs = 1;
- /* make the right function name up */
+ /* Make the right function name up. */
strcpy (tstr, "operator__");
ptr = tstr + 8;
strcpy (mangle_tstr, "__");
values of length 1.
(3) Character values are also allowed and are treated as character
- string values of length 1.
- */
+ string values of length 1. */
struct value *
value_concat (struct value *arg1, struct value *arg2)
or a repeat count and a value to be repeated. INVAL1 is set to the
first of two concatenated values, or the repeat count. INVAL2 is set
to the second of the two concatenated values or the value to be
- repeated. */
+ repeated. */
if (TYPE_CODE (type2) == TYPE_CODE_INT)
{
inval2 = arg2;
}
- /* Now process the input values. */
+ /* Now process the input values. */
if (TYPE_CODE (type1) == TYPE_CODE_INT)
{
/* We have a repeat count. Validate the second value and then
- construct a value repeated that many times. */
+ construct a value repeated that many times. */
if (TYPE_CODE (type2) == TYPE_CODE_STRING
|| TYPE_CODE (type2) == TYPE_CODE_CHAR)
{
else if (TYPE_CODE (type1) == TYPE_CODE_STRING
|| TYPE_CODE (type1) == TYPE_CODE_CHAR)
{
- /* We have two character strings to concatenate. */
+ /* We have two character strings to concatenate. */
if (TYPE_CODE (type2) != TYPE_CODE_STRING
&& TYPE_CODE (type2) != TYPE_CODE_CHAR)
{
else if (TYPE_CODE (type1) == TYPE_CODE_BITSTRING
|| TYPE_CODE (type1) == TYPE_CODE_BOOL)
{
- /* We have two bitstrings to concatenate. */
+ /* We have two bitstrings to concatenate. */
if (TYPE_CODE (type2) != TYPE_CODE_BITSTRING
&& TYPE_CODE (type2) != TYPE_CODE_BOOL)
{
}
else
{
- /* We don't know how to concatenate these operands. */
+ /* We don't know how to concatenate these operands. */
error (_("illegal operands for concatenation."));
}
return (outval);
\f
/* Integer exponentiation: V1**V2, where both arguments are
integers. Requires V1 != 0 if V2 < 0. Returns 1 for 0 ** 0. */
+
static LONGEST
integer_pow (LONGEST v1, LONGEST v2)
{
}
else
{
- /* The Russian Peasant's Algorithm */
+ /* The Russian Peasant's Algorithm. */
LONGEST v;
v = 1;
/* Integer exponentiation: V1**V2, where both arguments are
integers. Requires V1 != 0 if V2 < 0. Returns 1 for 0 ** 0. */
+
static ULONGEST
uinteger_pow (ULONGEST v1, LONGEST v2)
{
}
else
{
- /* The Russian Peasant's Algorithm */
+ /* The Russian Peasant's Algorithm. */
ULONGEST v;
v = 1;
case BINOP_MOD:
/* Knuth 1.2.4, integer only. Note that unlike the C '%' op,
- v1 mod 0 has a defined value, v1. */
+ v1 mod 0 has a defined value, v1. */
if (v2 == 0)
{
v = v1;
else
{
v = v1 / v2;
- /* Note floor(v1/v2) == v1/v2 for unsigned. */
+ /* Note floor(v1/v2) == v1/v2 for unsigned. */
v = v1 - (v2 * v);
}
break;
case BINOP_MOD:
/* Knuth 1.2.4, integer only. Note that unlike the C '%' op,
- X mod 0 has a defined value, X. */
+ X mod 0 has a defined value, X. */
if (v2 == 0)
{
v = v1;
else
{
v = v1 / v2;
- /* Compute floor. */
+ /* Compute floor. */
if (TRUNCATION_TOWARDS_ZERO && (v < 0) && ((v1 % v2) != 0))
{
v--;
}
/* Perform a comparison on two string values (whose content are not
- necessarily null terminated) based on their length */
+ necessarily null terminated) based on their length. */
static int
value_strcmp (struct value *arg1, struct value *arg2)
else
{
error (_("Invalid type combination in equality test."));
- return 0; /* For lint -- never reached */
+ return 0; /* For lint -- never reached. */
}
}
else
{
error (_("Argument to positive operation not a number."));
- return 0; /* For lint -- never reached */
+ return 0; /* For lint -- never reached. */
}
}
{
struct value *val = allocate_value (type);
int len = TYPE_LENGTH (type);
- gdb_byte decbytes[16]; /* a decfloat is at most 128 bits long */
+ gdb_byte decbytes[16]; /* a decfloat is at most 128 bits long. */
memcpy (decbytes, value_contents (arg1), len);
else
{
error (_("Argument to negate operation not a number."));
- return 0; /* For lint -- never reached */
+ return 0; /* For lint -- never reached. */
}
}
\f
/* The INDEX'th bit of SET value whose value_type is TYPE,
and whose value_contents is valaddr.
- Return -1 if out of range, -2 other error. */
+ Return -1 if out of range, -2 other error. */
int
value_bit_index (struct type *type, const gdb_byte *valaddr, int index)
if (code1 == TYPE_CODE_REF)
{
/* We dereference type; then we recurse and finally
- we generate value of the given reference. Nothing wrong with
+ we generate value of the given reference. Nothing wrong with
that. */
struct type *t1 = check_typedef (type);
struct type *dereftype = check_typedef (TYPE_TARGET_TYPE (t1));
struct value *val;
/* Evaluate it first; if the result is a memory address, we're fine.
- Lazy evaluation pays off here. */
+ Lazy evaluation pays off here. */
val = value_of_variable (var, b);
other than array subscripting, where the caller would get back a
value that had an address somewhere before the actual first element
of the array, and the information about the lower bound would be
- lost because of the coercion to pointer type.
- */
+ lost because of the coercion to pointer type. */
struct value *
value_coerce_array (struct value *arg1)
if (VALUE_LVAL (arg1) != lval_memory)
error (_("Attempt to take address of value not located in memory."));
- /* Get target memory address */
+ /* Get target memory address. */
arg2 = value_from_pointer (lookup_pointer_type (value_type (arg1)),
(value_address (arg1)
+ value_embedded_offset (arg1)));
arg2 = value_at_lazy (enc_type,
find_function_addr (arg1, NULL));
else
- /* Retrieve the enclosing object pointed to */
+ /* Retrieve the enclosing object pointed to. */
arg2 = value_at_lazy (enc_type,
(value_as_address (arg1)
- value_pointed_to_offset (arg1)));
}
/* Helper function used by value_struct_elt to recurse through
- baseclasses. Look for a field NAME in ARG1. Adjust the address of
+ baseclasses. Look for a field NAME in ARG1. Adjust the address of
ARG1 by OFFSET bytes, and search in it assuming it has (class) type
TYPE. If found, return value, else return NULL.
error (_("virtual baseclass botch"));
/* The virtual base class pointer might have been clobbered
- by the user program. Make sure that it still points to a
+ by the user program. Make sure that it still points to a
valid memory location. */
boffset += value_embedded_offset (arg1) + offset;
}
/* Helper function used by value_struct_elt to recurse through
- baseclasses. Look for a field NAME in ARG1. Adjust the address of
+ baseclasses. Look for a field NAME in ARG1. Adjust the address of
ARG1 by OFFSET bytes, and search in it assuming it has (class) type
TYPE.
{
char *t_field_name = TYPE_FN_FIELDLIST_NAME (type, i);
- /* FIXME! May need to check for ARM demangling here */
+ /* FIXME! May need to check for ARM demangling here. */
if (strncmp (t_field_name, "__", 2) == 0 ||
strncmp (t_field_name, "op", 2) == 0 ||
strncmp (t_field_name, "type", 4) == 0)
const gdb_byte *base_valaddr;
/* The virtual base class pointer might have been
- clobbered by the user program. Make sure that it
+ clobbered by the user program. Make sure that it
still points to a valid memory location. */
if (offset < 0 || offset >= TYPE_LENGTH (type))
ERR is used in the error message if *ARGP's type is wrong.
C++: ARGS is a list of argument types to aid in the selection of
- an appropriate method. Also, handle derived types.
+ an appropriate method. Also, handle derived types.
STATIC_MEMFUNCP, if non-NULL, points to a caller-supplied location
where the truthvalue of whether the function that was resolved was
NUM_FNS is the number of overloaded instances.
BASETYPE is set to the actual type of the subobject where the
method is found.
- BOFFSET is the offset of the base subobject where the method is found.
-*/
+ BOFFSET is the offset of the base subobject where the method is found. */
static struct fn_field *
find_method_list (struct value **argp, const char *method,
NUM_FNS is the number of overloaded instances.
BASETYPE is set to the type of the base subobject that defines the
method.
- BOFFSET is the offset of the base subobject which defines the method.
-*/
+ BOFFSET is the offset of the base subobject which defines the method. */
struct fn_field *
value_find_oload_method_list (struct value **argp, const char *method,
METHOD: for member functions.
BOTH: used for overload resolution of operators where the
candidates are expected to be either member or non member
- functions. In this case the first argument ARGTYPES
+ functions. In this case the first argument ARGTYPES
(representing 'this') is expected to be a reference to the
target object, and will be dereferenced when attempting the
non-member search.
Note: This function does *not* check the value of
overload_resolution. Caller must check it to see whether overload
- resolution is permitted.
-*/
+ resolution is permitted. */
int
find_overload_match (struct type **arg_types, int nargs,
*oload_syms = NULL;
*oload_champ_bv = NULL;
- /* First, see if we have a deeper namespace we can search in.
+ /* First, see if we have a deeper namespace we can search in.
If we get a good match there, use it. */
if (qualified_name[next_namespace_len] == ':')
++start;
/* If skipping artificial fields, find the first real field
- in T1. */
+ in T1. */
if (skip_artificial)
{
while (start < TYPE_NFIELDS (t1)
++start;
}
- /* Now compare parameters */
+ /* Now compare parameters. */
/* Special case: a method taking void. T1 will contain no
non-artificial fields, and T2 will contain TYPE_CODE_VOID. */
return argp;
}
- /* Check if object is in memory */
+ /* Check if object is in memory. */
if (VALUE_LVAL (argp) != lval_memory)
{
warning (_("Couldn't retrieve complete object of RTTI "
void _initialize_valprint (void);
-#define PRINT_MAX_DEFAULT 200 /* Start print_max off at this value. */
+#define PRINT_MAX_DEFAULT 200 /* Start print_max off at this value. */
struct value_print_options user_print_options =
{
/* Print repeat counts if there are more than this many repetitions of an
element in an array. Referenced by the low level language dependent
- print routines. */
+ print routines. */
static void
show_repeat_count_threshold (struct ui_file *file, int from_tty,
value);
}
-/* If nonzero, stops printing of char arrays at first null. */
+/* If nonzero, stops printing of char arrays at first null. */
static void
show_stop_print_at_null (struct ui_file *file, int from_tty,
value);
}
-/* Controls pretty printing of structures. */
+/* Controls pretty printing of structures. */
static void
show_prettyprint_structs (struct ui_file *file, int from_tty,
}
/* If nonzero, causes unions inside structures or other unions to be
- printed. */
+ printed. */
static void
show_unionprint (struct ui_file *file, int from_tty,
value);
}
-/* If nonzero, causes machine addresses to be printed in certain contexts. */
+/* If nonzero, causes machine addresses to be printed in certain contexts. */
static void
show_addressprint (struct ui_file *file, int from_tty,
for (specific CPU type and thus specific target byte ordering), then
either the print routines are going to have to take this into account,
or the data is going to have to be passed into here already converted
- to the host byte ordering, whichever is more convenient. */
+ to the host byte ordering, whichever is more convenient. */
int
/* Print a number according to FORMAT which is one of d,u,x,o,b,h,w,g.
The raison d'etre of this function is to consolidate printing of
- LONG_LONG's into this one function. The format chars b,h,w,g are
+ LONG_LONG's into this one function. The format chars b,h,w,g are
from print_scalar_formatted(). Numbers are printed using C
- format.
+ format.
USE_C_FORMAT means to use C format in all cases. Without it,
'o' and 'x' format do not include the standard C radix prefix
the integer is a protocol thing, not a user-visible thing). The
parameter remains to preserve the information of what things might
be printed with language-specific format, should we ever resurrect
- that capability. */
+ that capability. */
void
print_longest (struct ui_file *stream, int format, int use_c_format,
int
longest_to_int (LONGEST arg)
{
- /* Let the compiler do the work */
+ /* Let the compiler do the work. */
int rtnval = (int) arg;
- /* Check for overflows or underflows */
+ /* Check for overflows or underflows. */
if (sizeof (LONGEST) > sizeof (int))
{
if (rtnval != arg)
int b;
/* Declared "int" so it will be signed.
- * This ensures that right shift will shift in zeros.
- */
+ This ensures that right shift will shift in zeros. */
+
const int mask = 0x080;
/* FIXME: We should be not printing leading zeroes in most cases. */
p++)
{
/* Every byte has 8 binary characters; peel off
- * and print from the MSB end.
- */
+ and print from the MSB end. */
+
for (i = 0; i < (BITS_IN_BYTES * sizeof (*p)); i++)
{
if (*p & (mask >> i))
}
/* VALADDR points to an integer of LEN bytes.
- * Print it in octal on stream or format it in buf.
- */
+ Print it in octal on stream or format it in buf. */
+
void
print_octal_chars (struct ui_file *stream, const gdb_byte *valaddr,
unsigned len, enum bfd_endian byte_order)
#define LOW_TWO 0007
/* For 32 we start in cycle 2, with two bits and one bit carry;
- * for 64 in cycle in cycle 1, with one bit and a two bit carry.
- */
+ for 64 in cycle in cycle 1, with one bit and a two bit carry. */
+
cycle = (len * BITS_IN_BYTES) % BITS_IN_OCTAL;
carry = 0;
switch (cycle)
{
case 0:
- /* No carry in, carry out two bits.
- */
+ /* No carry in, carry out two bits. */
+
octa1 = (HIGH_ZERO & *p) >> 5;
octa2 = (LOW_ZERO & *p) >> 2;
carry = (CARRY_ZERO & *p);
break;
case 1:
- /* Carry in two bits, carry out one bit.
- */
+ /* Carry in two bits, carry out one bit. */
+
octa1 = (carry << 1) | ((HIGH_ONE & *p) >> 7);
octa2 = (MID_ONE & *p) >> 4;
octa3 = (LOW_ONE & *p) >> 1;
break;
case 2:
- /* Carry in one bit, no carry out.
- */
+ /* Carry in one bit, no carry out. */
+
octa1 = (carry << 2) | ((HIGH_TWO & *p) >> 6);
octa2 = (MID_TWO & *p) >> 3;
octa3 = (LOW_TWO & *p);
{
case 0:
/* Carry out, no carry in */
+
octa1 = (HIGH_ZERO & *p) >> 5;
octa2 = (LOW_ZERO & *p) >> 2;
carry = (CARRY_ZERO & *p);
case 1:
/* Carry in, carry out */
+
octa1 = (carry << 1) | ((HIGH_ONE & *p) >> 7);
octa2 = (MID_ONE & *p) >> 4;
octa3 = (LOW_ONE & *p) >> 1;
case 2:
/* Carry in, no carry out */
+
octa1 = (carry << 2) | ((HIGH_TWO & *p) >> 6);
octa2 = (MID_TWO & *p) >> 3;
octa3 = (LOW_TWO & *p);
}
/* VALADDR points to an integer of LEN bytes.
- * Print it in decimal on stream or format it in buf.
- */
+ Print it in decimal on stream or format it in buf. */
+
void
print_decimal_chars (struct ui_file *stream, const gdb_byte *valaddr,
unsigned len, enum bfd_endian byte_order)
int flip;
/* Base-ten number is less than twice as many digits
- * as the base 16 number, which is 2 digits per byte.
- */
+ as the base 16 number, which is 2 digits per byte. */
+
decimal_len = len * 2 * 2;
digits = xmalloc (decimal_len);
* the nibbles by 16, add Y and re-decimalize. Repeat with Z.
*
* The trick is that "digits" holds a base-10 number, but sometimes
- * the individual digits are > 10.
+ * the individual digits are > 10.
*
* Outer loop is per nibble (hex digit) of input, from MSD end to
* LSD end.
*/
if (flip == 0)
{
- /* Take top nibble.
- */
+ /* Take top nibble. */
+
digits[0] += HIGH_NIBBLE (*p);
flip = 1;
}
else
{
- /* Take low nibble and bump our pointer "p".
- */
+ /* Take low nibble and bump our pointer "p". */
+
digits[0] += LOW_NIBBLE (*p);
if (byte_order == BFD_ENDIAN_BIG)
p++;
}
/* Ok, now "digits" is the decimal representation, with
- * the "decimal_digits" actual digits. Print!
- */
+ the "decimal_digits" actual digits. Print! */
+
for (i = decimal_digits - 1; i >= 0; i--)
{
fprintf_filtered (stream, "%1d", digits[i]);
}
/* VALADDR points to a char integer of LEN bytes.
- Print it out in appropriate language form on stream.
+ Print it out in appropriate language form on stream.
Omit any leading zero chars. */
void
(FIXME?) Assumes array element separator is a comma, which is correct
for all languages currently handled.
(FIXME?) Some languages have a notation for repeated array elements,
- perhaps we should try to use that notation when appropriate.
- */
+ perhaps we should try to use that notation when appropriate. */
void
val_print_array_elements (struct type *type, const gdb_byte *valaddr,
/* Read LEN bytes of target memory at address MEMADDR, placing the
results in GDB's memory at MYADDR. Returns a count of the bytes
actually read, and optionally an errno value in the location
- pointed to by ERRNOPTR if ERRNOPTR is non-null. */
+ pointed to by ERRNOPTR if ERRNOPTR is non-null. */
/* FIXME: cagney/1999-10-14: Only used by val_print_string. Can this
function be eliminated. */
partial_memory_read (CORE_ADDR memaddr, gdb_byte *myaddr,
int len, int *errnoptr)
{
- int nread; /* Number of bytes actually read. */
- int errcode; /* Error from last read. */
+ int nread; /* Number of bytes actually read. */
+ int errcode; /* Error from last read. */
- /* First try a complete read. */
+ /* First try a complete read. */
errcode = target_read_memory (memaddr, myaddr, len);
if (errcode == 0)
{
- /* Got it all. */
+ /* Got it all. */
nread = len;
}
else
{
- /* Loop, reading one byte at a time until we get as much as we can. */
+ /* Loop, reading one byte at a time until we get as much as we can. */
for (errcode = 0, nread = 0; len > 0 && errcode == 0; nread++, len--)
{
errcode = target_read_memory (memaddr++, myaddr++, 1);
}
- /* If an error, the last read was unsuccessful, so adjust count. */
+ /* If an error, the last read was unsuccessful, so adjust count. */
if (errcode != 0)
{
nread--;
Note: There was a FIXME asking to make this code use target_read_string,
but this function is more general (can read past null characters, up to
- given LEN). Besides, it is used much more often than target_read_string
+ given LEN). Besides, it is used much more often than target_read_string
so it is more tested. Perhaps callers of target_read_string should use
this function instead? */
{
int force_ellipsis = 0; /* Force ellipsis to be printed if nonzero. */
int errcode; /* Errno returned from bad reads. */
- int found_nul; /* Non-zero if we found the nul char */
+ int found_nul; /* Non-zero if we found the nul char. */
unsigned int fetchlimit; /* Maximum number of chars to print. */
int bytes_read;
gdb_byte *buffer = NULL; /* Dynamically growable fetch buffer. */
radix greater than 1, even if we don't have unique digits for every
value from 0 to radix-1, but in practice we lose on large radix values.
We should either fix the lossage or restrict the radix range more.
- (FIXME). */
+ (FIXME). */
if (radix < 2)
{
set_output_radix_1 (int from_tty, unsigned radix)
{
/* Validate the radix and disallow ones that we aren't prepared to
- handle correctly, leaving the radix unchanged. */
+ handle correctly, leaving the radix unchanged. */
switch (radix)
{
case 16:
It may be useful to have an unusual input radix. If the user wishes to
set an input radix that is not valid as an output radix, he needs to use
- the 'set input-radix' command. */
+ the 'set input-radix' command. */
static void
set_radix (char *arg, int from_tty)
}
}
-/* Show both the input and output radices. */
+/* Show both the input and output radices. */
static void
show_radix (char *arg, int from_tty)
_("Generic command for setting how things print."),
&setprintlist, "set print ", 0, &setlist);
add_alias_cmd ("p", "print", no_class, 1, &setlist);
- /* prefer set print to set prompt */
+ /* Prefer set print to set prompt. */
add_alias_cmd ("pr", "print", no_class, 1, &setlist);
add_prefix_cmd ("print", no_class, show_print,
they are like normal set and show commands but allow two normally
independent variables to be either set or shown with a single
command. So the usual deprecated_add_set_cmd() and [deleted]
- add_show_from_set() commands aren't really appropriate. */
+ add_show_from_set() commands aren't really appropriate. */
/* FIXME: i18n: With the new add_setshow_integer command, that is no
longer true - show can display anything. */
add_cmd ("radix", class_support, set_radix, _("\
/* Maximum number of chars to print for a string pointer value or vector
contents, or UINT_MAX for no limit. Note that "set print elements 0"
stores UINT_MAX in print_max, which displays in a show command as
- "unlimited". */
+ "unlimited". */
unsigned int print_max;
/* Print repeat counts if there are more than this many repetitions
#include "tracepoint.h"
-/* Prototypes for exported functions. */
+/* Prototypes for exported functions. */
void _initialize_values (void);
/* Only used for bitfields; position of start of field. For
gdbarch_bits_big_endian=0 targets, it is the position of the LSB. For
- gdbarch_bits_big_endian=1 targets, it is the position of the MSB. */
+ gdbarch_bits_big_endian=1 targets, it is the position of the MSB. */
int bitpos;
/* Only used for bitfields; the containing value. This allows a
int reference_count;
};
-/* Prototypes for local functions. */
+/* Prototypes for local functions. */
static void show_values (char *, int);
static struct value_history_chunk *value_history_chain;
-static int value_history_count; /* Abs number of last entry stored */
+static int value_history_count; /* Abs number of last entry stored. */
\f
/* List of all value objects currently allocated
return foo;
}
-/* Extract a value as a C pointer. Does not deallocate the value.
+/* Extract a value as a C pointer. Does not deallocate the value.
Note that val's type may not actually be a pointer; value_as_long
handles all the cases. */
CORE_ADDR
int len;
int nosign;
- *invp = 0; /* Assume valid. */
+ *invp = 0; /* Assume valid. */
CHECK_TYPEDEF (type);
code = TYPE_CODE (type);
len = TYPE_LENGTH (type);
\f
/* Get the value of the FIELDNO'th field (which must be static) of
TYPE. Return NULL if the field doesn't exist or has been
- optimized out. */
+ optimized out. */
struct value *
value_static_field (struct type *type, int fieldno)
case FIELD_LOC_KIND_PHYSNAME:
{
char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno);
- /*TYPE_FIELD_NAME (type, fieldno);*/
+ /* TYPE_FIELD_NAME (type, fieldno); */
struct symbol *sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0);
if (sym == NULL)
{
/* With some compilers, e.g. HP aCC, static data members are
- reported as non-debuggable symbols */
+ reported as non-debuggable symbols. */
struct minimal_symbol *msym = lookup_minimal_symbol (phys_name,
NULL, NULL);
/* Given a value ARG1 (offset by OFFSET bytes)
of a struct or union type ARG_TYPE,
extract and return the value of one of its (non-static) fields.
- FIELDNO says which field. */
+ FIELDNO says which field. */
struct value *
value_primitive_field (struct value *arg1, int offset,
/* Given a value ARG1 of a struct or union type,
extract and return the value of one of its (non-static) fields.
- FIELDNO says which field. */
+ FIELDNO says which field. */
struct value *
value_field (struct value *arg1, int fieldno)
J is an index into F which provides the desired method.
We only use the symbol for its address, so be happy with either a
- full symbol or a minimal symbol.
- */
+ full symbol or a minimal symbol. */
struct value *
value_fn_field (struct value **arg1p, struct fn_field *f,
value_addr (*arg1p)));
/* Move the `this' pointer according to the offset.
- VALUE_OFFSET (*arg1p) += offset;
- */
+ VALUE_OFFSET (*arg1p) += offset; */
}
return v;
number of bits from the LSB of the anonymous object to the LSB of the
bitfield.
- If the field is signed, we also do sign extension. */
+ If the field is signed, we also do sign extension. */
LONGEST
unpack_bits_as_long (struct type *field_type, const gdb_byte *valaddr,
val = extract_unsigned_integer (valaddr + bitpos / 8,
bytes_read, byte_order);
- /* Extract bits. See comment above. */
+ /* Extract bits. See comment above. */
if (gdbarch_bits_big_endian (get_type_arch (field_type)))
lsbcount = (bytes_read * 8 - bitpos % 8 - bitsize);
val >>= lsbcount;
/* If the field does not entirely fill a LONGEST, then zero the sign bits.
- If the field is signed, and is negative, then sign extend. */
+ If the field is signed, and is negative, then sign extend. */
if ((bitsize > 0) && (bitsize < 8 * (int) sizeof (val)))
{
/* Modify the value of a bitfield. ADDR points to a block of memory in
target byte order; the bitfield starts in the byte pointed to. FIELDVAL
is the desired value of the field, in host byte order. BITPOS and BITSIZE
- indicate which bits (in target bit order) comprise the bitfield.
+ indicate which bits (in target bit order) comprise the bitfield.
Requires 0 < BITSIZE <= lbits, 0 <= BITPOS % 8 + BITSIZE <= lbits, and
0 <= BITPOS, where lbits is the size of a LONGEST in bits. */
extern int value_entirely_optimized_out (const struct value *value);
/* Set or return field indicating whether a variable is initialized or
- not, based on debugging information supplied by the compiler.
+ not, based on debugging information supplied by the compiler.
1 = initialized; 0 = uninitialized. */
extern int value_initialized (struct value *);
extern void set_value_initialized (struct value *, int);
fprintf_filtered (file, _("Varobj debugging is %s.\n"), value);
}
-/* String representations of gdb's format codes */
+/* String representations of gdb's format codes. */
char *varobj_format_string[] =
{ "natural", "binary", "decimal", "hexadecimal", "octal" };
-/* String representations of gdb's known languages */
+/* String representations of gdb's known languages. */
char *varobj_language_string[] = { "unknown", "C", "C++", "Java" };
/* True if we want to allow Python-based pretty-printing. */
/* Data structures */
/* Every root variable has one of these structures saved in its
- varobj. Members which must be free'd are noted. */
+ varobj. Members which must be free'd are noted. */
struct varobj_root
{
- /* Alloc'd expression for this parent. */
+ /* Alloc'd expression for this parent. */
struct expression *exp;
- /* Block for which this expression is valid */
+ /* Block for which this expression is valid. */
struct block *valid_block;
/* The frame for this expression. This field is set iff valid_block is
struct frame_id frame;
/* The thread ID that this varobj_root belong to. This field
- is only valid if valid_block is not NULL.
+ is only valid if valid_block is not NULL.
When not 0, indicates which thread 'frame' belongs to.
When 0, indicates that the thread list was empty when the varobj_root
was created. */
/* If 1, the -var-update always recomputes the value in the
current thread and frame. Otherwise, variable object is
- always updated in the specific scope/thread/frame */
+ always updated in the specific scope/thread/frame. */
int floating;
/* Flag that indicates validity: set to 0 when this varobj_root refers
to symbols that do not exist anymore. */
int is_valid;
- /* Language info for this variable and its children */
+ /* Language info for this variable and its children. */
struct language_specific *lang;
- /* The varobj for this root node. */
+ /* The varobj for this root node. */
struct varobj *rootvar;
/* Next root variable */
};
/* Every variable in the system has a structure of this type defined
- for it. This structure holds all information necessary to manipulate
- a particular object variable. Members which must be freed are noted. */
+ for it. This structure holds all information necessary to manipulate
+ a particular object variable. Members which must be freed are noted. */
struct varobj
{
- /* Alloc'd name of the variable for this object.. If this variable is a
+ /* Alloc'd name of the variable for this object. If this variable is a
child, then this name will be the child's source name.
- (bar, not foo.bar) */
- /* NOTE: This is the "expression" */
+ (bar, not foo.bar). */
+ /* NOTE: This is the "expression". */
char *name;
/* Alloc'd expression for this child. Can be used to create a
root variable corresponding to this child. */
char *path_expr;
- /* The alloc'd name for this variable's object. This is here for
- convenience when constructing this object's children. */
+ /* The alloc'd name for this variable's object. This is here for
+ convenience when constructing this object's children. */
char *obj_name;
- /* Index of this variable in its parent or -1 */
+ /* Index of this variable in its parent or -1. */
int index;
/* The type of this variable. This can be NULL
the value is either NULL, or not lazy. */
struct value *value;
- /* The number of (immediate) children this variable has */
+ /* The number of (immediate) children this variable has. */
int num_children;
- /* If this object is a child, this points to its immediate parent. */
+ /* If this object is a child, this points to its immediate parent. */
struct varobj *parent;
/* Children of this object. */
can avoid that. */
int children_requested;
- /* Description of the root variable. Points to root variable for children. */
+ /* Description of the root variable. Points to root variable for
+ children. */
struct varobj_root *root;
- /* The format of the output for this object */
+ /* The format of the output for this object. */
enum varobj_display_formats format;
- /* Was this variable updated via a varobj_set_value operation */
+ /* Was this variable updated via a varobj_set_value operation. */
int updated;
/* Last print value. */
/* Private function prototypes */
-/* Helper functions for the above subcommands. */
+/* Helper functions for the above subcommands. */
static int delete_variable (struct cpstack **, struct varobj *, int);
static int install_new_value (struct varobj *var, struct value *value,
int initial);
-/* Language-specific routines. */
+/* Language-specific routines. */
static enum varobj_languages variable_language (struct varobj *var);
struct language_specific
{
- /* The language of this variable */
+ /* The language of this variable. */
enum varobj_languages language;
- /* The number of children of PARENT. */
+ /* The number of children of PARENT. */
int (*number_of_children) (struct varobj * parent);
- /* The name (expression) of a root varobj. */
+ /* The name (expression) of a root varobj. */
char *(*name_of_variable) (struct varobj * parent);
- /* The name of the INDEX'th child of PARENT. */
+ /* The name of the INDEX'th child of PARENT. */
char *(*name_of_child) (struct varobj * parent, int index);
/* Returns the rooted expression of CHILD, which is a variable
obtain that has some parent. */
char *(*path_expr_of_child) (struct varobj * child);
- /* The ``struct value *'' of the root variable ROOT. */
+ /* The ``struct value *'' of the root variable ROOT. */
struct value *(*value_of_root) (struct varobj ** root_handle);
- /* The ``struct value *'' of the INDEX'th child of PARENT. */
+ /* The ``struct value *'' of the INDEX'th child of PARENT. */
struct value *(*value_of_child) (struct varobj * parent, int index);
- /* The type of the INDEX'th child of PARENT. */
+ /* The type of the INDEX'th child of PARENT. */
struct type *(*type_of_child) (struct varobj * parent, int index);
- /* The current value of VAR. */
+ /* The current value of VAR. */
char *(*value_of_variable) (struct varobj * var,
enum varobj_display_formats format);
};
-/* Array of known source language routines. */
+/* Array of known source language routines. */
static struct language_specific languages[vlang_end] = {
- /* Unknown (try treating as C */
+ /* Unknown (try treating as C). */
{
vlang_unknown,
c_number_of_children,
java_value_of_variable}
};
-/* A little convenience enum for dealing with C++/Java */
+/* A little convenience enum for dealing with C++/Java. */
enum vsections
{
v_public = 0, v_private, v_protected
/* Private data */
-/* Mappings of varobj_display_formats enums to gdb's format codes */
+/* Mappings of varobj_display_formats enums to gdb's format codes. */
static int format_code[] = { 0, 't', 'd', 'x', 'o' };
-/* Header of the list of root variable objects */
+/* Header of the list of root variable objects. */
static struct varobj_root *rootlist;
-/* Prime number indicating the number of buckets in the hash table */
-/* A prime large enough to avoid too many colisions */
+/* Prime number indicating the number of buckets in the hash table. */
+/* A prime large enough to avoid too many colisions. */
#define VAROBJ_TABLE_SIZE 227
-/* Pointer to the varobj hash table (built at run time) */
+/* Pointer to the varobj hash table (built at run time). */
static struct vlist **varobj_table;
-/* Is the variable X one of our "fake" children? */
+/* Is the variable X one of our "fake" children? */
#define CPLUS_FAKE_CHILD(x) \
((x) != NULL && (x)->type == NULL && (x)->value == NULL)
\f
}
#endif
-/* Creates a varobj (not its children) */
+/* Creates a varobj (not its children). */
/* Return the full FRAME which corresponds to the given CORE_ADDR
or NULL if no FRAME on the chain corresponds to CORE_ADDR. */
struct varobj *var;
struct cleanup *old_chain;
- /* Fill out a varobj structure for the (root) variable being constructed. */
+ /* Fill out a varobj structure for the (root) variable being constructed. */
var = new_root_variable ();
old_chain = make_cleanup_free_variable (var);
if (has_stack_frames ())
{
- /* Allow creator to specify context of variable */
+ /* Allow creator to specify context of variable. */
if ((type == USE_CURRENT_FRAME) || (type == USE_SELECTED_FRAME))
fi = get_selected_frame (NULL);
else
else
fi = NULL;
- /* frame = -2 means always use selected frame */
+ /* frame = -2 means always use selected frame. */
if (type == USE_SELECTED_FRAME)
var->root->floating = 1;
p = expression;
innermost_block = NULL;
/* Wrap the call to parse expression, so we can
- return a sensible error. */
+ return a sensible error. */
if (!gdb_parse_exp_1 (&p, block, 0, &var->root->exp))
{
return NULL;
}
- /* Don't allow variables to be created for types. */
+ /* Don't allow variables to be created for types. */
if (var->root->exp->elts[0].opcode == OP_TYPE)
{
do_cleanups (old_chain);
/* When the frame is different from the current frame,
we must select the appropriate frame before parsing
the expression, otherwise the value will not be current.
- Since select_frame is so benign, just call it for all cases. */
+ Since select_frame is so benign, just call it for all cases. */
if (innermost_block)
{
/* User could specify explicit FRAME-ADDR which was not found but
/* We definitely need to catch errors here.
If evaluate_expression succeeds we got the value we wanted.
- But if it fails, we still go on with a call to evaluate_type() */
+ But if it fails, we still go on with a call to evaluate_type(). */
if (!gdb_evaluate_expression (var->root->exp, &value))
{
/* Error getting the value. Try to at least get the
lang = variable_language (var);
var->root->lang = &languages[lang];
- /* Set ourselves as our root */
+ /* Set ourselves as our root. */
var->root->rootvar = var;
- /* Reset the selected frame */
+ /* Reset the selected frame. */
if (frame_id_p (old_id))
select_frame (frame_find_by_id (old_id));
}
/* If the variable object name is null, that means this
- is a temporary variable, so don't install it. */
+ is a temporary variable, so don't install it. */
if ((var != NULL) && (objname != NULL))
{
var->obj_name = xstrdup (objname);
/* If a varobj name is duplicated, the install will fail so
- we must clenup */
+ we must cleanup. */
if (!install_variable (var))
{
do_cleanups (old_chain);
return var;
}
-/* Generates an unique name that can be used for a varobj */
+/* Generates an unique name that can be used for a varobj. */
char *
varobj_gen_name (void)
static int id = 0;
char *obj_name;
- /* generate a name for this object */
+ /* Generate a name for this object. */
id++;
obj_name = xstrprintf ("var%d", id);
return cv->var;
}
-/* Given the handle, return the name of the object */
+/* Given the handle, return the name of the object. */
char *
varobj_get_objname (struct varobj *var)
return var->obj_name;
}
-/* Given the handle, return the expression represented by the object */
+/* Given the handle, return the expression represented by the object. */
char *
varobj_get_expression (struct varobj *var)
/* Deletes a varobj and all its children if only_children == 0,
otherwise deletes only the children; returns a malloc'ed list of
all the (malloc'ed) names of the variables that have been deleted
- (NULL terminated) */
+ (NULL terminated). */
int
varobj_delete (struct varobj *var, char ***dellist, int only_children)
struct cpstack *result = NULL;
char **cp;
- /* Initialize a stack for temporary results */
+ /* Initialize a stack for temporary results. */
cppush (&result, NULL);
if (only_children)
- /* Delete only the variable children */
+ /* Delete only the variable children. */
delcount = delete_variable (&result, var, 1 /* only the children */ );
else
- /* Delete the variable and all its children */
+ /* Delete the variable and all its children. */
delcount = delete_variable (&result, var, 0 /* parent+children */ );
- /* We may have been asked to return a list of what has been deleted */
+ /* We may have been asked to return a list of what has been deleted. */
if (dellist != NULL)
{
*dellist = xmalloc ((delcount + 1) * sizeof (char *));
#endif
-/* Set/Get variable object display format */
+/* Set/Get variable object display format. */
enum varobj_display_formats
varobj_set_display_format (struct varobj *var,
/* If the variable object is bound to a specific thread, that
is its evaluation can always be done in context of a frame
inside that thread, returns GDB id of the thread -- which
- is always positive. Otherwise, returns -1. */
+ is always positive. Otherwise, returns -1. */
int
varobj_get_thread_id (struct varobj *var)
{
}
/* Creates a list of the immediate children of a variable object;
- the return code is the number of such children or -1 on error */
+ the return code is the number of such children or -1 on error. */
VEC (varobj_p)*
varobj_list_children (struct varobj *var, int *from, int *to)
#endif /* HAVE_PYTHON */
/* Obtain the type of an object Variable as a string similar to the one gdb
- prints on the console */
+ prints on the console. */
char *
varobj_get_type (struct varobj *var)
{
- /* For the "fake" variables, do not return a type. (It's type is
+ /* For the "fake" variables, do not return a type. (It's type is
NULL, too.)
Do not return a type for invalid variables as well. */
if (CPLUS_FAKE_CHILD (var) || !var->root->is_valid)
int attributes = 0;
if (varobj_editable_p (var))
- /* FIXME: define masks for attributes */
+ /* FIXME: define masks for attributes. */
attributes |= 0x00000001; /* Editable */
return attributes;
}
/* Set the value of an object variable (if it is editable) to the
- value of the given expression */
-/* Note: Invokes functions that can call error() */
+ value of the given expression. */
+/* Note: Invokes functions that can call error(). */
int
varobj_set_value (struct varobj *var, char *expression)
struct value *val;
/* The argument "expression" contains the variable's new value.
- We need to first construct a legal expression for this -- ugh! */
- /* Does this cover all the bases? */
+ We need to first construct a legal expression for this -- ugh! */
+ /* Does this cover all the bases? */
struct expression *exp;
struct value *value;
int saved_input_radix = input_radix;
gdb_assert (varobj_editable_p (var));
- input_radix = 10; /* ALWAYS reset to decimal temporarily */
+ input_radix = 10; /* ALWAYS reset to decimal temporarily. */
exp = parse_exp_1 (&s, 0, 0);
if (!gdb_evaluate_expression (exp, &value))
{
- /* We cannot proceed without a valid expression. */
+ /* We cannot proceed without a valid expression. */
xfree (exp);
return 0;
}
variable as changed -- because the first assignment has set the
'updated' flag. There's no need to optimize that, because return value
of -var-update should be considered an approximation. */
- var->updated = install_new_value (var, val, 0 /* Compare values. */);
+ var->updated = install_new_value (var, val, 0 /* Compare values. */);
input_radix = saved_input_radix;
return 1;
}
this is the first assignement after the variable object was just
created, or changed type. In that case, just assign the value
and return 0.
- Otherwise, assign the new value, and return 1 if the value is different
- from the current one, 0 otherwise. The comparison is done on textual
- representation of value. Therefore, some types need not be compared. E.g.
- for structures the reported value is always "{...}", so no comparison is
- necessary here. If the old value was NULL and new one is not, or vice versa,
- we always return 1.
+ Otherwise, assign the new value, and return 1 if the value is
+ different from the current one, 0 otherwise. The comparison is
+ done on textual representation of value. Therefore, some types
+ need not be compared. E.g. for structures the reported value is
+ always "{...}", so no comparison is necessary here. If the old
+ value was NULL and new one is not, or vice versa, we always return 1.
The VALUE parameter should not be released -- the function will
take care of releasing it when needed. */
/* We need to know the varobj's type to decide if the value should
be fetched or not. C++ fake children (public/protected/private)
- don't have a type. */
+ don't have a type. */
gdb_assert (var->type || CPLUS_FAKE_CHILD (var));
changeable = varobj_value_is_changeable_p (var);
/* If the type has custom visualizer, we consider it to be always
- changeable. FIXME: need to make sure this behaviour will not
+ changeable. FIXME: need to make sure this behaviour will not
mess up read-sensitive values. */
if (var->pretty_printer)
changeable = 1;
/* If the value of the varobj was changed by -var-set-value,
then the value in the varobj and in the target is the same.
However, that value is different from the value that the
- varobj had after the previous -var-update. So need to the
+ varobj had after the previous -var-update. So need to the
varobj as changed. */
if (var->updated)
{
changed = 1;
}
else if (var->value == NULL && value == NULL)
- /* Equal. */
+ /* Equal. */
;
else if (var->value == NULL || value == NULL)
{
The EXPLICIT parameter specifies if this call is result
of MI request to update this specific variable, or
- result of implicit -var-update *. For implicit request, we don't
+ result of implicit -var-update *. For implicit request, we don't
update frozen variables.
- NOTE: This function may delete the caller's varobj. If it
+ NOTE: This function may delete the caller's varobj. If it
returns TYPE_CHANGED, then it has done this and VARP will be modified
to point to the new varobj. */
r.varobj = *varp;
r.status = VAROBJ_IN_SCOPE;
- /* Update the root variable. value_of_root can return NULL
+ /* Update the root variable. value_of_root can return NULL
if the variable is no longer around, i.e. we stepped out of
- the frame in which a local existed. We are letting the
+ the frame in which a local existed. We are letting the
value_of_root variable dispose of the varobj if the type
has changed. */
new = value_of_root (varp, &type_changed);
/* We probably should not get children of a varobj that has a
pretty-printer, but for which -var-list-children was never
- invoked. */
+ invoked. */
if (v->pretty_printer)
{
VEC (varobj_p) *changed = 0, *new = 0, *unchanged = 0;
return delcount;
}
-/* Delete the variable object VAR and its children */
+/* Delete the variable object VAR and its children. */
/* IMPORTANT NOTE: If we delete a variable which is a child
and the parent is not removed we dump core. It must be always
- initially called with remove_from_parent_p set */
+ initially called with remove_from_parent_p set. */
static void
delete_variable_1 (struct cpstack **resultp, int *delcountp,
struct varobj *var, int only_children_p,
{
int i;
- /* Delete any children of this variable, too. */
+ /* Delete any children of this variable, too. */
for (i = 0; i < VEC_length (varobj_p, var->children); ++i)
{
varobj_p child = VEC_index (varobj_p, var->children, i);
}
VEC_free (varobj_p, var->children);
- /* if we were called to delete only the children we are done here */
+ /* if we were called to delete only the children we are done here. */
if (only_children_p)
return;
- /* Otherwise, add it to the list of deleted ones and proceed to do so */
+ /* Otherwise, add it to the list of deleted ones and proceed to do so. */
/* If the name is null, this is a temporary variable, that has not
- yet been installed, don't report it, it belongs to the caller... */
+ yet been installed, don't report it, it belongs to the caller... */
if (var->obj_name != NULL)
{
cppush (resultp, xstrdup (var->obj_name));
*delcountp = *delcountp + 1;
}
- /* If this variable has a parent, remove it from its parent's list */
+ /* If this variable has a parent, remove it from its parent's list. */
/* OPTIMIZATION: if the parent of this variable is also being deleted,
(as indicated by remove_from_parent_p) we don't bother doing an
expensive list search to find the element to remove when we are
- discarding the list afterwards */
+ discarding the list afterwards. */
if ((remove_from_parent_p) && (var->parent != NULL))
{
VEC_replace (varobj_p, var->parent->children, var->index, NULL);
if (var->obj_name != NULL)
uninstall_variable (var);
- /* Free memory associated with this variable */
+ /* Free memory associated with this variable. */
free_variable (var);
}
-/* Install the given variable VAR with the object name VAR->OBJ_NAME. */
+/* Install the given variable VAR with the object name VAR->OBJ_NAME. */
static int
install_variable (struct varobj *var)
{
if (cv != NULL)
error (_("Duplicate variable object name"));
- /* Add varobj to hash table */
+ /* Add varobj to hash table. */
newvl = xmalloc (sizeof (struct vlist));
newvl->next = *(varobj_table + index);
newvl->var = var;
*(varobj_table + index) = newvl;
- /* If root, add varobj to root list */
+ /* If root, add varobj to root list. */
if (is_root_p (var))
{
- /* Add to list of root variables */
+ /* Add to list of root variables. */
if (rootlist == NULL)
var->root->next = NULL;
else
return 1; /* OK */
}
-/* Unistall the object VAR. */
+/* Unistall the object VAR. */
static void
uninstall_variable (struct varobj *var)
{
unsigned int index = 0;
unsigned int i = 1;
- /* Remove varobj from hash table */
+ /* Remove varobj from hash table. */
for (chp = var->obj_name; *chp; chp++)
{
index = (index + (i++ * (unsigned int) *chp)) % VAROBJ_TABLE_SIZE;
xfree (cv);
- /* If root, remove varobj from root list */
+ /* If root, remove varobj from root list. */
if (is_root_p (var))
{
- /* Remove from list of root variables */
+ /* Remove from list of root variables. */
if (rootlist == var->root)
rootlist = var->root->next;
else
}
-/* Create and install a child of the parent of the given name */
+/* Create and install a child of the parent of the given name. */
static struct varobj *
create_child (struct varobj *parent, int index, char *name)
{
child = new_variable ();
- /* name is allocated by name_of_child */
+ /* Name is allocated by name_of_child. */
/* FIXME: xstrdup should not be here. */
child->name = xstrdup (name);
child->index = index;
calling install_new_value. */
if (value != NULL)
/* If the child had no evaluation errors, var->value
- will be non-NULL and contain a valid type. */
+ will be non-NULL and contain a valid type. */
child->type = value_type (value);
else
- /* Otherwise, we must compute the type. */
+ /* Otherwise, we must compute the type. */
child->type = (*child->root->lang->type_of_child) (child->parent,
child->index);
install_new_value (child, value, 1);
* Miscellaneous utility functions.
*/
-/* Allocate memory and initialize a new variable */
+/* Allocate memory and initialize a new variable. */
static struct varobj *
new_variable (void)
{
return var;
}
-/* Allocate memory and initialize a new root variable */
+/* Allocate memory and initialize a new root variable. */
static struct varobj *
new_root_variable (void)
{
return var;
}
-/* Free any allocated memory associated with VAR. */
+/* Free any allocated memory associated with VAR. */
static void
free_variable (struct varobj *var)
{
value_free (var->value);
- /* Free the expression if this is a root variable. */
+ /* Free the expression if this is a root variable. */
if (is_root_p (var))
{
xfree (var->root->exp);
return make_cleanup (do_free_variable_cleanup, var);
}
-/* This returns the type of the variable. It also skips past typedefs
+/* This returns the type of the variable. It also skips past typedefs
to return the real type of the variable.
NOTE: TYPE_TARGET_TYPE should NOT be used anywhere in this file
- except within get_target_type and get_type. */
+ except within get_target_type and get_type. */
static struct type *
get_type (struct varobj *var)
{
/* Return the type of the value that's stored in VAR,
or that would have being stored there if the
- value were accessible.
+ value were accessible.
This differs from VAR->type in that VAR->type is always
the true type of the expession in the source language.
past typedefs, just like get_type ().
NOTE: TYPE_TARGET_TYPE should NOT be used anywhere in this file
- except within get_target_type and get_type. */
+ except within get_target_type and get_type. */
static struct type *
get_target_type (struct type *type)
{
}
/* What is the default display for this variable? We assume that
- everything is "natural". Any exceptions? */
+ everything is "natural". Any exceptions? */
static enum varobj_display_formats
variable_default_display (struct varobj *var)
{
return FORMAT_NATURAL;
}
-/* FIXME: The following should be generic for any pointer */
+/* FIXME: The following should be generic for any pointer. */
static void
cppush (struct cpstack **pstack, char *name)
{
*pstack = s;
}
-/* FIXME: The following should be generic for any pointer */
+/* FIXME: The following should be generic for any pointer. */
static char *
cppop (struct cpstack **pstack)
{
/* Common entry points */
-/* Get the language of variable VAR. */
+/* Get the language of variable VAR. */
static enum varobj_languages
variable_language (struct varobj *var)
{
/* Return the number of children for a given variable.
The result of this function is defined by the language
- implementation. The number of children returned by this function
+ implementation. The number of children returned by this function
is the number of children that the user will see in the variable
- display. */
+ display. */
static int
number_of_children (struct varobj *var)
{
}
/* What is the expression for the root varobj VAR? Returns a malloc'd
- string. */
+ string. */
static char *
name_of_variable (struct varobj *var)
{
}
/* What is the name of the INDEX'th child of VAR? Returns a malloc'd
- string. */
+ string. */
static char *
name_of_child (struct varobj *var, int index)
{
var = *var_handle;
/* This should really be an exception, since this should
- only get called with a root variable. */
+ only get called with a root variable. */
if (!is_root_p (var))
return NULL;
return (*var->root->lang->value_of_root) (var_handle);
}
-/* What is the ``struct value *'' for the INDEX'th child of PARENT? */
+/* What is the ``struct value *'' for the INDEX'th child of PARENT? */
static struct value *
value_of_child (struct varobj *parent, int index)
{
return value;
}
-/* GDB already has a command called "value_of_variable". Sigh. */
+/* GDB already has a command called "value_of_variable". Sigh. */
static char *
my_value_of_variable (struct varobj *var, enum varobj_display_formats format)
{
for getting children of the variable object.
This includes dereferencing top-level references
to all types and dereferencing pointers to
- structures.
+ structures.
- Both TYPE and *TYPE should be non-null. VALUE
+ Both TYPE and *TYPE should be non-null. VALUE
can be null if we want to only translate type.
*VALUE can be null as well -- if the parent
- value is not known.
+ value is not known.
If WAS_PTR is not NULL, set *WAS_PTR to 0 or 1
depending on whether pointer was dereferenced
break;
case TYPE_CODE_PTR:
- /* The type here is a pointer to non-struct. Typically, pointers
+ /* The type here is a pointer to non-struct. Typically, pointers
have one child, except for function ptrs, which have no children,
and except for void*, as we don't know what to show.
We can show char* so we allow it to be dereferenced. If you decide
to test for it, please mind that a little magic is necessary to
properly identify it: char* has TYPE_CODE == TYPE_CODE_INT and
- TYPE_NAME == "char" */
+ TYPE_NAME == "char". */
if (TYPE_CODE (target) == TYPE_CODE_FUNC
|| TYPE_CODE (target) == TYPE_CODE_VOID)
children = 0;
break;
default:
- /* Other types have no children */
+ /* Other types have no children. */
break;
}
/* Return the value of element TYPE_INDEX of a structure
value VALUE. VALUE's type should be a structure,
- or union, or a typedef to struct/union.
+ or union, or a typedef to struct/union.
Returns NULL if getting the value fails. Never throws. */
static struct value *
}
/* Obtain the information about child INDEX of the variable
- object PARENT.
+ object PARENT.
If CNAME is not null, sets *CNAME to the name of the child relative
to the parent.
If CVALUE is not null, sets *CVALUE to the value of the child.
break;
default:
- /* This should not happen */
+ /* This should not happen. */
if (cname)
*cname = xstrdup ("???");
if (cfull_expression)
*cfull_expression = xstrdup ("???");
- /* Don't set value and type, we don't know then. */
+ /* Don't set value and type, we don't know then. */
}
}
int within_scope = 0;
struct cleanup *back_to;
- /* Only root variables can be updated... */
+ /* Only root variables can be updated... */
if (!is_root_p (var))
- /* Not a root var */
+ /* Not a root var. */
return NULL;
back_to = make_cleanup_restore_current_thread ();
- /* Determine whether the variable is still around. */
+ /* Determine whether the variable is still around. */
if (var->root->valid_block == NULL || var->root->floating)
within_scope = 1;
else if (var->root->thread_id == 0)
if (var->pretty_printer && var->print_value)
return xstrdup (var->print_value);
- /* Strip top-level references. */
+ /* Strip top-level references. */
while (TYPE_CODE (type) == TYPE_CODE_REF)
type = check_typedef (TYPE_TARGET_TYPE (type));
if (var->value == NULL)
{
/* This can happen if we attempt to get the value of a struct
- member when the parent is an invalid pointer. This is an
- error condition, so we should tell the caller. */
+ member when the parent is an invalid pointer. This is an
+ error condition, so we should tell the caller. */
return NULL;
}
else
gdb_assert (!value_lazy (var->value));
/* If the specified format is the current one,
- we can reuse print_value */
+ we can reuse print_value. */
if (format == var->format)
return xstrdup (var->print_value);
else
if (kids[v_protected] != 0)
children++;
- /* Add any baseclasses */
+ /* Add any baseclasses. */
children += TYPE_N_BASECLASSES (type);
dont_know = 0;
- /* FIXME: save children in var */
+ /* FIXME: save children in var. */
}
}
else
/* Compute # of public, private, and protected variables in this class.
That means we need to descend into all baseclasses and find out
- how many are there, too. */
+ how many are there, too. */
static void
cplus_class_num_children (struct type *type, int children[3])
{
particular access control type ("public","protected",
or "private"). We must skip over fields that don't
have the access control we are looking for to properly
- find the indexed field. */
+ find the indexed field. */
int type_index = TYPE_N_BASECLASSES (type);
enum accessibility acc = public_field;
int vptr_fieldno;
{
char *ptr = was_ptr ? "*" : "";
- /* Cast the parent to the base' type. Note that in gdb,
+ /* Cast the parent to the base' type. Note that in gdb,
expression like
(Base1)d
will create an lvalue, for all appearences, so we don't
only be "public", "private", or "protected"
The special "fake" children are always output by varobj in
- this order. So if INDEX == 2, it MUST be "protected". */
+ this order. So if INDEX == 2, it MUST be "protected". */
index -= TYPE_N_BASECLASSES (type);
switch (index)
{
access = "protected";
break;
case 2:
- /* Must be protected */
+ /* Must be protected. */
access = "protected";
break;
default:
- /* error! */
+ /* error! */
break;
}
{
/* If we have one of our special types, don't print out
- any value. */
+ any value. */
if (CPLUS_FAKE_CHILD (var))
return xstrdup ("");
name = cplus_name_of_variable (parent);
/* If the name has "-" in it, it is because we
- needed to escape periods in the name... */
+ needed to escape periods in the name... */
p = name;
while (*p != '\000')
char *name, *p;
name = cplus_name_of_child (parent, index);
- /* Escape any periods in the name... */
+ /* Escape any periods in the name... */
p = name;
while (*p != '\000')
enum varobj_type
{
- USE_SPECIFIED_FRAME, /* Use the frame passed to varobj_create */
- USE_CURRENT_FRAME, /* Use the current frame */
- USE_SELECTED_FRAME /* Always reevaluate in selected frame */
+ USE_SPECIFIED_FRAME, /* Use the frame passed to varobj_create. */
+ USE_CURRENT_FRAME, /* Use the current frame. */
+ USE_SELECTED_FRAME /* Always reevaluate in selected frame. */
};
/* Enumerator describing if a variable object is in scope. */
will. */
};
-/* String representations of gdb's format codes (defined in varobj.c) */
+/* String representations of gdb's format codes (defined in varobj.c). */
extern char *varobj_format_string[];
-/* Languages supported by this variable objects system. */
+/* Languages supported by this variable objects system. */
enum varobj_languages
{
vlang_unknown = 0, vlang_c, vlang_cplus, vlang_java, vlang_end
};
-/* String representations of gdb's known languages (defined in varobj.c) */
+/* String representations of gdb's known languages (defined in varobj.c). */
extern char *varobj_language_string[];
-/* Struct thar describes a variable object instance */
+/* Struct thar describes a variable object instance. */
struct varobj;
typedef struct varobj *varobj_p;
enum varobj_scope_status status;
/* This variable is used internally by varobj_update to indicate if the
new value of varobj is already computed and installed, or has to
- be yet installed. Don't use this outside varobj.c */
+ be yet installed. Don't use this outside varobj.c. */
int value_installed;
/* This will be non-NULL when new children were added to the varobj.
}
/* Return the GDB type object for the "standard" data type of data in
- register REGNUM. */
+ register REGNUM. */
static struct type *
vax_register_type (struct gdbarch *gdbarch, int regnum)
alloc = num + -reserve;
else
{
- /* Exponential growth. */
+ /* Exponential growth. */
if (!alloc)
alloc = 4;
else if (alloc < 16)
/* Grow slower when large. */
alloc = (alloc * 3 / 2);
- /* If this is still too small, set it to the right size. */
+ /* If this is still too small, set it to the right size. */
if (alloc < num + reserve)
alloc = num + reserve;
}
/* Ensure there are at least abs(RESERVE) free slots in VEC. If
RESERVE < 0 grow exactly, else grow exponentially. As a special
- case, if VEC is NULL, and RESERVE is 0, no vector will be created. */
+ case, if VEC is NULL, and RESERVE is 0, no vector will be created. */
void *
vec_p_reserve (void *vec, int reserve)
specific size from the get go.
You should prefer the push and pop operations, as they append and
- remove from the end of the vector. If you need to remove several
+ remove from the end of the vector. If you need to remove several
items in one go, use the truncate operation. The insert and remove
operations allow you to change elements in the middle of the
vector. There are two remove operations, one which preserves the
T *VEC_T_quick_push (VEC(T) *v, T *obj); // Object
Push a new element onto the end, returns a pointer to the slot
- filled in. For object vectors, the new value can be NULL, in which
+ filled in. For object vectors, the new value can be NULL, in which
case NO initialization is performed. There must
be sufficient space in the vector. */
T *VEC_T_safe_push (VEC(T,A) *&v, T *obj); // Object
Push a new element onto the end, returns a pointer to the slot
- filled in. For object vectors, the new value can be NULL, in which
+ filled in. For object vectors, the new value can be NULL, in which
case NO initialization is performed. Reallocates V, if needed. */
#define VEC_safe_push(T,V,O) (VEC_OP(T,safe_push)(&(V),O VEC_ASSERT_INFO))
T VEC_T_pop (VEC(T) *v); // Pointer
void VEC_T_pop (VEC(T) *v); // Object
- Pop the last element off the end. Returns the element popped, for
+ Pop the last element off the end. Returns the element popped, for
pointer vectors. */
#define VEC_pop(T,V) (VEC_OP(T,pop)(V VEC_ASSERT_INFO))
T *VEC_T_replace (VEC(T) *v, unsigned ix, T *val); // Object
Replace the IXth element of V with a new value, VAL. For pointer
- vectors returns the original value. For object vectors returns a
+ vectors returns the original value. For object vectors returns a
pointer to the new value. For object vectors the new value can be
NULL, in which case no overwriting of the slot is actually
performed. */
T *VEC_T_quick_insert (VEC(T) *v, unsigned ix, T val); // Pointer
T *VEC_T_quick_insert (VEC(T) *v, unsigned ix, T *val); // Object
- Insert an element, VAL, at the IXth position of V. Return a pointer
+ Insert an element, VAL, at the IXth position of V. Return a pointer
to the slot created. For vectors of object, the new value can be
NULL, in which case no initialization of the inserted slot takes
- place. There must be sufficient space. */
+ place. There must be sufficient space. */
#define VEC_quick_insert(T,V,I,O) \
(VEC_OP(T,quick_insert)(V,I,O VEC_ASSERT_INFO))
T *VEC_T_safe_insert (VEC(T,A) *&v, unsigned ix, T val); // Pointer
T *VEC_T_safe_insert (VEC(T,A) *&v, unsigned ix, T *val); // Object
- Insert an element, VAL, at the IXth position of V. Return a pointer
+ Insert an element, VAL, at the IXth position of V. Return a pointer
to the slot created. For vectors of object, the new value can be
NULL, in which case no initialization of the inserted slot takes
- place. Reallocate V, if necessary. */
+ place. Reallocate V, if necessary. */
#define VEC_safe_insert(T,V,I,O) \
(VEC_OP(T,safe_insert)(&(V),I,O VEC_ASSERT_INFO))
T VEC_T_ordered_remove (VEC(T) *v, unsigned ix); // Pointer
void VEC_T_ordered_remove (VEC(T) *v, unsigned ix); // Object
- Remove an element from the IXth position of V. Ordering of
+ Remove an element from the IXth position of V. Ordering of
remaining elements is preserved. For pointer vectors returns the
removed object. This is an O(N) operation due to a memmove. */
T VEC_T_unordered_remove (VEC(T) *v, unsigned ix); // Pointer
void VEC_T_unordered_remove (VEC(T) *v, unsigned ix); // Object
- Remove an element from the IXth position of V. Ordering of
+ Remove an element from the IXth position of V. Ordering of
remaining elements is destroyed. For pointer vectors returns the
removed object. This is an O(1) operation. */
\
if (len_) \
{ \
- /* We must request exact size allocation, hence the negation. */ \
+ /* We must request exact size allocation, hence the negation. */ \
new_vec_ = (VEC (T) *) \
vec_o_reserve (NULL, -len_, offsetof (VEC(T),vec), sizeof (T)); \
\
\
if (len_) \
{ \
- /* We must request exact size allocation, hence the negation. */ \
+ /* We must request exact size allocation, hence the negation. */ \
new_vec_ = (VEC (T) *)(vec_p_reserve (NULL, -len_)); \
\
new_vec_->num = len_; \
\
if (len_) \
{ \
- /* We must request exact size allocation, hence the negation. */ \
+ /* We must request exact size allocation, hence the negation. */ \
new_vec_ = (VEC (T) *) \
vec_o_reserve (NULL, -len_, offsetof (VEC(T),vec), sizeof (T)); \
\
/* Version number of GDB, as a string. */
extern const char version[];
-/* Canonical host name as a string. */
+/* Canonical host name as a string. */
extern const char host_name[];
-/* Canonical target name as a string. */
+/* Canonical target name as a string. */
extern const char target_name[];
#endif /* #ifndef VERSION_H */
DWORD);
static BOOL WINAPI (*LookupPrivilegeValueA)(LPCSTR, LPCSTR, PLUID);
static BOOL WINAPI (*OpenProcessToken)(HANDLE, DWORD, PHANDLE);
-static BOOL WINAPI (*GetCurrentConsoleFont) (HANDLE, BOOL, CONSOLE_FONT_INFO *);
+static BOOL WINAPI (*GetCurrentConsoleFont) (HANDLE, BOOL,
+ CONSOLE_FONT_INFO *);
static COORD WINAPI (*GetConsoleFontSize) (HANDLE, DWORD);
static struct target_ops windows_ops;
# define bad_GetModuleFileNameEx bad_GetModuleFileNameExA
#else
# define __PMAX PATH_MAX
-/* The starting and ending address of the cygwin1.dll text segment. */
+/* The starting and ending address of the cygwin1.dll text segment. */
static CORE_ADDR cygwin_load_start;
static CORE_ADDR cygwin_load_end;
# if CYGWIN_VERSION_DLL_MAKE_COMBINED(CYGWIN_VERSION_API_MAJOR,CYGWIN_VERSION_API_MINOR) >= 181
# define __USEWIDE
typedef wchar_t cygwin_buf_t;
- static DWORD WINAPI (*GetModuleFileNameEx) (HANDLE, HMODULE, LPWSTR, DWORD);
+ static DWORD WINAPI (*GetModuleFileNameEx) (HANDLE, HMODULE,
+ LPWSTR, DWORD);
# define STARTUPINFO STARTUPINFOW
# define CreateProcess CreateProcessW
# define GetModuleFileNameEx_name "GetModuleFileNameExW"
# endif
#endif
-static int have_saved_context; /* True if we've saved context from a cygwin signal. */
-static CONTEXT saved_context; /* Containes the saved context from a cygwin signal. */
+static int have_saved_context; /* True if we've saved context from a
+ cygwin signal. */
+static CONTEXT saved_context; /* Containes the saved context from a
+ cygwin signal. */
/* If we're not using the old Cygwin header file set, define the
following which never should have been in the generic Win32 API
- headers in the first place since they were our own invention... */
+ headers in the first place since they were our own invention... */
#ifndef _GNU_H_WINDOWS_H
enum
{
#define DR6_CLEAR_VALUE 0xffff0ff0
/* The string sent by cygwin when it processes a signal.
- FIXME: This should be in a cygwin include file. */
+ FIXME: This should be in a cygwin include file. */
#ifndef _CYGWIN_SIGNAL_STRING
#define _CYGWIN_SIGNAL_STRING "cYgSiGw00f"
#endif
static unsigned long cygwin_get_dr6 (void);
static enum target_signal last_sig = TARGET_SIGNAL_0;
-/* Set if a signal was received from the debugged process */
+/* Set if a signal was received from the debugged process. */
/* Thread information structure used to track information that is
not available in gdb's thread structure. */
static thread_info thread_head;
-/* The process and thread handles for the above context. */
+/* The process and thread handles for the above context. */
static DEBUG_EVENT current_event; /* The current debug event from
WaitForDebugEvent */
static thread_info *current_thread; /* Info on currently selected thread */
static DWORD main_thread_id; /* Thread ID of the main thread */
-/* Counts of things. */
+/* Counts of things. */
static int exception_count = 0;
static int event_count = 0;
static int saw_create;
static int open_process_used = 0;
-/* User options. */
+/* User options. */
static int new_console = 0;
#ifdef __CYGWIN__
static int cygwin_exceptions = 0;
One day we could read a reg, we could inspect the context we
already have loaded, if it doesn't have the bit set that we need,
we read that set of registers in using GetThreadContext. If the
- context already contains what we need, we just unpack it. Then to
+ context already contains what we need, we just unpack it. Then to
write a register, first we have to ensure that the context contains
the other regs of the group, and then we copy the info in and set
- out bit. */
+ out bit. */
static const int *mappings;
/* This vector maps the target's idea of an exception (extracted
- from the DEBUG_EVENT structure) to GDB's idea. */
+ from the DEBUG_EVENT structure) to GDB's idea. */
struct xlate_exception
{
}
/* Clear out any old thread list and reintialize it to a
- pristine state. */
+ pristine state. */
static void
windows_init_thread_list (void)
{
thread_head.next = NULL;
}
-/* Delete a thread from the list of threads */
+/* Delete a thread from the list of threads. */
static void
windows_delete_thread (ptid_t ptid)
{
if (!current_thread)
return; /* Windows sometimes uses a non-existent thread id in its
- events */
+ events. */
if (current_thread->reload_context)
{
#ifdef __COPY_CONTEXT_SIZE
if (have_saved_context)
{
- /* Lie about where the program actually is stopped since cygwin has informed us that
- we should consider the signal to have occurred at another location which is stored
- in "saved_context. */
- memcpy (¤t_thread->context, &saved_context, __COPY_CONTEXT_SIZE);
+ /* Lie about where the program actually is stopped since
+ cygwin has informed us that we should consider the signal
+ to have occurred at another location which is stored in
+ "saved_context. */
+ memcpy (¤t_thread->context, &saved_context,
+ __COPY_CONTEXT_SIZE);
have_saved_context = 0;
}
else
th->context.ContextFlags = CONTEXT_DEBUGGER_DR;
GetThreadContext (th->h, &th->context);
/* Copy dr values from that thread.
- But only if there were not modified since last stop. PR gdb/2388 */
+ But only if there were not modified since last stop.
+ PR gdb/2388 */
if (!debug_registers_changed)
{
dr[0] = th->context.Dr0;
{
current_thread = thread_rec (ptid_get_tid (inferior_ptid), TRUE);
/* Check if current_thread exists. Windows sometimes uses a non-existent
- thread id in its events */
+ thread id in its events. */
if (current_thread)
do_windows_fetch_inferior_registers (regcache, r);
}
do_windows_store_inferior_registers (const struct regcache *regcache, int r)
{
if (!current_thread)
- /* Windows sometimes uses a non-existent thread id in its events */;
+ /* Windows sometimes uses a non-existent thread id in its events. */;
else if (r >= 0)
regcache_raw_collect (regcache, r,
((char *) ¤t_thread->context) + mappings[r]);
}
}
-/* Store a new register value into the current thread context */
+/* Store a new register value into the current thread context. */
static void
windows_store_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int r)
{
current_thread = thread_rec (ptid_get_tid (inferior_ptid), TRUE);
/* Check if current_thread exists. Windows sometimes uses a non-existent
- thread id in its events */
+ thread id in its events. */
if (current_thread)
do_windows_store_inferior_registers (regcache, r);
}
MODULEINFO mi;
int i;
HMODULE dh_buf[1];
- HMODULE *DllHandle = dh_buf; /* Set to temporary storage for initial query */
+ HMODULE *DllHandle = dh_buf; /* Set to temporary storage for
+ initial query. */
DWORD cbNeeded;
#ifdef __CYGWIN__
cygwin_buf_t pathbuf[__PMAX]; /* Temporary storage prior to converting to
posix form. __PMAX is always enough
as long as SO_NAME_MAX_PATH_SIZE is defined
- as 512. */
+ as 512. */
#endif
cbNeeded = 0;
- /* Find size of buffer needed to handle list of modules loaded in inferior */
+ /* Find size of buffer needed to handle list of modules loaded in
+ inferior. */
if (!EnumProcessModules (current_process_handle, DllHandle,
sizeof (HMODULE), &cbNeeded) || !cbNeeded)
goto failed;
- /* Allocate correct amount of space for module list */
+ /* Allocate correct amount of space for module list. */
DllHandle = (HMODULE *) alloca (cbNeeded);
if (!DllHandle)
goto failed;
- /* Get the list of modules */
+ /* Get the list of modules. */
if (!EnumProcessModules (current_process_handle, DllHandle, cbNeeded,
&cbNeeded))
goto failed;
for (i = 0; i < (int) (cbNeeded / sizeof (HMODULE)); i++)
{
- /* Get information on this module */
+ /* Get information on this module. */
if (!GetModuleInformation (current_process_handle, DllHandle[i],
&mi, sizeof (mi)))
error (_("Can't get module info"));
if (!base_address || mi.lpBaseOfDll == base_address)
{
- /* Try to find the name of the given module */
+ /* Try to find the name of the given module. */
#ifdef __CYGWIN__
- /* Cygwin prefers that the path be in /x/y/z format */
+ /* Cygwin prefers that the path be in /x/y/z format. */
len = GetModuleFileNameEx (current_process_handle,
DllHandle[i], pathbuf, __PMAX);
if (len == 0)
len = GetModuleFileNameEx (current_process_handle,
DllHandle[i], dll_name_ret, __PMAX);
if (len == 0)
- error (_("Error getting dll name: %u."), (unsigned) GetLastError ());
+ error (_("Error getting dll name: %u."),
+ (unsigned) GetLastError ());
#endif
return 1; /* success */
}
}
/* Encapsulate the information required in a call to
- symbol_file_add_args */
+ symbol_file_add_args. */
struct safe_symbol_file_add_args
{
char *name;
struct objfile *ret;
};
-/* Maintain a linked list of "so" information. */
+/* Maintain a linked list of "so" information. */
struct lm_info
{
LPVOID load_addr;
static struct so_list solib_start, *solib_end;
/* Call symbol_file_add with stderr redirected. We don't care if there
- are errors. */
+ are errors. */
static int
safe_symbol_file_add_stub (void *argv)
{
#undef p
}
-/* Restore gdb's stderr after calling symbol_file_add */
+/* Restore gdb's stderr after calling symbol_file_add. */
static void
safe_symbol_file_add_cleanup (void *p)
{
#undef sp
}
-/* symbol_file_add wrapper that prevents errors from being displayed. */
+/* symbol_file_add wrapper that prevents errors from being displayed. */
static struct objfile *
safe_symbol_file_add (char *name, int from_tty,
struct section_addr_info *addrs,
/* The symbols in a dll are offset by 0x1000, which is the the
offset from 0 of the first byte in an image - because of the
- file header and the section alignment. */
- cygwin_load_start = (CORE_ADDR) (uintptr_t) ((char *) load_addr + 0x1000);
+ file header and the section alignment. */
+ cygwin_load_start = (CORE_ADDR) (uintptr_t) ((char *)
+ load_addr + 0x1000);
cygwin_load_end = cygwin_load_start + bfd_section_size (abfd, text);
bfd_close (abfd);
/* Attempt to read the name of the dll that was detected.
This is documented to work only when actively debugging
- a program. It will not work for attached processes. */
+ a program. It will not work for attached processes. */
if (address == NULL)
return NULL;
/* See if we could read the address of a string, and that the
- address isn't null. */
- if (!ReadProcessMemory (h, address, &address_ptr, sizeof (address_ptr), &done)
+ address isn't null. */
+ if (!ReadProcessMemory (h, address, &address_ptr,
+ sizeof (address_ptr), &done)
|| done != sizeof (address_ptr) || !address_ptr)
return NULL;
- /* Find the length of the string */
+ /* Find the length of the string. */
while (ReadProcessMemory (h, address_ptr + len++ * size, &b, size, &done)
&& (b[0] != 0 || b[size - 1] != 0) && done == size)
continue;
return 0;
}
-/* Clear list of loaded DLLs. */
+/* Clear list of loaded DLLs. */
static void
windows_clear_solib (void)
{
solib_end = &solib_start;
}
-/* Load DLL symbol info. */
+/* Load DLL symbol info. */
void
dll_symbol_command (char *args, int from_tty)
{
/* Handle DEBUG_STRING output from child process.
Cygwin prepends its messages with a "cygwin:". Interpret this as
- a Cygwin signal. Otherwise just print the string as a warning. */
+ a Cygwin signal. Otherwise just print the string as a warning. */
static int
handle_output_debug_string (struct target_waitstatus *ourstatus)
{
&s, 1024, 0)
|| !s || !*s)
/* nothing to do */;
- else if (strncmp (s, _CYGWIN_SIGNAL_STRING, sizeof (_CYGWIN_SIGNAL_STRING) - 1) != 0)
+ else if (strncmp (s, _CYGWIN_SIGNAL_STRING,
+ sizeof (_CYGWIN_SIGNAL_STRING) - 1) != 0)
{
#ifdef __CYGWIN__
if (strncmp (s, "cYg", 3) != 0)
#ifdef __COPY_CONTEXT_SIZE
else
{
- /* Got a cygwin signal marker. A cygwin signal is followed by the signal number
- itself and then optionally followed by the thread id and address to saved context
- within the DLL. If these are supplied, then the given thread is assumed to have
- issued the signal and the context from the thread is assumed to be stored at the
- given address in the inferior. Tell gdb to treat this like a real signal. */
+ /* Got a cygwin signal marker. A cygwin signal is followed by
+ the signal number itself and then optionally followed by the
+ thread id and address to saved context within the DLL. If
+ these are supplied, then the given thread is assumed to have
+ issued the signal and the context from the thread is assumed
+ to be stored at the given address in the inferior. Tell gdb
+ to treat this like a real signal. */
char *p;
int sig = strtol (s + sizeof (_CYGWIN_SIGNAL_STRING) - 1, &p, 0);
int gotasig = target_signal_from_host (sig);
retval = main_thread_id;
else if ((x = (LPCVOID) strtoul (p, &p, 0))
&& ReadProcessMemory (current_process_handle, x,
- &saved_context, __COPY_CONTEXT_SIZE, &n)
+ &saved_context,
+ __COPY_CONTEXT_SIZE, &n)
&& n == __COPY_CONTEXT_SIZE)
have_saved_context = 1;
current_event.dwThreadId = retval;
ourstatus->kind = TARGET_WAITKIND_STOPPED;
- /* Record the context of the current thread */
+ /* Record the context of the current thread. */
th = thread_rec (current_event.dwThreadId, -1);
switch (code)
ourstatus->value.sig = TARGET_SIGNAL_SEGV;
#ifdef __CYGWIN__
{
- /* See if the access violation happened within the cygwin DLL itself. Cygwin uses
- a kind of exception handling to deal with passed-in invalid addresses. gdb
- should not treat these as real SEGVs since they will be silently handled by
- cygwin. A real SEGV will (theoretically) be caught by cygwin later in the process
- and will be sent as a cygwin-specific-signal. So, ignore SEGVs if they show up
- within the text segment of the DLL itself. */
+ /* See if the access violation happened within the cygwin DLL
+ itself. Cygwin uses a kind of exception handling to deal
+ with passed-in invalid addresses. gdb should not treat
+ these as real SEGVs since they will be silently handled by
+ cygwin. A real SEGV will (theoretically) be caught by
+ cygwin later in the process and will be sent as a
+ cygwin-specific-signal. So, ignore SEGVs if they show up
+ within the text segment of the DLL itself. */
char *fn;
- CORE_ADDR addr = (CORE_ADDR) (uintptr_t) current_event.u.Exception.ExceptionRecord.ExceptionAddress;
- if ((!cygwin_exceptions && (addr >= cygwin_load_start && addr < cygwin_load_end))
+ CORE_ADDR addr = (CORE_ADDR) (uintptr_t)
+ current_event.u.Exception.ExceptionRecord.ExceptionAddress;
+
+ if ((!cygwin_exceptions && (addr >= cygwin_load_start
+ && addr < cygwin_load_end))
|| (find_pc_partial_function (addr, &fn, NULL, NULL)
- && strncmp (fn, "KERNEL32!IsBad", strlen ("KERNEL32!IsBad")) == 0))
+ && strncmp (fn, "KERNEL32!IsBad",
+ strlen ("KERNEL32!IsBad")) == 0))
return 0;
}
#endif
ourstatus->value.sig = TARGET_SIGNAL_ILL;
break;
default:
- /* Treat unhandled first chance exceptions specially. */
+ /* Treat unhandled first chance exceptions specially. */
if (current_event.u.Exception.dwFirstChance)
return -1;
printf_unfiltered ("gdb: unknown target exception 0x%08lx at %s\n",
}
/* Resume all artificially suspended threads if we are continuing
- execution */
+ execution. */
static BOOL
windows_continue (DWORD continue_status, int id)
{
for (i = 0; xlate[i].them != -1; i++)
if (xlate[i].us == sig)
{
- current_event.u.Exception.ExceptionRecord.ExceptionCode =
- xlate[i].them;
+ current_event.u.Exception.ExceptionRecord.ExceptionCode
+ = xlate[i].them;
continue_status = DBG_EXCEPTION_NOT_HANDLED;
break;
}
DEBUG_EXEC (("gdb: windows_resume (pid=%d, tid=%ld, step=%d, sig=%d);\n",
ptid_get_pid (ptid), ptid_get_tid (ptid), step, sig));
- /* Get context for currently selected thread */
+ /* Get context for currently selected thread. */
th = thread_rec (ptid_get_tid (inferior_ptid), FALSE);
if (th)
{
if (step)
{
- /* Single step by setting t bit */
+ /* Single step by setting t bit. */
struct regcache *regcache = get_current_regcache ();
struct gdbarch *gdbarch = get_regcache_arch (regcache);
windows_fetch_inferior_registers (ops, regcache,
}
/* Allow continuing with the same signal that interrupted us.
- Otherwise complain. */
+ Otherwise complain. */
if (resume_all)
windows_continue (continue_status, -1);
return TRUE;
if (!DebugBreakProcess (current_process_handle))
- warning (_("\
-Could not interrupt program. Press Ctrl-c in the program console."));
+ warning (_("Could not interrupt program. "
+ "Press Ctrl-c in the program console."));
/* Return true to tell that Ctrl-C has been handled. */
return TRUE;
{
/* Kludge around a Windows bug where first event is a create
thread event. Caused when attached process does not have
- a main thread. */
+ a main thread. */
retval = fake_create_process ();
if (retval)
saw_create++;
}
break;
}
- /* Record the existence of this thread */
+ /* Record the existence of this thread. */
retval = current_event.dwThreadId;
th = windows_add_thread (ptid_build (current_event.dwProcessId, 0,
current_event.dwThreadId),
windows_delete_thread (ptid_build (current_event.dwProcessId, 0,
main_thread_id));
main_thread_id = current_event.dwThreadId;
- /* Add the main thread */
+ /* Add the main thread. */
th = windows_add_thread (ptid_build (current_event.dwProcessId, 0,
current_event.dwThreadId),
current_event.u.CreateProcessInfo.hThread,
}
break;
- case OUTPUT_DEBUG_STRING_EVENT: /* message from the kernel */
+ case OUTPUT_DEBUG_STRING_EVENT: /* Message from the kernel. */
DEBUG_EVENTS (("gdb: kernel event for pid=%d tid=%x code=%s)\n",
(unsigned) current_event.dwProcessId,
(unsigned) current_event.dwThreadId,
with a SPURIOUS because resume can try and step or modify things,
which needs a current_thread->h. But some of these exceptions mark
the birth or death of threads, which mean that the current thread
- isn't necessarily what you think it is. */
+ isn't necessarily what you think it is. */
while (1)
{
- The debugger and the program do not share the console, in
which case the Ctrl-c event only reached the debugger.
In that case, the ctrl_c handler will take care of interrupting
- the inferior. Note that this case is working starting with
- Windows XP. For Windows 2000, Ctrl-C should be pressed in the
+ the inferior. Note that this case is working starting with
+ Windows XP. For Windows 2000, Ctrl-C should be pressed in the
inferior console.
- The debugger and the program share the same console, in which
This code is copied from the Cygwin source code and rearranged to allow
dynamically loading of the needed symbols from advapi32 which is only
- available on NT/2K/XP. */
+ available on NT/2K/XP. */
static int
set_process_privilege (const char *privilege, BOOL enable)
{
#if 0
/* Disabled, otherwise every `attach' in an unprivileged user session
would raise the "Failed to get SE_DEBUG_NAME privilege" warning in
- windows_attach(). */
+ windows_attach(). */
/* AdjustTokenPrivileges returns TRUE even if the privilege could not
- be enabled. GetLastError () returns an correct error code, though. */
+ be enabled. GetLastError () returns an correct error code, though. */
if (enable && GetLastError () == ERROR_NOT_ALL_ASSIGNED)
goto out;
#endif
if (set_process_privilege (SE_DEBUG_NAME, TRUE) < 0)
{
printf_unfiltered ("Warning: Failed to get SE_DEBUG_NAME privilege\n");
- printf_unfiltered ("This can cause attach to fail on Windows NT/2K/XP\n");
+ printf_unfiltered ("This can cause attach to "
+ "fail on Windows NT/2K/XP\n");
}
windows_init_thread_list ();
#ifdef __CYGWIN__
if (!ok)
{
- /* Try fall back to Cygwin pid */
+ /* Try fall back to Cygwin pid. */
pid = cygwin_internal (CW_CYGWIN_PID_TO_WINPID, pid);
if (pid > 0)
{
static char path[__PMAX];
#ifdef __CYGWIN__
- /* Try to find exe name as symlink target of /proc/<pid>/exe */
+ /* Try to find exe name as symlink target of /proc/<pid>/exe. */
int nchars;
char procexe[sizeof ("/proc/4294967295/exe")];
sprintf (procexe, "/proc/%u/exe", pid);
#endif
/* If we get here then either Cygwin is hosed, this isn't a Cygwin version
- of gdb, or we're trying to debug a non-Cygwin windows executable. */
+ of gdb, or we're trying to debug a non-Cygwin windows executable. */
if (!get_module_name (0, path))
path[0] = '\0';
cygallargs = (wchar_t *) alloca (len * sizeof (wchar_t));
swprintf (cygallargs, len, L" -c 'exec %s %s'", exec_file, allargs);
#else
- cygallargs = (char *) alloca (sizeof (" -c 'exec '") + strlen (exec_file)
+ cygallargs = (char *)
+ alloca (sizeof (" -c 'exec '") + strlen (exec_file)
+ strlen (allargs) + 2);
sprintf (cygallargs, " -c 'exec %s %s'", exec_file, allargs);
#endif
}
/* Send a SIGINT to the process group. This acts just like the user typed a
- ^C on the controlling terminal. */
+ ^C on the controlling terminal. */
static void
windows_stop (ptid_t ptid)
break;
}
- target_mourn_inferior (); /* or just windows_mourn_inferior? */
+ target_mourn_inferior (); /* Or just windows_mourn_inferior? */
}
static void
windows_prepare_to_store (struct regcache *regcache)
{
- /* Do nothing, since we can store individual regs */
+ /* Do nothing, since we can store individual regs. */
}
static int
PIDGET (inferior_ptid)));
}
-/* Convert pid to printable format. */
+/* Convert pid to printable format. */
static char *
windows_pid_to_str (struct target_ops *ops, ptid_t ptid)
{
obstack_init (&obstack);
obstack_grow_str (&obstack, "<library-list>\n");
for (so = solib_start.next; so; so = so->next)
- windows_xfer_shared_library (so->so_name, (CORE_ADDR) (uintptr_t) so->lm_info->load_addr,
+ windows_xfer_shared_library (so->so_name, (CORE_ADDR)
+ (uintptr_t) so->lm_info->load_addr,
target_gdbarch, &obstack);
obstack_grow_str0 (&obstack, "</library-list>\n");
NULL, /* FIXME: i18n: */
&setlist, &showlist);
- add_setshow_boolean_cmd ("cygwin-exceptions", class_support, &cygwin_exceptions, _("\
+ add_setshow_boolean_cmd ("cygwin-exceptions", class_support,
+ &cygwin_exceptions, _("\
Break when an exception is detected in the Cygwin DLL itself."), _("\
Show whether gdb breaks on exceptions in the Cygwin DLL itself."), NULL,
NULL,
/* Determine if the thread referenced by "ptid" is alive
by "polling" it. If WaitForSingleObject returns WAIT_OBJECT_0
- it means that the thread has died. Otherwise it is assumed to be alive. */
+ it means that the thread has died. Otherwise it is assumed to be alive. */
static int
windows_thread_alive (struct target_ops *ops, ptid_t ptid)
{
gdb_assert (ptid_get_tid (ptid) != 0);
tid = ptid_get_tid (ptid);
- return WaitForSingleObject (thread_rec (tid, FALSE)->h, 0) == WAIT_OBJECT_0 ?
- FALSE : TRUE;
+ return WaitForSingleObject (thread_rec (tid, FALSE)->h, 0) == WAIT_OBJECT_0
+ ? FALSE : TRUE;
}
void
}
/* Define dummy functions which always return error for the rare cases where
- these functions could not be found. */
+ these functions could not be found. */
static BOOL WINAPI
bad_DebugActiveProcessStop (DWORD w)
{
}
/* Load any functions which may not be available in ancient versions
- of Windows. */
+ of Windows. */
void
_initialize_loadable (void)
{
}
/* Set variables to dummy versions of these processes if the function
- wasn't found in kernel32.dll. */
+ wasn't found in kernel32.dll. */
if (!DebugBreakProcess)
DebugBreakProcess = bad_DebugBreakProcess;
if (!DebugActiveProcessStop || !DebugSetProcessKillOnExit)
GetCurrentConsoleFont = bad_GetCurrentConsoleFont;
/* Load optional functions used for retrieving filename information
- associated with the currently debugged process or its dlls. */
+ associated with the currently debugged process or its dlls. */
hm = LoadLibrary ("psapi.dll");
if (hm)
{
if (!EnumProcessModules || !GetModuleInformation || !GetModuleFileNameEx)
{
/* Set variables to dummy versions of these processes if the function
- wasn't found in psapi.dll. */
+ wasn't found in psapi.dll. */
EnumProcessModules = bad_EnumProcessModules;
GetModuleInformation = bad_GetModuleInformation;
GetModuleFileNameEx = bad_GetModuleFileNameEx;
- /* This will probably fail on Windows 9x/Me. Let the user know that we're
- missing some functionality. */
- warning(_("cannot automatically find executable file or library to read symbols.\nUse \"file\" or \"dll\" command to load executable/libraries directly."));
+ /* This will probably fail on Windows 9x/Me. Let the user know
+ that we're missing some functionality. */
+ warning(_("\
+cannot automatically find executable file or library to read symbols.\n\
+Use \"file\" or \"dll\" command to load executable/libraries directly."));
}
hm = LoadLibrary ("advapi32.dll");
AdjustTokenPrivileges = (void *)
GetProcAddress (hm, "AdjustTokenPrivileges");
/* Only need to set one of these since if OpenProcessToken fails nothing
- else is needed. */
- if (!OpenProcessToken || !LookupPrivilegeValueA || !AdjustTokenPrivileges)
+ else is needed. */
+ if (!OpenProcessToken || !LookupPrivilegeValueA
+ || !AdjustTokenPrivileges)
OpenProcessToken = bad_OpenProcessToken;
}
}
" last_error_number " /* %fs:0x0034 */
};
-static const int MAX_TIB32 = sizeof (thread_information_32) / sizeof (uint32_t);
-static const int MAX_TIB64 = sizeof (thread_information_64) / sizeof (uint64_t);
+static const int MAX_TIB32 =
+ sizeof (thread_information_32) / sizeof (uint32_t);
+static const int MAX_TIB64 =
+ sizeof (thread_information_64) / sizeof (uint64_t);
static const int FULL_TIB_SIZE = 0x1000;
static int maint_display_all_tib = 0;
module_list_ptr_type = void_ptr_type;
- append_composite_type_field (list_type, "forward_list", module_list_ptr_type);
+ append_composite_type_field (list_type, "forward_list",
+ module_list_ptr_type);
append_composite_type_field (list_type, "backward_list",
module_list_ptr_type);
/* uint32_t current_seh; %fs:0x0000 */
append_composite_type_field (tib_type, "current_seh", seh_ptr_type);
/* uint32_t current_top_of_stack; %fs:0x0004 */
- append_composite_type_field (tib_type, "current_top_of_stack", void_ptr_type);
+ append_composite_type_field (tib_type, "current_top_of_stack",
+ void_ptr_type);
/* uint32_t current_bottom_of_stack; %fs:0x0008 */
append_composite_type_field (tib_type, "current_bottom_of_stack",
void_ptr_type);
/* uint32_t active_rpc_handle; %fs:0x0028 */
append_composite_type_field (tib_type, "active_rpc_handle", dword_ptr_type);
/* uint32_t thread_local_storage; %fs:0x002c */
- append_composite_type_field (tib_type, "thread_local_storage", void_ptr_type);
+ append_composite_type_field (tib_type, "thread_local_storage",
+ void_ptr_type);
/* uint32_t process_environment_block; %fs:0x0030 */
append_composite_type_field (tib_type, "process_environment_block",
peb_ptr_type);
if (target_read (¤t_target, TARGET_OBJECT_MEMORY,
NULL, tib, thread_local_base, tib_size) != tib_size)
{
- printf_filtered (_("Unable to read thread information block for %s at \
-address %s\n"),
+ printf_filtered (_("Unable to read thread information "
+ "block for %s at address %s\n"),
target_pid_to_str (ptid),
paddress (target_gdbarch, thread_local_base));
return -1;
obstack_grow_str (obstack, "\"><segment address=\"");
/* The symbols in a dll are offset by 0x1000, which is the the
offset from 0 of the first byte in an image - because of the file
- header and the section alignment. */
+ header and the section alignment. */
obstack_grow_str (obstack, paddress (gdbarch, load_addr + 0x1000));
obstack_grow_str (obstack, "\"/></library>");
}
show_maint_show_all_tib (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- fprintf_filtered (file, _("Show all non-zero elements of Thread Information \
-Block is %s.\n"), value);
+ fprintf_filtered (file, _("Show all non-zero elements of "
+ "Thread Information Block is %s.\n"), value);
}
static void
unsigned int lineno_off;
};
-/* Remember what we deduced to be the source language of this psymtab. */
+/* Remember what we deduced to be the source language of this psymtab. */
static enum language psymtab_language = language_unknown;
\f
-/* Simplified internal version of coff symbol table information */
+/* Simplified internal version of coff symbol table information. */
struct coff_symbol
{
char *c_name;
- int c_symnum; /* symbol number of this entry */
- int c_naux; /* 0 if syment only, 1 if syment + auxent */
+ int c_symnum; /* Symbol number of this entry. */
+ int c_naux; /* 0 if syment only, 1 if syment + auxent. */
long c_value;
unsigned char c_sclass;
int c_secnum;
unsigned int c_type;
};
-/* last function's saved coff symbol `cs' */
+/* Last function's saved coff symbol `cs'. */
static struct coff_symbol fcn_cs_saved;
/* Core address of start and end of text of current source file.
This is calculated from the first function seen after a C_FILE
- symbol. */
+ symbol. */
static CORE_ADDR cur_src_end_addr;
static CORE_ADDR first_object_file_end;
-/* initial symbol-table-debug-string vector length */
+/* Initial symbol-table-debug-string vector length. */
#define INITIAL_STABVECTOR_LENGTH 40
struct coff_symfile_info
{
- file_ptr min_lineno_offset; /* Where in file lowest line#s are */
- file_ptr max_lineno_offset; /* 1+last byte of line#s in file */
+ file_ptr min_lineno_offset; /* Where in file lowest line#s are. */
+ file_ptr max_lineno_offset; /* 1+last byte of line#s in file. */
/* Pointer to the string table. */
char *strtbl;
return sect;
}
\f
-/* add a given stab string into given stab vector. */
+/* add a given stab string into given stab vector. */
#if 0
Two reasons:
1) xlc (IBM's native c compiler) postpones static function code
- emission to the end of a compilation unit. This way it can
+ emission to the end of a compilation unit. This way it can
determine if those functions (statics) are needed or not, and
- can do some garbage collection (I think). This makes line
+ can do some garbage collection (I think). This makes line
numbers and corresponding addresses unordered, and we end up
with a line table like:
60 0x900
and that breaks gdb's binary search on line numbers, if the
- above table is not sorted on line numbers. And that sort
+ above table is not sorted on line numbers. And that sort
should be on function based, since gcc can emit line numbers
like:
30 0x300
10 0x400 - for the increment part of a for stmt.
- arrange_linetable() will do this sorting.
+ arrange_linetable() will do this sorting.
2) aix symbol table might look like:
.ei
basically, .bi/.ei pairs do not necessarily encapsulate
- their scope. They need to be recorded, and processed later
+ their scope. They need to be recorded, and processed later
on when we come the end of the compilation unit.
Include table (inclTable) and process_linenos() handle
that. */
-/* compare line table entry addresses. */
+/* compare line table entry addresses. */
static int
compare_lte (const void *lte1p, const void *lte2p)
return lte1->pc - lte2->pc;
}
-/* Given a line table with function entries are marked, arrange its functions
- in ascending order and strip off function entry markers and return it in
- a newly created table. If the old one is good enough, return the old one. */
+/* Given a line table with function entries are marked, arrange its
+ functions in ascending order and strip off function entry markers
+ and return it in a newly created table. If the old one is good
+ enough, return the old one. */
/* FIXME: I think all this stuff can be replaced by just passing
sort_linevec = 1 to end_symtab. */
for (function_count = 0, ii = 0; ii < oldLineTb->nitems; ++ii)
{
if (oldLineTb->item[ii].line == 0)
- { /* function entry found. */
+ { /* Function entry found. */
if (function_count >= fentry_size)
- { /* make sure you have room. */
+ { /* Make sure you have room. */
fentry_size *= 2;
fentry = (struct linetable_entry *)
xrealloc (fentry,
qsort (fentry, function_count,
sizeof (struct linetable_entry), compare_lte);
- /* allocate a new line table. */
+ /* Allocate a new line table. */
newLineTb = (struct linetable *)
xmalloc
(sizeof (struct linetable) +
(oldLineTb->nitems - function_count) * sizeof (struct linetable_entry));
- /* if line table does not start with a function beginning, copy up until
- a function begin. */
+ /* If line table does not start with a function beginning, copy up until
+ a function begin. */
newline = 0;
if (oldLineTb->item[0].line != 0)
newline < oldLineTb->nitems && oldLineTb->item[newline].line; ++newline)
newLineTb->item[newline] = oldLineTb->item[newline];
- /* Now copy function lines one by one. */
+ /* Now copy function lines one by one. */
for (ii = 0; ii < function_count; ++ii)
{
}
/* include file support: C_BINCL/C_EINCL pairs will be kept in the
- following `IncludeChain'. At the end of each symtab (end_symtab),
+ following `IncludeChain'. At the end of each symtab (end_symtab),
we will determine if we should create additional symtab's to
- represent if (the include files. */
+ represent if (the include files. */
typedef struct _inclTable
int begin, end;
struct subfile *subfile;
- unsigned funStartLine; /* start line # of its function */
+ unsigned funStartLine; /* Start line # of its function. */
}
InclTable;
static struct partial_symtab *this_symtab_psymtab;
/* given the start and end addresses of a compilation unit (or a csect,
- at times) process its lines and create appropriate line vectors. */
+ at times) process its lines and create appropriate line vectors. */
static void
process_linenos (CORE_ADDR start, CORE_ADDR end)
memset (&main_subfile, '\0', sizeof (main_subfile));
if (inclIndx == 0)
- /* All source lines were in the main source file. None in include files. */
+ /* All source lines were in the main source file. None in include
+ files. */
enter_line_range (&main_subfile, offset, 0, start, end,
&main_source_baseline);
if (strcmp (inclTable[ii].name, last_source_file) == 0)
{
/* The entry in the include table refers to the main source
- file. Add the lines to the main subfile. */
+ file. Add the lines to the main subfile. */
main_source_baseline = inclTable[ii].funStartLine;
enter_line_range
lv = main_subfile.line_vector;
- /* Line numbers are not necessarily ordered. xlc compilation will
- put static function to the end. */
+ /* Line numbers are not necessarily ordered. xlc compilation will
+ put static function to the end. */
lineTb = arrange_linetable (lv);
if (lv == lineTb)
lv = (inclTable[ii].subfile)->line_vector;
- /* Line numbers are not necessarily ordered. xlc compilation will
- put static function to the end. */
+ /* Line numbers are not necessarily ordered. xlc compilation will
+ put static function to the end. */
lineTb = arrange_linetable (lv);
#include "foo.h"
......
- while foo.h including code in it. (stupid but possible)
+ while foo.h including code in it. (stupid but possible)
Since start_subfile() looks at the name and uses an
existing one if finds, we need to provide a fake name and
fool it. */
static void
aix_process_linenos (void)
{
- /* process line numbers and enter them into line vector */
+ /* Process line numbers and enter them into line vector. */
process_linenos (last_source_start_addr, cur_src_end_addr);
}
(into the string table) but this does no harm. */
/* Reading symbol table has to be fast! Keep the followings as macros, rather
- than functions. */
+ than functions. */
#define RECORD_MINIMAL_SYMBOL(NAME, ADDR, TYPE, SECTION, OBJFILE) \
{ \
}
-/* xcoff has static blocks marked in `.bs', `.es' pairs. They cannot be
- nested. At any given time, a symbol can only be in one static block.
- This is the base address of current static block, zero if non exists. */
+/* xcoff has static blocks marked in `.bs', `.es' pairs. They cannot be
+ nested. At any given time, a symbol can only be in one static block.
+ This is the base address of current static block, zero if non exists. */
static int static_block_base = 0;
static int static_block_section = -1;
-/* true if space for symbol name has been allocated. */
+/* true if space for symbol name has been allocated. */
static int symname_alloced = 0;
struct internal_syment symbol;
char *retval;
- /* FIXME: is this the same as the passed arg? */
+ /* FIXME: is this the same as the passed arg? */
if (this_symtab_psymtab)
objfile = this_symtab_psymtab->objfile;
{
struct objfile *objfile = pst->objfile;
bfd *abfd = objfile->obfd;
- char *raw_auxptr; /* Pointer to first raw aux entry for sym */
+ char *raw_auxptr; /* Pointer to first raw aux entry for sym. */
char *strtbl =
((struct coff_symfile_info *) objfile->deprecated_sym_private)->strtbl;
char *debugsec =
struct coff_symbol fcn_stab_saved = { 0 };
- /* fcn_cs_saved is global because process_xcoff_symbol needs it. */
+ /* fcn_cs_saved is global because process_xcoff_symbol needs it. */
union internal_auxent fcn_aux_saved;
struct context_stack *new;
- char *filestring = " _start_ "; /* Name of the current file. */
+ char *filestring = " _start_ "; /* Name of the current file. */
- char *last_csect_name; /* last seen csect's name and value */
+ char *last_csect_name; /* Last seen csect's name and value. */
CORE_ADDR last_csect_val;
int last_csect_sec;
this_symtab_psymtab = pst;
/* Get the appropriate COFF "constants" related to the file we're
- handling. */
+ handling. */
local_symesz = coff_data (abfd)->local_symesz;
last_source_file = NULL;
QUIT; /* make this command interruptable. */
/* READ_ONE_SYMBOL (symbol, cs, symname_alloced); */
- /* read one symbol into `cs' structure. After processing the
+ /* read one symbol into `cs' structure. After processing the
whole symbol table, only string table will be kept in memory,
- symbol table and debug section of xcoff will be freed. Thus
+ symbol table and debug section of xcoff will be freed. Thus
we can mark symbols with names in string table as
- `alloced'. */
+ `alloced'. */
{
int ii;
}
}
- /* if symbol name starts with ".$" or "$", ignore it. */
+ /* if symbol name starts with ".$" or "$", ignore it. */
if (cs->c_name[0] == '$'
|| (cs->c_name[1] == '$' && cs->c_name[0] == '.'))
continue;
start_symtab ("_globals_", (char *) NULL, (CORE_ADDR) 0);
record_debugformat (debugfmt);
cur_src_end_addr = first_object_file_end;
- /* done with all files, everything from here on is globals */
+ /* Done with all files, everything from here on is globals. */
}
if ((cs->c_sclass == C_EXT || cs->c_sclass == C_HIDEXT)
prefers one symtab for each source file. In case
of AIX, one source file might include more than one
[PR] csect, and they don't have to be adjacent in
- terms of the space they occupy in memory. Thus, one
+ terms of the space they occupy in memory. Thus, one
single source file might get fragmented in the
memory and gdb's file start and end address
approach does not work! GCC (and I think xlc) seem
}
/* If this is the very first csect seen,
- basically `__start'. */
+ basically `__start'. */
if (just_started)
{
first_object_file_end
switch (CSECT_SCLAS (&main_aux))
{
case XMC_PR:
- /* a function entry point. */
+ /* a function entry point. */
function_entry_point:
fcn_start_addr = cs->c_value;
/* save the function header info, which will be used
- when `.bf' is seen. */
+ when `.bf' is seen. */
fcn_cs_saved = *cs;
fcn_aux_saved = main_aux;
continue;
case XMC_GL:
- /* shared library function trampoline code entry point. */
+ /* shared library function trampoline code entry point. */
continue;
case XMC_DS:
/* xlc puts each variable in a separate csect, so we get
an XTY_SD for each variable. But gcc puts several
variables in a csect, so that each variable only gets
- an XTY_LD. This will typically be XMC_RW; I suspect
+ an XTY_LD. This will typically be XMC_RW; I suspect
XMC_RO and XMC_BS might be possible too.
These variables are put in the minimal symbol table
only. */
case C_FILE:
/* c_value field contains symnum of next .file entry in table
- or symnum of first global after last .file. */
+ or symnum of first global after last .file. */
next_file_symnum = cs->c_value;
/* Complete symbol table for last object file containing
- debugging information. */
+ debugging information. */
/* Whether or not there was a csect in the previous file, we
have to call `end_stabs' and `start_stabs' to reset
record_debugformat (debugfmt);
last_csect_name = 0;
- /* reset file start and end addresses. A compilation unit
+ /* reset file start and end addresses. A compilation unit
with no text (only data) should have zero file
- boundaries. */
+ boundaries. */
file_start_addr = file_end_addr = 0;
break;
contains number of lines to '}' */
if (context_stack_depth <= 0)
- { /* We attempted to pop an empty context stack */
+ { /* We attempted to pop an empty context stack. */
ef_complaint (cs->c_symnum);
within_function = 0;
break;
case C_BINCL:
/* beginning of include file */
/* In xlc output, C_BINCL/C_EINCL pair doesn't show up in sorted
- order. Thus, when wee see them, we might not know enough info
- to process them. Thus, we'll be saving them into a table
- (inclTable) and postpone their processing. */
+ order. Thus, when wee see them, we might not know enough info
+ to process them. Thus, we'll be saving them into a table
+ (inclTable) and postpone their processing. */
record_include_begin (cs);
break;
else if (strcmp (cs->c_name, ".eb") == 0)
{
if (context_stack_depth <= 0)
- { /* We attempted to pop an empty context stack */
+ { /* We attempted to pop an empty context stack. */
eb_complaint (cs->c_symnum);
break;
}
&objfile->objfile_obstack))
-/* process one xcoff symbol. */
+/* process one xcoff symbol. */
static struct symbol *
process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
}
else
{
- /* In case we can't figure out the type, provide default. */
+ /* In case we can't figure out the type, provide default. */
SYMBOL_TYPE (sym) = objfile_type (objfile)->nodebug_data_symbol;
switch (cs->c_sclass)
return 0;
gotit:
- /* take aux entry and return its lineno */
+ /* Take aux entry and return its lineno. */
symno++;
bfd_coff_swap_aux_in (objfile->obfd, stbl + symno * local_symesz,
symbol->n_type, symbol->n_sclass,
return main_aux->x_sym.x_misc.x_lnsz.x_lnno;
}
-/* Support for line number handling */
+/* Support for line number handling. */
/* This function is called for every section; it finds the outer limits
* of the line table (minimum and maximum file offset) so that the
return;
}
- /* Read in all partial symtabs on which this one is dependent */
+ /* Read in all partial symtabs on which this one is dependent. */
for (i = 0; i < pst->number_of_dependencies; i++)
if (!pst->dependencies[i]->readin)
{
static void
xcoff_symfile_init (struct objfile *objfile)
{
- /* Allocate struct to keep track of the symfile */
+ /* Allocate struct to keep track of the symfile. */
objfile->deprecated_sym_private
= xmalloc (sizeof (struct coff_symfile_info));
/* Perform any local cleanups required when we are done with a particular
objfile. I.E, we are in the process of discarding all symbol information
for an objfile, freeing up all memory held for it, and unlinking the
- objfile struct from the global list of known objfiles. */
+ objfile struct from the global list of known objfiles. */
static void
xcoff_symfile_finish (struct objfile *objfile)
if (val != sizeof lengthbuf || length < sizeof lengthbuf)
return;
- /* Allocate string table from objfile_obstack. We will need this table
- as long as we have its symbol table around. */
+ /* Allocate string table from objfile_obstack. We will need this table
+ as long as we have its symbol table around. */
strtbl = (char *) obstack_alloc (&objfile->objfile_obstack, length);
((struct coff_symfile_info *) objfile->deprecated_sym_private)->strtbl
SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
is the address relative to which its symbols are (incremental) or 0
- (normal). */
+ (normal). */
static struct partial_symtab *
xcoff_start_psymtab (struct objfile *objfile, char *filename, int first_symnum,
((struct symloc *) result->read_symtab_private)->first_symnum = first_symnum;
result->read_symtab = xcoff_psymtab_to_symtab;
- /* Deduce the source language from the filename for this psymtab. */
+ /* Deduce the source language from the filename for this psymtab. */
psymtab_language = deduce_language_from_filename (filename);
return result;
(struct partial_symtab *, char **, int, int,
struct partial_symtab **, int, int);
-/* Close off the current usage of PST.
+/* Close off the current usage of PST.
Returns PST, or NULL if the partial symtab was empty and thrown away.
CAPPING_SYMBOL_NUMBER is the end of pst (exclusive).
scan_xcoff_symtab (struct objfile *objfile)
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
- CORE_ADDR toc_offset = 0; /* toc offset value in data section. */
+ CORE_ADDR toc_offset = 0; /* toc offset value in data section. */
char *filestring = NULL;
char *namestring;
/* Current partial symtab */
struct partial_symtab *pst;
- /* List of current psymtab's include files */
+ /* List of current psymtab's include files. */
char **psymtab_include_list;
int includes_allocated;
int includes_used;
- /* Index within current psymtab dependency list */
+ /* Index within current psymtab dependency list. */
struct partial_symtab **dependency_list;
int dependencies_used, dependencies_allocated;
union internal_auxent main_aux[5];
unsigned int ssymnum;
- char *last_csect_name = NULL; /* last seen csect's name and value */
+ char *last_csect_name = NULL; /* Last seen csect's name and value. */
CORE_ADDR last_csect_val = 0;
int last_csect_sec = 0;
- int misc_func_recorded = 0; /* true if any misc. function */
+ int misc_func_recorded = 0; /* true if any misc. function. */
int textlow_not_set = 1;
pst = (struct partial_symtab *) 0;
if (last_csect_name)
{
/* If no misc. function recorded in the last
- seen csect, enter it as a function. This
+ seen csect, enter it as a function. This
will take care of functions like strcmp()
compiled by xlc. */
case XMC_GL:
/* shared library function trampoline code entry
- point. */
+ point. */
/* record trampoline code entries as
mst_solib_trampoline symbol. When we lookup mst
symbols, we will choose mst_text over
- mst_solib_trampoline. */
+ mst_solib_trampoline. */
RECORD_MINIMAL_SYMBOL
(namestring, symbol.n_value,
mst_solib_trampoline,
case C_BINCL:
{
- /* Mark down an include file in the current psymtab */
+ /* Mark down an include file in the current psymtab. */
enum language tmp_language;
swap_sym (&symbol, &main_aux[0], &namestring, &sraw_symbol,
/* In C++, one may expect the same filename to come round many
times, when code is coming alternately from the main file
- and from inline functions in other files. So I check to see
+ and from inline functions in other files. So I check to see
if this is a file we've seen before -- either the main
source file, or a previously included file.
symbol.n_value += ANOFFSET (objfile->section_offsets,
SECT_OFF_DATA (objfile));
/* The addresses in these entries are reported to be
- wrong. See the code that reads 'G's for symtabs. */
+ wrong. See the code that reads 'G's for symtabs. */
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_STATIC,
&objfile->global_psymbols,
goto check_enum;
case 't':
- if (p != namestring) /* a name is there, not just :T... */
+ if (p != namestring) /* a name is there, not just :T... */
{
add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_TYPEDEF,
}
/* We need only the minimal symbols for these
- loader-generated definitions. Keeping the global
+ loader-generated definitions. Keeping the global
symbols leads to "in psymbols but not in symbols"
- errors. */
+ errors. */
if (strncmp (namestring, "@FIX", 4) == 0)
continue;
dependencies_used, textlow_not_set);
}
- /* Record the toc offset value of this symbol table into objfile structure.
- If no XMC_TC0 is found, toc_offset should be zero. Another place to obtain
- this information would be file auxiliary header. */
+ /* Record the toc offset value of this symbol table into objfile
+ structure. If no XMC_TC0 is found, toc_offset should be zero.
+ Another place to obtain this information would be file auxiliary
+ header. */
((struct coff_symfile_info *) objfile->deprecated_sym_private)->toc_offset
= toc_offset;
hung off the objfile structure.
SECTION_OFFSETS contains offsets relative to which the symbols in the
- various sections are (depending where the sections were actually loaded).
-*/
+ various sections are (depending where the sections were actually
+ loaded). */
static void
xcoff_initial_scan (struct objfile *objfile, int symfile_flags)
if (val != size)
perror_with_name (_("reading symbol table"));
- /* If we are reinitializing, or if we have never loaded syms yet, init */
+ /* If we are reinitializing, or if we have never loaded syms yet, init. */
if (objfile->global_psymbols.size == 0 && objfile->static_psymbols.size == 0)
/* I'm not sure how how good num_symbols is; the rule of thumb in
init_psymbol_list was developed for a.out. On the one hand,
scan_xcoff_symtab (objfile);
/* Install any minimal symbols that have been collected as the current
- minimal symbols for this objfile. */
+ minimal symbols for this objfile. */
install_minimal_symbols (objfile);
obstack_alloc (&objfile->objfile_obstack,
SIZEOF_N_SECTION_OFFSETS (objfile->num_sections));
- /* Initialize the section indexes for future use. */
+ /* Initialize the section indexes for future use. */
sect = bfd_get_section_by_name (objfile->obfd, ".text");
if (sect)
objfile->sect_index_text = sect->index;
if (!vp)
return;
- /* skip over the first vmap, it is the main program, always loaded. */
+ /* skip over the first vmap, it is the main program, always loaded. */
for (vp = vp->nxt; vp; vp = vp->nxt)
if (! pattern
|| re_exec (vp->name)
gdb_xml_error (parser, _("Required element <%s> is missing"),
element->name);
- /* Call the element processor. */
+ /* Call the element processor. */
if (scope->element != NULL && scope->element->end_handler)
{
char *body;
/* Xstormy16 has 16 general purpose registers (R0-R15) plus PC.
Functions will return their values in register R2-R7 as they fit.
Otherwise a hidden pointer to an big enough area is given as argument
- to the function in r2. Further arguments are beginning in r3 then.
+ to the function in r2. Further arguments are beginning in r3 then.
R13 is used as frame pointer when GCC compiles w/o optimization
R14 is used as "PSW", displaying the CPU status.
- R15 is used implicitely as stack pointer. */
+ R15 is used implicitely as stack pointer. */
E_R0_REGNUM,
E_R1_REGNUM,
E_R2_REGNUM, E_1ST_ARG_REGNUM = E_R2_REGNUM, E_PTR_RET_REGNUM = E_R2_REGNUM,
CORE_ADDR saved_sp;
};
-/* Size of instructions, registers, etc. */
+/* Size of instructions, registers, etc. */
enum
{
xstormy16_inst_size = 2,
xstormy16_pc_size = 4
};
-/* Size of return datatype which fits into the remaining return registers. */
+/* Size of return datatype which fits into the remaining return registers. */
#define E_MAX_RETTYPE_SIZE(regnum) ((E_LST_ARG_REGNUM - (regnum) + 1) \
* xstormy16_reg_size)
-/* Size of return datatype which fits into all return registers. */
+/* Size of return datatype which fits into all return registers. */
enum
{
E_MAX_RETTYPE_SIZE_IN_REGS = E_MAX_RETTYPE_SIZE (E_R2_REGNUM)
{
if (TYPE_LENGTH (type) == 1)
{
- /* Add leading zeros to the value. */
+ /* Add leading zeros to the value. */
char buf[xstormy16_reg_size];
memset (buf, 0, xstormy16_reg_size);
memcpy (buf, valbuf, 1);
argreg++;
}
- /* Arguments are passed in R2-R7 as they fit. If an argument doesn't
+ /* Arguments are passed in R2-R7 as they fit. If an argument doesn't
fit in the remaining registers we're switching over to the stack.
No argument is put on stack partially and as soon as we switched
over to stack no further argument is put in a register even if it
if (typelen > E_MAX_RETTYPE_SIZE (argreg))
break;
- /* Put argument into registers wordwise. */
+ /* Put argument into registers wordwise. */
val = value_contents (args[i]);
for (j = 0; j < typelen; j += xstormy16_reg_size)
regcache_cooked_write_unsigned (regcache, argreg++,
memcpy (val, value_contents (args[j]), typelen);
memset (val + typelen, 0, slacklen);
- /* Now write this data to the stack. The stack grows upwards. */
+ /* Now write this data to the stack. The stack grows upwards. */
write_memory (stack_dest, val, typelen + slacklen);
stack_dest += typelen + slacklen;
}
LONGEST offset;
int regnum;
- /* Initialize framesize with size of PC put on stack by CALLF inst. */
+ /* Initialize framesize with size of PC put on stack by CALLF inst. */
cache->saved_regs[E_PC_REGNUM] = 0;
cache->framesize = xstormy16_pc_size;
cache->framesize += xstormy16_reg_size;
}
- /* optional stack allocation for args and local vars <= 4 byte */
- else if (inst == 0x301f || inst == 0x303f) /* inc r15, #0x1/#0x3 */
+ /* Optional stack allocation for args and local vars <= 4 byte. */
+ else if (inst == 0x301f || inst == 0x303f) /* inc r15, #0x1/#0x3 */
{
cache->framesize += ((inst & 0x0030) >> 4) + 1;
}
cache->framesize += (inst & 0x00f0) >> 4;
}
- /* optional stack allocation for args and local vars >= 16 byte */
- else if (inst == 0x314f && inst2 >= 0x0010) /* 314f HHHH add r15, #0xH */
+ /* Optional stack allocation for args and local vars >= 16 byte. */
+ else if (inst == 0x314f && inst2 >= 0x0010) /* 314f HHHH add r15, #0xH */
{
cache->framesize += inst2;
next_addr += xstormy16_inst_size;
cache->uses_fp = 1;
}
- /* optional copying of args in r2-r7 to r10-r13 */
- /* Probably only in optimized case but legal action for prologue */
+ /* optional copying of args in r2-r7 to r10-r13. */
+ /* Probably only in optimized case but legal action for prologue. */
else if ((inst & 0xff00) == 0x4600 /* 46SD mov rD, rS */
&& (inst & 0x00f0) >= 0x0020 && (inst & 0x00f0) <= 0x0070
&& (inst & 0x000f) >= 0x00a0 && (inst & 0x000f) <= 0x000d)
;
- /* optional copying of args in r2-r7 to stack */
- /* 72DS HHHH mov.b (rD, 0xHHHH), r(S-8) (bit3 always 1, bit2-0 = reg) */
+ /* Optional copying of args in r2-r7 to stack. */
+ /* 72DS HHHH mov.b (rD, 0xHHHH), r(S-8)
+ (bit3 always 1, bit2-0 = reg) */
/* 73DS HHHH mov.w (rD, 0xHHHH), r(S-8) */
else if ((inst & 0xfed8) == 0x72d8 && (inst & 0x0007) >= 2)
{
regnum = inst & 0x0007;
/* Only 12 of 16 bits of the argument are used for the
- signed offset. */
+ signed offset. */
offset = (LONGEST) (inst2 & 0x0fff);
if (offset & 0x0800)
offset -= 0x1000;
next_addr += xstormy16_inst_size;
}
- else /* Not a prologue instruction. */
+ else /* Not a prologue instruction. */
break;
}
memset (&cache, 0, sizeof cache);
- /* Don't trust line number debug info in frameless functions. */
+ /* Don't trust line number debug info in frameless functions. */
plg_end = xstormy16_analyze_prologue (gdbarch, func_addr, func_end,
&cache, NULL);
if (!cache.uses_fp)
/* Found a function. */
sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL);
- /* Don't use line number debug info for assembly source files. */
+ /* Don't use line number debug info for assembly source files. */
if (sym && SYMBOL_LANGUAGE (sym) != language_asm)
{
sal = find_pc_line (func_addr, 0);
return sal.end;
}
}
- /* No useable line symbol. Use result of prologue parsing method. */
+ /* No useable line symbol. Use result of prologue parsing method. */
return plg_end;
}
- /* No function symbol -- just return the PC. */
+ /* No function symbol -- just return the PC. */
return (CORE_ADDR) pc;
}
/* The epilogue is defined here as the area at the end of a function,
either on the `ret' instruction itself or after an instruction which
- destroys the function's stack frame. */
+ destroys the function's stack frame. */
static int
xstormy16_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
ULONGEST inst, inst2;
CORE_ADDR addr = func_end - xstormy16_inst_size;
- /* The Xstormy16 epilogue is max. 14 bytes long. */
+ /* The Xstormy16 epilogue is max. 14 bytes long. */
if (pc < func_end - 7 * xstormy16_inst_size)
return 0;
/* Check if we're on a `ret' instruction. Otherwise it's
- too dangerous to proceed. */
+ too dangerous to proceed. */
inst = read_memory_unsigned_integer (addr,
xstormy16_inst_size, byte_order);
if (inst != 0x0003)
while ((addr -= xstormy16_inst_size) >= func_addr)
{
inst = read_memory_unsigned_integer (addr,
- xstormy16_inst_size, byte_order);
+ xstormy16_inst_size,
+ byte_order);
if (inst >= 0x009a && inst <= 0x009d) /* pop r10...r13 */
continue;
if (inst == 0x305f || inst == 0x307f) /* dec r15, #0x1/#0x3 */
break;
inst2 = read_memory_unsigned_integer (addr - xstormy16_inst_size,
- xstormy16_inst_size, byte_order);
- if (inst2 == 0x314f && inst >= 0x8000) /* add r15, neg. value */
+ xstormy16_inst_size,
+ byte_order);
+ if (inst2 == 0x314f && inst >= 0x8000) /* add r15, neg. value */
{
addr -= xstormy16_inst_size;
break;
}
/* Given a pointer to a jump table entry, return the address
- of the function it jumps to. Return 0 if not found. */
+ of the function it jumps to. Return 0 if not found. */
static CORE_ADDR
xstormy16_resolve_jmp_table_entry (struct gdbarch *gdbarch, CORE_ADDR faddr)
{
LONGEST inst, inst2, addr;
char buf[2 * xstormy16_inst_size];
- /* Return faddr if it's not pointing into the jump table. */
+ /* Return faddr if it's not pointing into the jump table. */
if (strcmp (faddr_sect->the_bfd_section->name, ".plt"))
return faddr;
/* Given a function's address, attempt to find (and return) the
address of the corresponding jump table entry. Return 0 if
- not found. */
+ not found. */
static CORE_ADDR
xstormy16_find_jmp_table_entry (struct gdbarch *gdbarch, CORE_ADDR faddr)
{
{
struct obj_section *osect;
- /* Return faddr if it's already a pointer to a jump table entry. */
+ /* Return faddr if it's already a pointer to a jump table entry. */
if (!strcmp (faddr_sect->the_bfd_section->name, ".plt"))
return faddr;
if (target_read_memory (addr, buf, sizeof buf))
return 0;
inst = extract_unsigned_integer (buf,
- xstormy16_inst_size, byte_order);
+ xstormy16_inst_size,
+ byte_order);
inst2 = extract_unsigned_integer (buf + xstormy16_inst_size,
- xstormy16_inst_size, byte_order);
+ xstormy16_inst_size,
+ byte_order);
faddr2 = inst2 << 8 | (inst & 0xff);
if (faddr == faddr2)
return addr;
/* Function: xstormy16_gdbarch_init
Initializer function for the xstormy16 gdbarch vector.
- Called by gdbarch. Sets up the gdbarch vector(s) for this target. */
+ Called by gdbarch. Sets up the gdbarch vector(s) for this target. */
static struct gdbarch *
xstormy16_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
struct gdbarch *gdbarch;
- /* find a candidate among the list of pre-declared architectures. */
+ /* find a candidate among the list of pre-declared architectures. */
arches = gdbarch_list_lookup_by_info (arches, &info);
if (arches != NULL)
return (arches->gdbarch);
set_gdbarch_address_to_pointer (gdbarch, xstormy16_address_to_pointer);
set_gdbarch_pointer_to_address (gdbarch, xstormy16_pointer_to_address);
- /* Stack grows up. */
+ /* Stack grows up. */
set_gdbarch_inner_than (gdbarch, core_addr_greaterthan);
/*
/* Function: _initialize_xstormy16_tdep
Initializer function for the Sanyo Xstormy16a module.
- Called by gdb at start-up. */
+ Called by gdb at start-up. */
-extern initialize_file_ftype _initialize_xstormy16_tdep; /* -Wmissing-prototypes */
+/* -Wmissing-prototypes */
+extern initialize_file_ftype _initialize_xstormy16_tdep;
void
_initialize_xstormy16_tdep (void)
#define PS_WOE (1<<18)
#define PS_EXC (1<<4)
-/* Convert a live A-register number to the corresponding AR-register number. */
+/* Convert a live A-register number to the corresponding AR-register
+ number. */
static int
arreg_number (struct gdbarch *gdbarch, int a_regnum, ULONGEST wb)
{
{
int wb; /* WINDOWBASE of the previous frame. */
int callsize; /* Call size of this frame. */
- int ws; /* WINDOWSTART of the previous frame. It keeps track of
- life windows only. If there is no bit set for the
- window, that means it had been already spilled
- because of window overflow. */
+ int ws; /* WINDOWSTART of the previous frame. It
+ keeps track of life windows only. If there
+ is no bit set for the window, that means it
+ had been already spilled because of window
+ overflow. */
/* Spilled A-registers from the previous frame.
AREGS[i] == -1, if corresponding AR is alive. */
/* Call0 ABI Definitions. */
-#define C0_MAXOPDS 3 /* Maximum number of operands for prologue analysis. */
+#define C0_MAXOPDS 3 /* Maximum number of operands for prologue
+ analysis. */
#define C0_NREGS 16 /* Number of A-registers to track. */
#define C0_CLESV 12 /* Callee-saved registers are here and up. */
#define C0_SP 1 /* Register used as SP. */
int fr_reg; /* original register from which register content
is derived, or C0_CONST, or C0_INEXP. */
int fr_ofs; /* constant offset from reg, or immediate value. */
- int to_stk; /* offset from original SP to register (4-byte aligned),
- or C0_NOSTK if register has not been saved. */
+ int to_stk; /* offset from original SP to register (4-byte
+ aligned), or C0_NOSTK if register has not
+ been saved. */
} xtensa_c0reg_t;
typedef struct xtensa_call0_frame_cache
{
int c0_frmsz; /* Stack frame size. */
- int c0_hasfp; /* Current frame uses frame pointer. */
+ int c0_hasfp; /* Current frame uses frame
+ pointer. */
int fp_regnum; /* A-register used as FP. */
int c0_fp; /* Actual value of frame pointer. */
xtensa_c0reg_t c0_rt[C0_NREGS]; /* Register tracking information. */
unsigned int register_operand;
/* Possible candidate for setting frame pointer
- from A1. This is what we are looking for. */
+ from A1. This is what we are looking for. */
if (xtensa_operand_get_field (isa, opc, 1, ifmt,
is, slot, ®ister_operand) != 0)
®ister_operand) != 0)
RETURN_FP;
- fp_regnum = gdbarch_tdep (gdbarch)->a0_base + register_operand;
+ fp_regnum
+ = gdbarch_tdep (gdbarch)->a0_base + register_operand;
RETURN_FP;
}
}
cache->base = SP (or best guess about FP) of this frame;
cache->pc = entry-PC (entry point of the frame function);
- cache->prev_sp = SP of the previous frame.
-*/
+ cache->prev_sp = SP of the previous frame. */
static void
call0_frame_cache (struct frame_info *this_frame,
}
if ((cache->prev_sp == 0) && ( ra != 0 ))
- /* If RA is equal to 0 this frame is an outermost frame. Leave
- cache->prev_sp unchanged marking the boundary of the frame stack. */
+ /* If RA is equal to 0 this frame is an outermost frame.
+ Leave cache->prev_sp unchanged marking the boundary of the
+ frame stack. */
{
if ((cache->wd.ws & (1 << cache->wd.wb)) == 0)
{
(gdbarch, gdbarch_tdep (gdbarch)->a0_base + 1,
cache->wd.wb);
- cache->prev_sp = get_frame_register_unsigned (this_frame, regnum);
+ cache->prev_sp = get_frame_register_unsigned (this_frame,
+ regnum);
}
}
}
spe = cache->c0.c0_fp
- cache->c0.c0_rt[cache->c0.fp_regnum].fr_ofs;
- return frame_unwind_got_memory (this_frame, regnum, spe + stkofs);
+ return frame_unwind_got_memory (this_frame, regnum,
+ spe + stkofs);
}
}
}
/* On Xtensa, we can return up to 4 words (or 2 for call12). */
if (len > (callsize > 8 ? 8 : 16))
internal_error (__FILE__, __LINE__,
- _("cannot extract return value of %d bytes long"), len);
+ _("cannot extract return value of %d bytes long"),
+ len);
/* Get the register offset of the return
register (A2) in the caller window. */
int align; /* alignment */
union
{
- int offset; /* stack offset if on stack */
- int regno; /* regno if in register */
+ int offset; /* stack offset if on stack. */
+ int regno; /* regno if in register. */
} u;
};
c0opc_mov, /* Moving a register to a register. */
c0opc_movi, /* Moving an immediate to a register. */
c0opc_l32r, /* Loading a literal. */
- c0opc_s32i, /* Storing word at fixed offset from a base register. */
+ c0opc_s32i, /* Storing word at fixed offset from a base
+ register. */
c0opc_NrOf /* Number of opcode classifications. */
} xtensa_insn_kind;
goto done;
opc = xtensa_opcode_decode (isa, ifmt, is, slot);
- DEBUGVERB ("[call0_analyze_prologue] instr addr = 0x%08x, opc = %d\n",
+ DEBUGVERB ("[call0_analyze_prologue] instr "
+ "addr = 0x%08x, opc = %d\n",
(unsigned)ia, opc);
if (opc == XTENSA_UNDEFINED)
opclass = c0opc_illegal;
static void
call0_frame_cache (struct frame_info *this_frame,
- xtensa_frame_cache_t *cache, CORE_ADDR pc, CORE_ADDR litbase)
+ xtensa_frame_cache_t *cache,
+ CORE_ADDR pc, CORE_ADDR litbase)
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
else if (cache->c0.c0_rt[C0_RA].fr_reg == C0_CONST
&& cache->c0.c0_rt[C0_RA].fr_ofs == 0)
{
- /* Special case for terminating backtrace at a function that wants to
- be seen as the outermost. Such a function will clear it's RA (A0)
- register to 0 in the prologue instead of saving its original value. */
+ /* Special case for terminating backtrace at a function that
+ wants to be seen as the outermost. Such a function will
+ clear it's RA (A0) register to 0 in the prologue instead of
+ saving its original value. */
ra = 0;
}
else
{
- /* RA was copied to another register or (before any function call) may
- still be in the original RA register. This is not always reliable:
- even in a leaf function, register tracking stops after prologue, and
- even in prologue, non-prologue instructions (not tracked) may overwrite
- RA or any register it was copied to. If likely in prologue or before
- any call, use retracking info and hope for the best (compiler should
- have saved RA in stack if not in a leaf function). If not in prologue,
- too bad. */
+ /* RA was copied to another register or (before any function
+ call) may still be in the original RA register. This is not
+ always reliable: even in a leaf function, register tracking
+ stops after prologue, and even in prologue, non-prologue
+ instructions (not tracked) may overwrite RA or any register
+ it was copied to. If likely in prologue or before any call,
+ use retracking info and hope for the best (compiler should
+ have saved RA in stack if not in a leaf function). If not in
+ prologue, too bad. */
int i;
for (i = 0;
set_gdbarch_register_name (gdbarch, xtensa_register_name);
set_gdbarch_register_type (gdbarch, xtensa_register_type);
- /* To call functions from GDB using dummy frame */
+ /* To call functions from GDB using dummy frame. */
set_gdbarch_push_dummy_call (gdbarch, xtensa_push_dummy_call);
set_gdbarch_believe_pcc_promotion (gdbarch, 1);
add_setshow_zinteger_cmd ("xtensa",
class_maintenance,
- &xtensa_debug_level, _("\
-Set Xtensa debugging."), _("\
-Show Xtensa debugging."), _("\
+ &xtensa_debug_level,
+ _("Set Xtensa debugging."),
+ _("Show Xtensa debugging."), _("\
When non-zero, Xtensa-specific debugging is enabled. \
Can be 1, 2, 3, or 4 indicating the level of debugging."),
NULL,
} xtensa_target_flags_t;
-/* Xtensa ELF core file register set representation ('.reg' section).
+/* Xtensa ELF core file register set representation ('.reg' section).
Copied from target-side ELF header <xtensa/elf.h>. */
typedef unsigned long xtensa_elf_greg_t;
/* For xtensa-config.c to expand to the structure above. */
#define XTREG(index,ofs,bsz,sz,al,tnum,flg,cp,ty,gr,name,fet,sto,mas,ct,x,y) \
- {#name, ofs, ty, ((gr)|((xtRegisterGroupNCP>>2)<<(cp+2))), \
+ {#name, ofs, ty, ((gr) | ((xtRegisterGroupNCP >> 2) << (cp + 2))), \
ct, bsz, sz, al, tnum, flg, cp, mas, fet, sto},
#define XTREG_END {0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0},