Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Do not add partial_symbol again and again to the list
@ 2008-02-11 20:23 Aleksandar Ristovski
  2008-02-11 20:38 ` Daniel Jacobowitz
  0 siblings, 1 reply; 29+ messages in thread
From: Aleksandar Ristovski @ 2008-02-11 20:23 UTC (permalink / raw)
  To: gdb-patches

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

Hello,

The attached patch checks if partial_symbol has already been added to the list 
instead of adding duplicate records.

Tested on linux x86, no regression.

Thanks,

---
Aleksandar Ristovski
QNX Software Systems


ChangeLog:
2008-02-11  Aleksandar Ristovski  <aristovski@qnx.com>

	* symfile.c (add_psymbol_to_list): Do not alloca and copy name
	if it's already properly terminated. Check if the partial_symbol
	structure has already been added to the list. If it has, do not
	add it again.

[-- Attachment #2: symfile.c.diff --]
[-- Type: text/plain, Size: 1665 bytes --]

Index: gdb/symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.198
diff -u -p -r1.198 symfile.c
--- gdb/symfile.c	29 Jan 2008 22:47:20 -0000	1.198
+++ gdb/symfile.c	11 Feb 2008 20:12:48 -0000
@@ -3102,15 +3103,20 @@ add_psymbol_to_list (char *name, int nam
 		     enum language language, struct objfile *objfile)
 {
   struct partial_symbol *psym;
-  char *buf = alloca (namelength + 1);
+  struct partial_symbol **ps;
+  char *buf = name;  
   /* psymbol is static so that there will be no uninitialized gaps in the
      structure which might contain random data, causing cache misses in
      bcache. */
   static struct partial_symbol psymbol;
-
-  /* Create local copy of the partial symbol */
-  memcpy (buf, name, namelength);
-  buf[namelength] = '\0';
+  
+  if (name[namelength] != '\0')
+    {
+      buf = alloca (namelength + 1);
+      /* Create local copy of the partial symbol */
+      memcpy (buf, name, namelength);
+      buf[namelength] = '\0';
+    }
   /* val and coreaddr are mutually exclusive, one of them *will* be zero */
   if (val != 0)
     {
@@ -3131,6 +3137,14 @@ add_psymbol_to_list (char *name, int nam
   psym = deprecated_bcache (&psymbol, sizeof (struct partial_symbol),
 			    objfile->psymbol_cache);
 
+  /* Check if the partial_symbol is already in the list. Do not add
+     it again if it is.  */
+  for (ps = list->list; ps != list->next; ps++)
+    {
+      if (psym == *ps)
+	return psym;
+    }
+
   /* Save pointer to partial symbol in psymtab, growing symtab if needed. */
   if (list->next >= list->list + list->size)
     {

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

end of thread, other threads:[~2008-06-05 19:26 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-11 20:23 [patch] Do not add partial_symbol again and again to the list Aleksandar Ristovski
2008-02-11 20:38 ` Daniel Jacobowitz
2008-02-11 20:52   ` Aleksandar Ristovski
2008-02-11 21:09     ` Daniel Jacobowitz
2008-02-11 21:41       ` Aleksandar Ristovski
2008-02-11 21:48         ` Daniel Jacobowitz
2008-02-11 22:10           ` Aleksandar Ristovski
2008-02-11 22:31             ` Daniel Jacobowitz
2008-02-11 22:43               ` Aleksandar Ristovski
2008-02-11 22:53                 ` Daniel Jacobowitz
2008-02-12  1:08                   ` Aleksandar Ristovski
2008-02-12  2:12                     ` Daniel Jacobowitz
2008-02-12  5:35                       ` Aleksandar Ristovski
2008-02-12 13:26                         ` Daniel Jacobowitz
2008-02-12 15:54                           ` Aleksandar Ristovski
2008-02-13  5:23                   ` Aleksandar Ristovski
2008-02-14  1:31                     ` Aleksandar Ristovski
2008-05-02 18:11                       ` Aleksandar Ristovski
2008-05-03 21:32                     ` Daniel Jacobowitz
2008-05-05 19:41                       ` Aleksandar Ristovski
2008-05-05 19:38                         ` Aleksandar Ristovski
2008-05-06 15:47                         ` Daniel Jacobowitz
2008-05-06 18:45                           ` Aleksandar Ristovski
2008-05-06 18:39                             ` Aleksandar Ristovski
2008-05-06 18:50                             ` Daniel Jacobowitz
2008-05-07  8:22                               ` Aleksandar Ristovski
2008-05-07  9:01                                 ` Aleksandar Ristovski
2008-06-05 18:17                                 ` Daniel Jacobowitz
2008-06-05 19:26                                   ` Aleksandar Ristovski

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