public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] tracepoint: add new trace command "printf"[1] gdbserver
@ 2011-01-03 16:29 Hui Zhu
  2011-01-28  6:41 ` Hui Zhu
  0 siblings, 1 reply; 8+ messages in thread
From: Hui Zhu @ 2011-01-03 16:29 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 247 bytes --]

This patch is for the gdbserver.

2011-01-04  Hui Zhu  <teawater@gmail.com>

	* tracepoint.c (gdb_agent_op): Add gdb_agent_op_printf.
	(gdb_agent_op_names): Add "printf".
	(tp_printf): New function.
	(eval_agent_expr): Handle gdb_agent_op_printf.

[-- Attachment #2: tp_print_server.txt --]
[-- Type: text/plain, Size: 1465 bytes --]

---
 gdbserver/tracepoint.c |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

--- a/gdbserver/tracepoint.c
+++ b/gdbserver/tracepoint.c
@@ -515,6 +515,7 @@ enum gdb_agent_op
     gdb_agent_op_setv = 0x2d,
     gdb_agent_op_tracev = 0x2e,
     gdb_agent_op_trace16 = 0x30,
+    gdb_agent_op_printf = 0x31,
     gdb_agent_op_last
   };
 
@@ -569,6 +570,7 @@ static const char *gdb_agent_op_names [g
     "tracev",
     "?undef?",
     "trace16",
+    "printf",
   };
 
 struct agent_expr
@@ -4288,6 +4290,16 @@ unparse_agent_expr (struct agent_expr *a
 
 #endif
 
+int
+tp_printf(const char *format, ...)
+{
+  va_list ap;
+  va_start (ap, format);
+  vprintf (format, ap);
+  va_end(ap);
+  return 0;
+}
+
 /* The agent expression evaluator, as specified by the GDB docs. It
    returns 0 if everything went OK, and a nonzero error code
    otherwise.  */
@@ -4630,6 +4642,22 @@ eval_agent_expr (struct tracepoint_hit_c
 	  agent_tsv_read (tframe, arg);
 	  break;
 
+	case gdb_agent_op_printf:
+	  {
+	    void *argv;
+	    arg = aexpr->bytes[pc++];
+	    argv = (void *)top;
+	    if (--sp >= 0)
+	      top = stack[sp];
+
+	    if (arg)
+	      tp_printf ((char *)(aexpr->bytes + pc), argv);
+	    else
+	      tp_printf ((char *)(aexpr->bytes + pc));
+	    pc += strlen ((char *)aexpr->bytes + pc) + 1;
+	  }
+	  break;
+
 	  /* GDB never (currently) generates any of these ops.  */
 	case gdb_agent_op_float:
 	case gdb_agent_op_ref_float:

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] tracepoint: add new trace command "printf"[1] gdbserver
  2011-01-03 16:29 [PATCH] tracepoint: add new trace command "printf"[1] gdbserver Hui Zhu
@ 2011-01-28  6:41 ` Hui Zhu
  2011-02-04 16:01   ` Hui Zhu
  0 siblings, 1 reply; 8+ messages in thread
From: Hui Zhu @ 2011-01-28  6:41 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 630 bytes --]

On Tue, Jan 4, 2011 at 00:29, Hui Zhu <teawater@gmail.com> wrote:
> This patch is for the gdbserver.
>
> 2011-01-04  Hui Zhu  <teawater@gmail.com>
>
>        * tracepoint.c (gdb_agent_op): Add gdb_agent_op_printf.
>        (gdb_agent_op_names): Add "printf".
>        (tp_printf): New function.
>        (eval_agent_expr): Handle gdb_agent_op_printf.
>

Fix a build error in i386.

Thanks,
Hui

2011-01-28  Hui Zhu  <teawater@gmail.com>

	* tracepoint.c (gdb_agent_op): Add gdb_agent_op_printf.
	(gdb_agent_op_names): Add "printf".
	(tp_printf): New function.
	(eval_agent_expr): Handle gdb_agent_op_printf.

[-- Attachment #2: tp_print_server.txt --]
[-- Type: text/plain, Size: 1480 bytes --]

---
 gdbserver/tracepoint.c |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

--- a/gdbserver/tracepoint.c
+++ b/gdbserver/tracepoint.c
@@ -517,6 +517,7 @@ enum gdb_agent_op
     gdb_agent_op_setv = 0x2d,
     gdb_agent_op_tracev = 0x2e,
     gdb_agent_op_trace16 = 0x30,
+    gdb_agent_op_printf = 0x31,
     gdb_agent_op_last
   };
 
@@ -571,6 +572,7 @@ static const char *gdb_agent_op_names [g
     "tracev",
     "?undef?",
     "trace16",
+    "printf",
   };
 
 struct agent_expr
@@ -4292,6 +4294,16 @@ unparse_agent_expr (struct agent_expr *a
 
 #endif
 
+int
+tp_printf(const char *format, ...)
+{
+  va_list ap;
+  va_start (ap, format);
+  vprintf (format, ap);
+  va_end(ap);
+  return 0;
+}
+
 /* The agent expression evaluator, as specified by the GDB docs. It
    returns 0 if everything went OK, and a nonzero error code
    otherwise.  */
@@ -4634,6 +4646,22 @@ eval_agent_expr (struct tracepoint_hit_c
 	  agent_tsv_read (tframe, arg);
 	  break;
 
+	case gdb_agent_op_printf:
+	  {
+	    void *argv;
+	    arg = aexpr->bytes[pc++];
+	    argv = (void *)(unsigned long)top;
+	    if (--sp >= 0)
+	      top = stack[sp];
+
+	    if (arg)
+	      tp_printf ((char *)(aexpr->bytes + pc), argv);
+	    else
+	      tp_printf ((char *)(aexpr->bytes + pc));
+	    pc += strlen ((char *)aexpr->bytes + pc) + 1;
+	  }
+	  break;
+
 	  /* GDB never (currently) generates any of these ops.  */
 	case gdb_agent_op_float:
 	case gdb_agent_op_ref_float:

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] tracepoint: add new trace command "printf"[1] gdbserver
  2011-01-28  6:41 ` Hui Zhu
