Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH]
@ 2012-01-18  4:35 Sergio Durigan Junior
  2012-01-18  4:52 ` [PATCH] Add initialize and reallocate methods to parser expout Sergio Durigan Junior
  2012-01-18  5:04 ` [PATCH] Joel Brobecker
  0 siblings, 2 replies; 14+ messages in thread
From: Sergio Durigan Junior @ 2012-01-18  4:35 UTC (permalink / raw)
  To: gdb-patches

Hi,

I believe this is a rather obvious patch, but I decided to ask anyway.
This is a pretty simple cleanup on parse.c: the creation of
`initialize_expout' and `reallocate_expout' to handle cases when one
needs to do those actions on expout.

This patch is going to be important for the coming SystemTap patches
that I plan to submit this week, and I know GDB has a rule to avoid
premature modification of the code before a patch is posted, but I
believe this is a good cleanup to have in any case.

This patch also relates to the parser cleanup that I am working on.

Ok to apply?

-- 
Sergio

2012-01-18  Sergio Durigan Junior  <sergiodj@redhat.com>

	* parse.c (initialize_expout): New function.
	(reallocate_expout): Likewise.
	(parse_exp_in_context): Use `initialize_expout' and
	`reallocate_expout' when appropriate.

diff --git a/gdb/parse.c b/gdb/parse.c
index f405dc5..b11070c 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -182,6 +182,41 @@ free_funcalls (void *ignore)
 /* This page contains the functions for adding data to the struct expression
    being constructed.  */
 
+/* Helper function used to initialize an struct expression that is going
+   to be used to store expression elements.  The arguments are the
+   parser_state PS containing the EXPOUT, the INITIAL_SIZE of the expression,
+   the language LANG parsed to build this expression, and the GDBARCH
+   pointer.  */
+
+static void
+initialize_expout (int initial_size, const struct language_defn *lang,
+		   struct gdbarch *gdbarch)
+{
+  expout_size = initial_size;
+  expout_ptr = 0;
+  expout = xmalloc (sizeof (struct expression)
+		    + EXP_ELEM_TO_BYTES (expout_size));
+  expout->language_defn = lang;
+  expout->gdbarch = gdbarch;
+}
+
+/* Helper function that reallocates the EXPOUT inside PS in order to
+   eliminate any unused space.  It is generally used when the expression
+   has just been parsed and created.  */
+
+static void
+reallocate_expout (void)
+{
+  /* Record the actual number of expression elements, and then
+     reallocate the expression memory so that we free up any
+     excess elements.  */
+
+  expout->nelts = expout_ptr;
+  expout = xrealloc ((char *) expout,
+		     sizeof (struct expression)
+		     + EXP_ELEM_TO_BYTES (expout_ptr));
+}
+
 /* Add one element to the end of the expression.  */
 
 /* To avoid a bug in the Sun 4 compiler, we pass things that can fit into
@@ -1156,12 +1191,7 @@ parse_exp_in_context (char **stringptr, struct block *block, int comma,
   else
     lang = current_language;
 
-  expout_size = 10;
-  expout_ptr = 0;
-  expout = (struct expression *)
-    xmalloc (sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_size));
-  expout->language_defn = lang;
-  expout->gdbarch = get_current_arch ();
+  initialize_expout (10, lang, get_current_arch ());
 
   TRY_CATCH (except, RETURN_MASK_ALL)
     {
@@ -1179,14 +1209,7 @@ parse_exp_in_context (char **stringptr, struct block *block, int comma,
 
   discard_cleanups (old_chain);
 
-  /* Record the actual number of expression elements, and then
-     reallocate the expression memory so that we free up any
-     excess elements.  */
-
-  expout->nelts = expout_ptr;
-  expout = (struct expression *)
-    xrealloc ((char *) expout,
-	      sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_ptr));
+  reallocate_expout ();
 
   /* Convert expression from postfix form as generated by yacc
      parser, to a prefix form.  */


^ permalink raw reply	[flat|nested] 14+ messages in thread
* [patch]
@ 2013-01-23 19:10 Doug Evans
  0 siblings, 0 replies; 14+ messages in thread
From: Doug Evans @ 2013-01-23 19:10 UTC (permalink / raw)
  To: gdb-patches

Hi.

