[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r13627 - in /libdfp/trunk: ChangeLog Makefile.gdb tests/gdb_start_address.py
- To: commits@xxxxxxxxxx
- Subject: [commits] r13627 - in /libdfp/trunk: ChangeLog Makefile.gdb tests/gdb_start_address.py
- From: ryanarn@xxxxxxxxxx
- Date: Thu, 28 Apr 2011 20:24:08 -0000
Author: ryanarn
Date: Thu Apr 28 13:24:07 2011
New Revision: 13627
Log:
2011-04-28 Ryan S. Arnold <rsa@xxxxxxxxxx>
* tests/gdb_start_address.py: New file which provides the
start_address() python convenience function to GDB.
* Makefile.gdb (*.gdb): Break on _dl_start_user for powerpc64 and
_dl_main_dispatch on powerpc32. Call new python convenience function
start_address() to get the start address of libc and libdfp for the
scripts.
Added:
libdfp/trunk/tests/gdb_start_address.py
Modified:
libdfp/trunk/ChangeLog
libdfp/trunk/Makefile.gdb
Modified: libdfp/trunk/ChangeLog
==============================================================================
--- libdfp/trunk/ChangeLog (original)
+++ libdfp/trunk/ChangeLog Thu Apr 28 13:24:07 2011
@@ -1,3 +1,12 @@
+2011-04-28 Ryan S. Arnold <rsa@xxxxxxxxxx>
+
+ * tests/gdb_start_address.py: New file which provides the
+ start_address() python convenience function to GDB.
+ * Makefile.gdb (*.gdb): Break on _dl_start_user for powerpc64 and
+ _dl_main_dispatch on powerpc32. Call new python convenience function
+ start_address() to get the start address of libc and libdfp for the
+ scripts.
+
2011-03-30 Ryan S. Arnold <rsa@xxxxxxxxxx>
* sysdeps/powerpc/powerpc32/power6/fpu/Makefile (ASFLAGS): Remove
Modified: libdfp/trunk/Makefile.gdb
==============================================================================
--- libdfp/trunk/Makefile.gdb (original)
+++ libdfp/trunk/Makefile.gdb Thu Apr 28 13:24:07 2011
@@ -29,10 +29,16 @@
#$(addsuffix .gdb,$(libdfp_tests)): $(top_builddir)/$(patsubst %.gdb,%,$@)
$(addsuffix .gdb,$(libdfp_tests)): $(libdfp_tests)
@echo "Generating GDB script $@"
- @echo 'set environment C -E -x c-header' > $@
+ @echo 'source $(top_srcdir)/tests/gdb_start_address.py' > $@
+ @echo 'set environment C -E -x c-header' >> $@
@echo 'set environment LD_LIBRARY_PATH=$(top_builddir)/:$$LD_LIBRARY_PATH' >> $@
ifneq ($(glibc_builddir),)
+ifeq ($(machine),powerpc/powerpc64)
+# powerpc64 doesn't have _dl_main_dispatch exported.
+ @echo 'break _dl_start_user' >> $@
+else
@echo 'break _dl_main_dispatch' >> $@
+endif
@echo 'run --library-path $(LIBRARY_PATH):$(glibc_builddir)/nptl_db:$(top_builddir)/ $(top_builddir)/$(patsubst %.gdb,%,$@)' >> $@
else
@echo 'break main' >> $@
@@ -42,26 +48,28 @@
@echo -n 'add-symbol-file $(top_builddir)/$(patsubst %.gdb,%,$@) 0x' >> $@
@echo `$(dir $(firstword $(CC)))objdump -s --section=".text" $(top_builddir)/$(patsubst %.gdb,%,$@) | grep Contents -A 1 | tail -n 1 | awk -F' ' '{printf $$1}'` >> $@
@echo '' >> $@
- @echo 'set $$libc = 0x' >> $@
- @echo -n 'set $$start = 0x' >> $@
+ @echo 'p/x $$start_address("libc")' >> $@
+ @echo 'set $$libc_start = $$' >> $@
+ @echo -n 'set $$libc_text = 0x' >> $@
ifneq ($(glibc_builddir),)
@echo `$(dir $(firstword $(CC)))objdump -s --section=".text" $(glibc_builddir)/libc.so | grep Contents -A 1 | tail -n 1 | awk -F' ' '{printf $$1}'` >> $@
else
@$(dir $(firstword $(CC)))objdump -s --section=".text" `LD_LIBRARY_PATH=./:$$LD_LIBRARY_PATH ldd $(patsubst %.gdb,%,$@) | grep libc.so | awk -F' ' '{print $$3}'` | grep Contents -A 1 | tail -n 1 | awk -F' ' '{printf $$1}' >> $@
@echo >> $@
endif
- @echo 'set $$addr = $$libc + $$start' >> $@
+ @echo 'set $$libc_addr = $$libc_start + $$libc_text' >> $@
@echo -n 'add-symbol-file ' >> $@
ifneq ($(glibc_builddir),)
@echo -n '$(glibc_builddir)/libc.so' >> $@
else
@echo -n `LD_LIBRARY_PATH=./:$$LD_LIBRARY_PATH ldd $(patsubst %.gdb,%,$@) | grep libc.so | awk -F' ' '{print $$3}'` >> $@
endif
- @echo ' $$addr' >> $@
+ @echo ' $$libc_addr' >> $@
@echo '' >> $@
- @echo 'set $$libdfp = 0x' >> $@
- @echo -n 'set $$start = 0x' >> $@
+ @echo 'p/x $$start_address("libdfp")' >> $@
+ @echo 'set $$libdfp_start = $$' >> $@
+ @echo -n 'set $$libdfp_text = 0x' >> $@
@echo `$(dir $(firstword $(CC)))objdump -s --section=".text" $(top_builddir)/libdfp.so.1 | grep Contents -A 1 | tail -n 1 | awk -F' ' '{printf $$1}'` >> $@
- @echo 'set $$addr = $$libdfp + $$start' >> $@
- @echo 'add-symbol-file $(top_builddir)/libdfp.so.1 $$addr' >> $@
+ @echo 'set $$libdfp_addr = $$libdfp_start + $$libdfp_text' >> $@
+ @echo 'add-symbol-file $(top_builddir)/libdfp.so.1 $$libdfp_addr' >> $@
@echo
Added: libdfp/trunk/tests/gdb_start_address.py
==============================================================================
--- libdfp/trunk/tests/gdb_start_address.py (added)
+++ libdfp/trunk/tests/gdb_start_address.py Thu Apr 28 13:24:07 2011
@@ -1,0 +1,33 @@
+# gdb_start_address.py created by Ryan S. Arnold, April 2011. No
+# attribution required or necessary to use/reuse/copy/modify this
+# function/script.
+
+import re
+class StartAddress(gdb.Function):
+ """Returns the start address of a library or executable from info
+ proc mappings."""
+
+ def __init__(self):
+ super (StartAddress, self).__init__ ("start_address")
+
+ def invoke(self, library):
+ mappings = gdb.execute("info proc mappings", to_string=True)
+ lines = mappings.split('\n')
+ to_mappings = ""
+ for line in lines:
+ if (to_mappings != "true"):
+ if (re.search("Start Addr", line)):
+ to_mappings = "true"
+ continue
+ else:
+
+ # The first match is the .text segment. Make sure to
+ # match on "/libdfp-1.0.7.so" when passed "libdfp" and
+ # not on "/libdfp" in the following example:
+ # /home/ryanarn/libdfp/build64_power6/libdfp-1.0.7.so
+ if (re.search("/" + library.string() + "[^/]*$", line)):
+ chunks = line.split()
+ return int(str(chunks[0]),16)
+ return 0x0
+
+StartAddress ()