]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
The hint given by Valgrind gdbserver when enabling host visibility
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 28 Mar 2015 12:23:07 +0000 (12:23 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 28 Mar 2015 12:23:07 +0000 (12:23 +0000)
in gdbserver was wrongly giving the file load address,
instead of the text segment address start.
This means that GDB was then showing wrong symbols for an address
(typically, symbols slightly before the address being printed).

This patch ensures the hint given is using the text start address.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15045

coregrind/m_gdbserver/server.c

index ecf3b42728aae240614ec216f9fac2483732f37d..9b30e678a51abfe877991e6976a5afab4403e72b 100644 (file)
@@ -331,7 +331,12 @@ int handle_gdb_valgrind_command (char *mon, OutputSink *sink_wanted_at_return)
          if (hostvisibility) {
             const DebugInfo *tooldi 
                = VG_(find_DebugInfo) ((Addr)handle_gdb_valgrind_command);
-            const NSegment *toolseg 
+            /* Normally, we should always find the tooldi. In case we
+               do not, suggest a 'likely somewhat working' address: */
+            const Addr tool_text_start
+               = tooldi ?
+               VG_(DebugInfo_get_text_avma) (tooldi) : 0x38000000;
+            const NSegment *toolseg
                = tooldi ?
                  VG_(am_find_nsegment) (VG_(DebugInfo_get_text_avma) (tooldi))
                  : NULL;
@@ -342,7 +347,7 @@ int handle_gdb_valgrind_command (char *mon, OutputSink *sink_wanted_at_return)
                 "add-symbol-file %s %p\n", 
                 toolseg ? VG_(am_get_filename)(toolseg)
                 : "<toolfile> <address> e.g.",
-                toolseg ? (void*)toolseg->start : (void*)0x38000000);
+                (void*)tool_text_start);
          } else
             VG_(gdb_printf)
                ("Disabled access to Valgrind memory/status by GDB\n");