linespec.c:find_linespec_symbols first tries to find "foo::bar" as
method bar in class foo (via lookup_prefix_sym).
If that fails it then tries to find bar in namespace foo.

      /* If successful, we're done.  If NOT_FOUND_ERROR
	 was not thrown, rethrow the exception that we did get.
	 Otherwise, fall back to looking up the entire name as a symbol.
	 This can happen with namespace::function.  */

Given that, there's no need for collect_one_symbol (only used by
lookup_prefix_sym) to collect namespaces.

Regression tested on amd64-linux.
I will commit this patch in a few days if there are no objections.

2013-01-23  Doug Evans  <dje@google.com>

	* linespec.c (collect_one_symbol): Clarify comment.
	Don't collect TYPE_CODE_NAMESPACE symbols.

Index: linespec.c
===================================================================
RCS file: /cvs/src/src/gdb/linespec.c,v
retrieving revision 1.174
diff -u -p -r1.174 linespec.c
--- linespec.c	1 Jan 2013 06:32:46 -0000	1.174
+++ linespec.c	23 Jan 2013 18:36:23 -0000
@@ -2539,7 +2539,7 @@ struct decode_compound_collector
 };
 
 /* A callback for iterate_over_symbols that is used by
-   lookup_prefix_sym to collect type symbols.  */
+   lookup_prefix_sym to collect class symbols.  */
 
 static int
 collect_one_symbol (struct symbol *sym, void *d)
@@ -2554,8 +2554,7 @@ collect_one_symbol (struct symbol *sym, 
   t = SYMBOL_TYPE (sym);
   CHECK_TYPEDEF (t);
   if (TYPE_CODE (t) != TYPE_CODE_STRUCT
-      && TYPE_CODE (t) != TYPE_CODE_UNION
-      && TYPE_CODE (t) != TYPE_CODE_NAMESPACE)
+      && TYPE_CODE (t) != TYPE_CODE_UNION)
     return 1; /* Continue iterating.  */
 
   slot = htab_find_slot (collector->unique_syms, sym, INSERT);


^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH]
@ 2009-05-06  0:35 Maxim Grigoriev
  0 siblings, 0 replies; 14+ messages in thread
From: Maxim Grigoriev @ 2009-05-06  0:35 UTC (permalink / raw)
  To: gdb-patches

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

This patch fixes Xtensa backtrace which is broken
when frame_func_unwind () returns bad value.

-- Maxim


[-- Attachment #2: xtensa-cisco-fix.diff --]
[-- Type: text/x-patch, Size: 726 bytes --]

2009-05-05  Maxim Grigoriev  <maxim2405@gmail.com>

	* xtensa-tdep.c (xtensa_frame_cache): Use pc instead of cache->pc.

Index: gdb/xtensa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/xtensa-tdep.c,v
retrieving revision 1.33
diff -u -r1.33 xtensa-tdep.c
--- gdb/xtensa-tdep.c	17 Apr 2009 15:44:28 -0000	1.33
+++ gdb/xtensa-tdep.c	6 May 2009 00:28:01 -0000
@@ -1242,7 +1242,7 @@
 	  cache->wd.ws = ws & ~(1 << wb);
 
 	  cache->pc = get_frame_func (this_frame);
-	  cache->ra = (cache->pc & 0xc0000000) | (ra & 0x3fffffff);
+	  cache->ra = (pc & 0xc0000000) | (ra & 0x3fffffff);
 	  cache->ps = (ps & ~PS_CALLINC_MASK)
 	    | ((WINSIZE(ra)/4) << PS_CALLINC_SHIFT);
 	}

^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH]
@ 2004-04-18 13:09 Mark Kettenis
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Kettenis @ 2004-04-18 13:09 UTC (permalink / raw)
  To: gdb-patches

While working on OpenBSD/m68k support, I couldn't resist tweaking some
comments such that things are a bit more consistent regarding to
coding style and such.  I also tweaked the comment about register
numbers.  For m68k these are all "real" so the comment about
pseudo-registers is just confusing.

Committed,

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* m68k-tdep.h: Tweak comments.
	* m68k-tdep.c: Tweak comment.

