>From b281d5456964a05331a70b34b1764d10bec63d3d Mon Sep 17 00:00:00 2001
From: qiaonuohan <qiaonuohan@cn.fujitsu.com>
Date: Mon, 16 Apr 2012 16:05:11 +0800
Subject: [PATCH 1/2] add printm command for gdb

---
 gdb-7.3.1.patch |   71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/gdb-7.3.1.patch b/gdb-7.3.1.patch
index 4e1c08b..0252260 100644
--- a/gdb-7.3.1.patch
+++ b/gdb-7.3.1.patch
@@ -1357,3 +1357,74 @@
  	      if (!field_is_static (&TYPE_FIELD (type, i))
  		  && TYPE_FIELD_PACKED (type, i))
  		{
+--- gdb-7.3.1/gdb/printcmd.c.orig
++++ gdb-7.3.1/gdb/printcmd.c
+@@ -941,7 +941,7 @@ validate_format (struct format_data fmt, char *cmdname)
+    first argument ("/x myvar" for example, to print myvar in hex).  */
+ 
+ static void
+-print_command_1 (char *exp, int inspect, int voidprint)
++print_command_1 (char *exp, int inspect, int voidprint, int memberprint)
+ {
+   struct expression *expr;
+   struct cleanup *old_chain = 0;
+@@ -975,7 +975,15 @@ print_command_1 (char *exp, int inspect, int voidprint)
+   else
+     val = access_value_history (0);
+ 
+-  if (voidprint || (val && value_type (val) &&
++  if (memberprint)
++    {
++      printf_filtered ("%d %d %d %d %d %d\n",
++        TYPE_CODE (check_typedef(value_type (val))),
++        TYPE_UNSIGNED (check_typedef(value_type (val))),
++        TYPE_LENGTH (check_typedef(value_type(val))),
++        value_offset (val), value_bitpos (val), value_bitsize(val));
++    }
++  else if (voidprint || (val && value_type (val) &&
+ 		    TYPE_CODE (value_type (val)) != TYPE_CODE_VOID))
+     {
+       struct value_print_options opts;
+@@ -1018,7 +1026,13 @@ print_command_1 (char *exp, int inspect, int voidprint)
+ static void
+ print_command (char *exp, int from_tty)
+ {
+-  print_command_1 (exp, 0, 1);
++  print_command_1 (exp, 0, 1, 0);
++}
++
++static void
++printm_command (char *exp, int from_tty)
++{
++  print_command_1 (exp, 0, 1, 1);
+ }
+ 
+ /* Same as print, except in epoch, it gets its own window.  */
+@@ -1027,14 +1041,14 @@ inspect_command (char *exp, int from_tty)
+ {
+   extern int epoch_interface;
+ 
+-  print_command_1 (exp, epoch_interface, 1);
++  print_command_1 (exp, epoch_interface, 1, 0);
+ }
+ 
+ /* Same as print, except it doesn't print void results.  */
+ static void
+ call_command (char *exp, int from_tty)
+ {
+-  print_command_1 (exp, 0, 0);
++  print_command_1 (exp, 0, 0, 0);
+ }
+ 
+ void
+@@ -2844,6 +2858,11 @@ resides in memory.\n\
+ \n\
+ EXP may be preceded with /FMT, where FMT is a format letter\n\
+ but no count or size letter (see \"x\" command)."));
++
++  c = add_com ("printm", class_vars, printm_command, _("\
++Similar to \"print\" command, but it used to print the type, size, offset,\n\
++bitpos and bitsize of the expression EXP."));
++
+   set_cmd_completer (c, expression_completer);
+   add_com_alias ("p", "print", class_vars, 1);
-- 
1.7.1

