[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <464529fe760334f693f88e25084b54a92f2be9fc.1359463075.git.jan.kiszka@siemens.com>
Date: Tue, 29 Jan 2013 13:37:45 +0100
From: Jan Kiszka <jan.kiszka@...mens.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org
Cc: Jason Wessel <jason.wessel@...driver.com>,
kgdb-bugreport@...ts.sourceforge.net,
Andi Kleen <andi@...stfloor.org>,
Tom Tromey <tromey@...hat.com>,
Ben Widawsky <ben@...dawsk.net>, Borislav Petkov <bp@...en8.de>
Subject: [PATCH v5 02/20] scripts/gdb: Add cache for type objects
Type lookups are very slow in gdb-python which is often noticeable when
iterating over a number of objects. Introduce the helper class
CachedType that keeps a reference to a gdb.Type object but also
refreshes it after an object file has been loaded.
Signed-off-by: Jan Kiszka <jan.kiszka@...mens.com>
---
scripts/gdb/utils.py | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/scripts/gdb/utils.py b/scripts/gdb/utils.py
index f75eae6..fdff85e 100644
--- a/scripts/gdb/utils.py
+++ b/scripts/gdb/utils.py
@@ -15,3 +15,24 @@ import gdb
import re
gdb_version = re.sub("^[^0-9]*", "", gdb.VERSION)
+
+
+class CachedType:
+ _type = None
+
+ def _new_objfile_handler(self, event):
+ self._type = None
+ gdb.events.new_objfile.disconnect(self._new_objfile_handler)
+
+ def __init__(self, name):
+ self._name = name
+
+ def get_type(self):
+ if self._type == None:
+ self._type = gdb.lookup_type(self._name)
+ if self._type == None:
+ raise gdb.GdbError("cannot resolve " \
+ "type '%s'" % self._name)
+ gdb.events.new_objfile.connect(
+ self._new_objfile_handler)
+ return self._type
--
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists