[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH 1/3] build: prepare script for gdb autoloading



Gdb can automatically load helper scripts. It looks for a file named
objfile-gdb.py, where objfile is the object file's real name.

Copy the uk-gdb.py into the build directry with a little modifictaion
- hardcode the absolute path to the unikraft's scripts directory.

This way gdb helper can easily import modules.

Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>
---
 Makefile                 | 12 +++++++++++-
 support/scripts/trace.py |  3 ++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index f0d1ad47..a22be4bc 100644
--- a/Makefile
+++ b/Makefile
@@ -532,8 +532,18 @@ libs: $(UK_ALIBS) $(UK_ALIBS-y) $(UK_OLIBS) $(UK_OLIBS-y)
 
 images: $(UK_IMAGES) $(UK_IMAGES-y)
 
-all: images
+GDB_HELPER_LINKS := $(addsuffix  .dbg-gdb.py,$(UK_IMAGES-y) $(UK_IMAGES))
+$(GDB_HELPER_LINKS):
+       $(call verbose_cmd,LN,$(notdir $@), ln -sf uk-gdb.py $@)
 
+SCRIPTS_DIR_BACKSLASHED = $(subst /,\/,$(SCRIPTS_DIR))
+$(BUILD_DIR)/uk-gdb.py: $(SCRIPTS_DIR)/uk-gdb.py
+       $(call verbose_cmd,GEN,$(notdir $@), \
+       sed '/scripts_dir = / 
s/os.path.dirname(os.path.realpath(__file__))/"$(SCRIPTS_DIR_BACKSLASHED)"/g' 
$^ > $@)
+
+gdb_helpers: $(GDB_HELPER_LINKS) $(BUILD_DIR)/uk-gdb.py
+
+all: images gdb_helpers
 
################################################################################
 # Cleanup rules
 
################################################################################
diff --git a/support/scripts/trace.py b/support/scripts/trace.py
index 5632d39f..636cd2dd 100755
--- a/support/scripts/trace.py
+++ b/support/scripts/trace.py
@@ -98,10 +98,11 @@ def fetch(uk_img, out, remote, do_list, verbose):
     if os.path.exists(out):
         os.remove(out)
 
+    helper_path = os.path.abspath(uk_img) + '-gdb.py'
     gdb_cmd = ['gdb', '-nh', '-batch',
                click.format_filename(uk_img),
+               '-iex', 'add-auto-load-safe-path ' + helper_path,
                '-ex', 'target remote ' + remote,
-               '-ex', 'source %s/uk-gdb.py' % scripts_dir,
                '-ex', 'uk trace save ' + out
     ]
 
-- 
2.19.2


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.