>From 0a01acbe0f12496dd0ed3609f70ab6639afc9e59 Mon Sep 17 00:00:00 2001
From: qiaonuohan <qiaonuohan@cn.fujitsu.com>
Date: Tue, 15 May 2012 04:54:26 +0800
Subject: [PATCH] add gdb command printm

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

diff --git a/gdb-7.3.1.patch b/gdb-7.3.1.patch
index 4e1c08b..791923a 100644
--- a/gdb-7.3.1.patch
+++ b/gdb-7.3.1.patch
@@ -1357,3 +1357,80 @@
  	      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
+@@ -1016,11 +1016,62 @@ print_command_1 (char *exp, int inspect, int voidprint)
+ }
+ 
+ static void
++print_command_2 (char *exp, int inspect, int voidprint)
++{
++  struct expression *expr;
++  struct cleanup *old_chain = 0;
++  char format = 0;
++  struct value *val;
++  struct format_data fmt;
++  int cleanup = 0;
++
++  if (exp && *exp == '/')
++    {
++      exp++;
++      fmt = decode_format (&exp, last_format, 0);
++      validate_format (fmt, "print");
++      last_format = format = fmt.format;
++    }
++  else
++    {
++      fmt.count = 1;
++      fmt.format = 0;
++      fmt.size = 0;
++      fmt.raw = 0;
++    }
++
++  if (exp && *exp)
++    {
++      expr = parse_expression (exp);
++      old_chain = make_cleanup (free_current_contents, &expr);
++      cleanup = 1;
++      val = evaluate_expression (expr);
++    }
++  else
++    val = access_value_history (0);
++
++    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));
++
++  if (cleanup)
++    do_cleanups (old_chain);
++}
++
++static void
+ print_command (char *exp, int from_tty)
+ {
+   print_command_1 (exp, 0, 1);
+ }
+ 
++static void
++printm_command (char *exp, int from_tty)
++{
++  print_command_2 (exp, 0, 1);
++}
++
+ /* Same as print, except in epoch, it gets its own window.  */
+ static void
+ inspect_command (char *exp, int from_tty)
+@@ -2847,6 +2898,11 @@ but no count or size letter (see \"x\" command)."));
+   set_cmd_completer (c, expression_completer);
+   add_com_alias ("p", "print", class_vars, 1);
+ 
++  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);
++
+   c = add_com ("inspect", class_vars, inspect_command, _("\
+ Same as \"print\" command, except that if you are running in the epoch\n\
+ environment, the value is printed in its own window."));
-- 
1.7.1