Index: m68k-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/m68k-tdep.c,v
retrieving revision 1.81
diff -u -p -r1.81 m68k-tdep.c
--- m68k-tdep.c 23 Mar 2004 14:47:56 -0000 1.81
+++ m68k-tdep.c 18 Apr 2004 13:00:24 -0000
@@ -1,4 +1,4 @@
-/* Target dependent code for the Motorola 68000 series.
+/* Target-dependent code for the Motorola 68000 series.
 
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000,
    2001, 2002, 2003, 2004 Free Software Foundation, Inc.
Index: m68k-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/m68k-tdep.h,v
retrieving revision 1.4
diff -u -p -r1.4 m68k-tdep.h
--- m68k-tdep.h 9 Jul 2003 21:36:08 -0000 1.4
+++ m68k-tdep.h 18 Apr 2004 13:00:24 -0000
@@ -1,6 +1,7 @@
-/* Common target dependent code for the Motorola 68000 series.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001, 2003
-   Free Software Foundation, Inc.
+/* Target-dependent code for the Motorola 68000 series.
+
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000,
+   2001, 2003, 2004 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -24,30 +25,26 @@
 
 struct frame_info;
 
-/* Register numbers of various important registers.
-   Note that some of these values are "real" register numbers,
-   and correspond to the general registers of the machine,
-   and some are "phony" register numbers which are too large
-   to be actual register numbers as far as the user is concerned
-   but do serve to get the desired values when passed to read_register.  */
+/* Register numbers of various important registers.  */
 
-enum
+enum m68k_regnum
 {
   M68K_D0_REGNUM = 0,
   M68K_D1_REGNUM = 1,
   M68K_A0_REGNUM = 8,
   M68K_A1_REGNUM = 9,
-  M68K_FP_REGNUM = 14,		/* Contains address of executing stack frame */
-  M68K_SP_REGNUM = 15,		/* Contains address of top of stack */
-  M68K_PS_REGNUM = 16,		/* Contains processor status */
-  M68K_PC_REGNUM = 17,		/* Contains program counter */
-  M68K_FP0_REGNUM = 18,		/* Floating point register 0 */
-  M68K_FPC_REGNUM = 26,		/* 68881 control register */
-  M68K_FPS_REGNUM = 27,		/* 68881 status register */
+  M68K_FP_REGNUM = 14,		/* Address of executing stack frame.  */
+  M68K_SP_REGNUM = 15,		/* Address of top of stack.  */
+  M68K_PS_REGNUM = 16,		/* Processor status.  */
+  M68K_PC_REGNUM = 17,		/* Program counter.  */
+  M68K_FP0_REGNUM = 18,		/* Floating point register 0.  */
+  M68K_FPC_REGNUM = 26,		/* 68881 control register.  */
+  M68K_FPS_REGNUM = 27,		/* 68881 status register.  */
   M68K_FPI_REGNUM = 28
 };
 
-#define M68K_NUM_REGS (M68K_FPI_REGNUM + 1)
+/* Number of machine registers.  */
+#define M68K_NUM_REGS	(M68K_FPI_REGNUM + 1)
 
 /* Size of the largest register.  */
 #define M68K_MAX_REGISTER_SIZE	12
@@ -70,6 +67,7 @@ enum struct_return
 };
 
 /* Target-dependent structure in gdbarch.  */
+
 struct gdbarch_tdep
 {
   /* Offset to PC value in the jump buffer.  If this is negative,
@@ -85,4 +83,4 @@ struct gdbarch_tdep
   enum struct_return struct_return;
 };
 
-#endif /* M68K_TDEP_H */
+#endif /* m68k-tdep.h */


^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH]
@ 2004-04-09 16:31 Mark Kettenis
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Kettenis @ 2004-04-09 16:31 UTC (permalink / raw)
  To: gdb-patches

Committed,

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>
 
	* i386-linux-nat.c: Update copyrigth year.  Tweak comment.