@ 2011-02-04 16:01   ` Hui Zhu
  2011-02-11 21:31     ` Tom Tromey
  0 siblings, 1 reply; 8+ messages in thread
From: Hui Zhu @ 2011-02-04 16:01 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

To make the gdbserver support %s.

Thanks,
Hui

2011-01-28  Hui Zhu  <teawater@gmail.com>

	* tracepoint.c (gdb_agent_op): Add gdb_agent_op_printf.
	(gdb_agent_op_names): Add "printf".
	(tp_printf): New function.
	(eval_agent_expr): Handle gdb_agent_op_printf.

[-- Attachment #2: tp_print_server.txt --]
[-- Type: text/plain, Size: 1874 bytes --]

---
 gdbserver/tracepoint.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

--- a/gdbserver/tracepoint.c
+++ b/gdbserver/tracepoint.c
@@ -517,6 +517,7 @@ enum gdb_agent_op
     gdb_agent_op_setv = 0x2d,
     gdb_agent_op_tracev = 0x2e,
     gdb_agent_op_trace16 = 0x30,
+    gdb_agent_op_printf = 0x31,
     gdb_agent_op_last
   };
 
@@ -571,6 +572,7 @@ static const char *gdb_agent_op_names [g
     "tracev",
     "?undef?",
     "trace16",
+    "printf",
   };
 
 struct agent_expr
@@ -4292,6 +4294,16 @@ unparse_agent_expr (struct agent_expr *a
 
 #endif
 
+int
+tp_printf(const char *format, ...)
+{
+  va_list ap;
+  va_start (ap, format);
+  vprintf (format, ap);
+  va_end(ap);
+  return 0;
+}
+
 /* The agent expression evaluator, as specified by the GDB docs. It
    returns 0 if everything went OK, and a nonzero error code
    otherwise.  */
@@ -4634,6 +4646,40 @@ eval_agent_expr (struct tracepoint_hit_c
 	  agent_tsv_read (tframe, arg);
 	  break;
 
+	case gdb_agent_op_printf:
+	  {
+	    void *argv;
+	    arg = aexpr->bytes[pc++];
+	    argv = (void *)(unsigned long)top;
+	    if (--sp >= 0)
+	      top = stack[sp];
+
+	    if (arg)
+	      {
+		if (strstr ((char *)(aexpr->bytes + pc), "%s"))
+		  {
+		    int			i;
+		    unsigned char	buf[100];
+
+		    for (i = 0; i < 100; i++)
+		      {
+			agent_mem_read (tframe, buf + i,
+					(CORE_ADDR) ((unsigned long)argv + i),
+					1);
+			if (!buf[i])
+			  break;
+		      }
+		    tp_printf ((char *)(aexpr->bytes + pc), buf);
+		  }
+		else
+	          tp_printf ((char *)(aexpr->bytes + pc), argv);
+	      }
+	    else
+	      tp_printf ((char *)(aexpr->bytes + pc));
+	    pc += strlen ((char *)aexpr->bytes + pc) + 1;
+	  }
+	  break;
+
 	  /* GDB never (currently) generates any of these ops.  */
 	case gdb_agent_op_float:
 	case gdb_agent_op_ref_float:

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] tracepoint: add new trace command "printf"[1] gdbserver
  2011-02-04 16:01   ` Hui Zhu
@ 2011-02-11 21:31     ` Tom Tromey
  2011-02-17  9:54       ` Hui Zhu
  0 siblings, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2011-02-11 21:31 UTC (permalink / raw)
  To: Hui Zhu; +Cc: gdb-patches

>>>>> ">" == Hui Zhu <teawater@gmail.com> writes:

>> To make the gdbserver support %s.

Oops, I missed this when reviewing your earlier patch.
Sorry about that.

>> +int
>> +tp_printf(const char *format, ...)

Space before open paren.

>> +  va_end(ap);

Likewise.

>> +	    argv = (void *)(unsigned long)top;

Spacing.

There are several more spacing bugs, please fix them all.

I didn't go read the other patch to try to deduce the format of the
printf opcode to see if it all makes sense.  Documentation would help.

Tom

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] tracepoint: add new trace command "printf"[1] gdbserver
  2011-02-11 21:31     ` Tom Tromey
@ 2011-02-17  9:54       ` Hui Zhu
  2011-02-21  8:18         ` Hui Zhu
  0 siblings, 1 reply; 8+ messages in thread
From: Hui Zhu @ 2011-02-17  9:54 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 960 bytes --]

On Sat, Feb 12, 2011 at 05:31, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> ">" == Hui Zhu <teawater@gmail.com> writes:
>
>>> To make the gdbserver support %s.
>
> Oops, I missed this when reviewing your earlier patch.
> Sorry about that.
>
>>> +int
>>> +tp_printf(const char *format, ...)
>
> Space before open paren.
>
>>> +  va_end(ap);
>
> Likewise.
>
>>> +        argv = (void *)(unsigned long)top;
>
> Spacing.
>
> There are several more spacing bugs, please fix them all.
>
> I didn't go read the other patch to try to deduce the format of the
> printf opcode to see if it all makes sense.  Documentation would help.
>
> Tom
>

Hi Tom,

I make a new patch according to your comments.

Thanks,
Hui

2011-02-17  Hui Zhu  <teawater@gmail.com>

	* tracepoint.c (gdb_agent_op): Add gdb_agent_op_printf.
	(gdb_agent_op_names): Add "printf".
	(tp_printf): New function.
	(eval_agent_expr): Handle gdb_agent_op_printf.

[-- Attachment #2: tp_print_server.txt --]
[-- Type: text/plain, Size: 1883 bytes --]

---
 gdbserver/tracepoint.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

--- a/gdbserver/tracepoint.c
+++ b/gdbserver/tracepoint.c
@@ -517,6 +517,7 @@ enum gdb_agent_op
     gdb_agent_op_setv = 0x2d,
     gdb_agent_op_tracev = 0x2e,
     gdb_agent_op_trace16 = 0x30,
+    gdb_agent_op_printf = 0x31,
     gdb_agent_op_last
   };
 
@@ -571,6 +572,7 @@ static const char *gdb_agent_op_names [g
     "tracev",
     "?undef?",
     "trace16",
+    "printf",
   };
 
 struct agent_expr
@@ -4292,6 +4294,16 @@ unparse_agent_expr (struct agent_expr *a
 
 #endif
 
+int
+tp_printf (const char *format, ...)
+{
+  va_list ap;
+  va_start (ap, format);
+  vprintf (format, ap);
+  va_end (ap);
+  return 0;
+}
+
 /* The agent expression evaluator, as specified by the GDB docs. It
    returns 0 if everything went OK, and a nonzero error code
    otherwise.  */
@@ -4634,6 +4646,40 @@ eval_agent_expr (struct tracepoint_hit_c
 	  agent_tsv_read (tframe, arg);
 	  break;
 
+	case gdb_agent_op_printf:
+	  {
+	    void *argv;
+	    arg = aexpr->bytes[pc++];
+	    argv = (void *) (unsigned long) top;
+	    if (--sp >= 0)
+	      top = stack[sp];
+
+	    if (arg)
+	      {
+		if (strstr ((char *) (aexpr->bytes + pc), "%s"))
+		  {
+		    int			i;
+		    unsigned char	buf[100];
+
+		    for (i = 0; i < 100; i++)
+		      {
+			agent_mem_read (tframe, buf + i,
+					(CORE_ADDR) ((unsigned long)argv + i),
+					1);
+			if (!buf[i])
+			  break;
+		      }
+		    tp_printf ((char *) (aexpr->bytes + pc), buf);
+		  }
+		else
+	          tp_printf ((char *) (aexpr->bytes + pc), argv);
+	      }
+	    else
+	      tp_printf ((char *) (aexpr->bytes + pc));
+	    pc += strlen ((char *) aexpr->bytes + pc) + 1;
+	  }
+	  break;
+
 	  /* GDB never (currently) generates any of these ops.  */
 	case gdb_agent_op_float:
 	case gdb_agent_op_ref_float:

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] tracepoint: add new trace command "printf"[1] gdbserver
  2011-02-17  9:54       ` Hui Zhu
@ 2011-02-21  8:18         ` Hui Zhu
  2011-02-24  7:46           ` Joel Brobecker
  0 siblings, 1 reply; 8+ messages in thread
From: Hui Zhu @ 2011-02-21  8:18 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1278 bytes --]

On Thu, Feb 17, 2011 at 16:16, Hui Zhu <teawater@gmail.com> wrote:
> On Sat, Feb 12, 2011 at 05:31, Tom Tromey <tromey@redhat.com> wrote:
>>>>>>> ">" == Hui Zhu <teawater@gmail.com> writes:
>>
>>>> To make the gdbserver support %s.
>>
>> Oops, I missed this when reviewing your earlier patch.
>> Sorry about that.
>>
>>>> +int
>>>> +tp_printf(const char *format, ...)
>>
>> Space before open paren.
>>
>>>> +  va_end(ap);
>>
>> Likewise.
>>
>>>> +        argv = (void *)(unsigned long)top;
>>
>> Spacing.
>>
>> There are several more spacing bugs, please fix them all.
>>
>> I didn't go read the other patch to try to deduce the format of the
>> printf opcode to see if it all makes sense.  Documentation would help.
>>
>> Tom
>>
>
> Hi Tom,
>
> I make a new patch according to your comments.
>
> Thanks,
> Hui
>
> 2011-02-17  Hui Zhu  <teawater@gmail.com>
>
>        * tracepoint.c (gdb_agent_op): Add gdb_agent_op_printf.
>        (gdb_agent_op_names): Add "printf".
>        (tp_printf): New function.
>        (eval_agent_expr): Handle gdb_agent_op_printf.
>

Checked in.

Thanks,
Hui

2011-02-21  Hui Zhu  <teawater@gmail.com>

	* tracepoint.c (tp_printf): New function.
	(eval_agent_expr): Handle gdb_agent_op_printf.

[-- Attachment #2: tp_print_server.txt --]
[-- Type: text/plain, Size: 1544 bytes --]

---
 gdbserver/tracepoint.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

--- a/gdbserver/tracepoint.c
+++ b/gdbserver/tracepoint.c
@@ -4214,6 +4214,16 @@ gdb_agent_op_name (int op)
   return gdb_agent_op_names[op];
 }
 
+int
+tp_printf (const char *format, ...)
+{
+  va_list ap;
+  va_start (ap, format);
+  vprintf (format, ap);
+  va_end (ap);
+  return 0;
+}
+
 /* The agent expression evaluator, as specified by the GDB docs. It
    returns 0 if everything went OK, and a nonzero error code
    otherwise.  */
@@ -4573,6 +4583,40 @@ eval_agent_expr (struct tracepoint_hit_c
 	  agent_tsv_read (tframe, arg);
 	  break;
 
+	case gdb_agent_op_printf:
+	  {
+	    void *argv;
+	    arg = aexpr->bytes[pc++];
+	    argv = (void *) (unsigned long) top;
+	    if (--sp >= 0)
+	      top = stack[sp];
+
+	    if (arg)
+	      {
+		if (strstr ((char *) (aexpr->bytes + pc), "%s"))
+		  {
+		    int			i;
+		    unsigned char	buf[100];
+
+		    for (i = 0; i < 100; i++)
+		      {
+			agent_mem_read (tframe, buf + i,
+					(CORE_ADDR) ((unsigned long)argv + i),
+					1);
+			if (!buf[i])
+			  break;
+		      }
+		    tp_printf ((char *) (aexpr->bytes + pc), buf);
+		  }
+		else
+	          tp_printf ((char *) (aexpr->bytes + pc), argv);
+	      }
+	    else
+	      tp_printf ((char *) (aexpr->bytes + pc));
+	    pc += strlen ((char *) aexpr->bytes + pc) + 1;
+	  }
+	  break;
+
 	  /* GDB never (currently) generates any of these ops.  */
 	case gdb_agent_op_float:
 	case gdb_agent_op_ref_float:

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] tracepoint: add new trace command "printf"[1] gdbserver
  2011-02-21  8:18         ` Hui Zhu
@ 2011-02-24  7:46           ` Joel Brobecker
  2011-02-24  8:37             ` Hui Zhu
  0 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2011-02-24  7:46 UTC (permalink / raw)
  To: Hui Zhu; +Cc: gdb-patches

> 	* tracepoint.c (tp_printf): New function.
> 	(eval_agent_expr): Handle gdb_agent_op_printf.

For the record, this patch and the other two associated patches
have been temporarily reverted, as they hadn't actually been approved.
Hopefully we'll have a change to review them soon.

-- 
Joel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] tracepoint: add new trace command "printf"[1] gdbserver
  2011-02-24  7:46           ` Joel Brobecker
@ 2011-02-24  8:37             ` Hui Zhu
  0 siblings, 0 replies; 8+ messages in thread
From: Hui Zhu @ 2011-02-24  8:37 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

Hi Joel,

Thanks for your help.

Best,
Hui

On Thu, Feb 24, 2011 at 15:44, Joel Brobecker <brobecker@adacore.com> wrote:
>>       * tracepoint.c (tp_printf): New function.
>>       (eval_agent_expr): Handle gdb_agent_op_printf.
>
> For the record, this patch and the other two associated patches
> have been temporarily reverted, as they hadn't actually been approved.
> Hopefully we'll have a change to review them soon.
>
> --
> Joel
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-02-24  7:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-03 16:29 [PATCH] tracepoint: add new trace command "printf"[1] gdbserver Hui Zhu
2011-01-28  6:41 ` Hui Zhu
2011-02-04 16:01   ` Hui Zhu
2011-02-11 21:31     ` Tom Tromey
2011-02-17  9:54       ` Hui Zhu
2011-02-21  8:18         ` Hui Zhu
2011-02-24  7:46           ` Joel Brobecker
2011-02-24  8:37             ` Hui Zhu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).