Index: i386-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-linux-nat.c,v
retrieving revision 1.54
diff -u -p -r1.54 i386-linux-nat.c
--- i386-linux-nat.c 26 Dec 2003 15:42:58 -0000 1.54
+++ i386-linux-nat.c 9 Apr 2004 16:29:47 -0000
@@ -1,6 +1,6 @@
-/* Native-dependent code for GNU/Linux x86.
+/* Native-dependent code for GNU/Linux i386.
 
-   Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
    This file is part of GDB.
 


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: [PATCH]
@ 2003-10-30 20:21 Mark Kettenis
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Kettenis @ 2003-10-30 20:21 UTC (permalink / raw)
  To: gdb-patches

Ouch,

Sorry about that.  Sent it off before I came up with a good subject
line.

Mark


^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH]
@ 2003-10-30 19:36 Mark Kettenis
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Kettenis @ 2003-10-30 19:36 UTC (permalink / raw)
  To: gdb-patches

This marks core files produced by "gcore" as "FreeBSD".  Otherwise
FreeBSD/amd64 won't recognize them as such.

FreeBSD/i386 already does this in most cases because of
bfd/elf32-i386.c:elf_i386_post_process_headers, and FreeBSD/amd64
should probably do something similar, but setting it here shouldn't
hurt.

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* fbsd-proc.c (fbsd_make_corefile_notes): Put a "FreeBSD" label in
	the ELF header.

Index: fbsd-proc.c
===================================================================
RCS file: /cvs/src/src/gdb/fbsd-proc.c,v
retrieving revision 1.4
diff -u -p -r1.4 fbsd-proc.c
--- fbsd-proc.c 29 Oct 2003 22:47:37 -0000 1.4
+++ fbsd-proc.c 30 Oct 2003 19:26:27 -0000
@@ -127,6 +127,11 @@ fbsd_make_corefile_notes (bfd *obfd, int
   gregset_t gregs;
   fpregset_t fpregs;
   char *note_data = NULL;
+  Elf_Internal_Ehdr *i_ehdrp;
+
+  /* Put a "FreeBSD" label in the ELF header.  */
+  i_ehdrp = elf_elfheader (obfd);
+  i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
 
   fill_gregset (&gregs, -1);
   note_data = elfcore_write_prstatus (obfd, note_data, note_size,


^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH]
@ 2003-03-01 13:09 Mark Kettenis
  2003-03-03 17:33 ` [PATCH] David Carlton
  0 siblings, 1 reply; 14+ messages in thread
From: Mark Kettenis @ 2003-03-01 13:09 UTC (permalink / raw)
  To: gdb-patches

Since this function is used for low-level things, SYMBOL_LINKAGE_NAME is appropriate here.

Checked in.

Mark

Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* i386-linux-tdep.c (find_minsym_and_objfile): Replace usage of
	DEPRECATED_SYMBOL_NAME with SYMBOL_LINKAGE_NAME.

2003-03-01  Mark Kettenis  <kettenis@gnu.org>

Index: i386-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-linux-tdep.c,v
retrieving revision 1.24
diff -u -p -r1.24 i386-linux-tdep.c
--- i386-linux-tdep.c 1 Mar 2003 12:36:36 -0000 1.24
+++ i386-linux-tdep.c 1 Mar 2003 12:55:43 -0000
@@ -332,8 +332,8 @@ find_minsym_and_objfile (char *name, str
 
       ALL_OBJFILE_MSYMBOLS (objfile, msym)
 	{
-	  if (DEPRECATED_SYMBOL_NAME (msym)
-	      && strcmp (DEPRECATED_SYMBOL_NAME (msym), name) == 0)
+	  if (SYMBOL_LINKAGE_NAME (msym)
+	      && strcmp (SYMBOL_LINKAGE_NAME (msym), name) == 0)
 	    {
 	      *objfile_p = objfile;
 	      return msym;


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-01-23 19:10 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-18  4:35 [PATCH] Sergio Durigan Junior
2012-01-18  4:52 ` [PATCH] Add initialize and reallocate methods to parser expout Sergio Durigan Junior
2012-01-18  5:04 ` [PATCH] Joel Brobecker
2012-01-18  5:17   ` [PATCH] Sergio Durigan Junior
2012-01-18 12:48     ` [PATCH] Joel Brobecker
2012-01-18 14:34       ` [PATCH] Sergio Durigan Junior
  -- strict thread matches above, loose matches on Subject: below --
2013-01-23 19:10 [patch] Doug Evans
2009-05-06  0:35 [PATCH] Maxim Grigoriev
2004-04-18 13:09 [PATCH] Mark Kettenis
2004-04-09 16:31 [PATCH] Mark Kettenis
2003-10-30 20:21 [PATCH] Mark Kettenis
2003-10-30 19:36 [PATCH] Mark Kettenis
2003-03-01 13:09 [PATCH] Mark Kettenis
2003-03-03 17:33 ` [PATCH] David Carlton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox