public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/2] gprofng: fprintf_styled_func not inizialized for disassembler
@ 2022-04-07  7:19 vladimir.mezentsev
  2022-04-10 16:13 ` Andrew Burgess
  0 siblings, 1 reply; 2+ messages in thread
From: vladimir.mezentsev @ 2022-04-07  7:19 UTC (permalink / raw)
  To: binutils

From: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>

gprofng/ChangeLog
2022-04-07  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	* libcollector/unwind.c: inizialize fprintf_styled_func.
	* src/Disasm.cc: Likewise.
---
 gprofng/libcollector/unwind.c |  9 +++++++++
 gprofng/src/Disasm.cc         | 16 ++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/gprofng/libcollector/unwind.c b/gprofng/libcollector/unwind.c
index ffb06f938f3..f309c54bd33 100644
--- a/gprofng/libcollector/unwind.c
+++ b/gprofng/libcollector/unwind.c
@@ -120,6 +120,14 @@ fprintf_func (void *arg ATTRIBUTE_UNUSED, const char *fmt ATTRIBUTE_UNUSED, ...)
   return 0;
 }
 
+static int
+fprintf_styled_func (void *arg ATTRIBUTE_UNUSED,
+		      enum disassembler_style st ATTRIBUTE_UNUSED,
+		      const char *fmt ATTRIBUTE_UNUSED, ...)
+{
+  return 0;
+}
+
 /* Get LENGTH bytes from info's buffer, at target address memaddr.
    Transfer them to myaddr.  */
 static int
@@ -4347,6 +4355,7 @@ parse_x86_AVX_instruction (unsigned char *pc)
   dis_info.octets_per_byte = 1;
   dis_info.disassembler_needs_relocs = FALSE;
   dis_info.fprintf_func = fprintf_func;
+  dis_info.fprintf_styled_func = fprintf_styled_func;
   dis_info.stream = NULL;
   dis_info.disassembler_options = NULL;
   dis_info.read_memory_func = read_memory_func;
diff --git a/gprofng/src/Disasm.cc b/gprofng/src/Disasm.cc
index 0fec9c3c76a..a5cca13950f 100644
--- a/gprofng/src/Disasm.cc
+++ b/gprofng/src/Disasm.cc
@@ -88,6 +88,21 @@ fprintf_func (void *arg, const char *fmt, ...)
   return cnt;
 }
 
+static int
+fprintf_styled_func (void *arg, enum disassembler_style st ATTRIBUTE_UNUSED,
+		      const char *fmt, ...)
+{
+  char buf[512];
+  va_list vp;
+  va_start (vp, fmt);
+  int cnt = vsnprintf (buf, sizeof (buf), fmt, vp);
+  va_end (vp);
+
+  Disasm *dis = (Disasm *) arg;
+  dis->dis_str->append (buf);
+  return cnt;
+}
+
 /* Get LENGTH bytes from info's buffer, at target address memaddr.
    Transfer them to myaddr.  */
 static int
@@ -165,6 +180,7 @@ Disasm::disasm_open ()
   dis_info.octets_per_byte = 1;
   dis_info.disassembler_needs_relocs = FALSE;
   dis_info.fprintf_func = fprintf_func;
+  dis_info.fprintf_styled_func = fprintf_styled_func;
   dis_info.stream = this;
   dis_info.disassembler_options = NULL;
   dis_info.read_memory_func = read_memory_func;
-- 
2.27.0


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

* Re: [PATCH 2/2] gprofng: fprintf_styled_func not inizialized for disassembler
  2022-04-07  7:19 [PATCH 2/2] gprofng: fprintf_styled_func not inizialized for disassembler vladimir.mezentsev
@ 2022-04-10 16:13 ` Andrew Burgess
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Burgess @ 2022-04-10 16:13 UTC (permalink / raw)
  To: vladimir.mezentsev, binutils

Vladimir Mezentsev via Binutils <binutils@sourceware.org> writes:

> From: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
>
> gprofng/ChangeLog
> 2022-04-07  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>
>
> 	* libcollector/unwind.c: inizialize fprintf_styled_func.
> 	* src/Disasm.cc: Likewise.
> ---
>  gprofng/libcollector/unwind.c |  9 +++++++++
>  gprofng/src/Disasm.cc         | 16 ++++++++++++++++
>  2 files changed, 25 insertions(+)

Not a binutils maintainer, so can't approve this patch.  But was
responsible for the styled disassembler work.  This change looks good to
me.

Thanks,
Andrew

>
> diff --git a/gprofng/libcollector/unwind.c b/gprofng/libcollector/unwind.c
> index ffb06f938f3..f309c54bd33 100644
> --- a/gprofng/libcollector/unwind.c
> +++ b/gprofng/libcollector/unwind.c
> @@ -120,6 +120,14 @@ fprintf_func (void *arg ATTRIBUTE_UNUSED, const char *fmt ATTRIBUTE_UNUSED, ...)
>    return 0;
>  }
>  
> +static int
> +fprintf_styled_func (void *arg ATTRIBUTE_UNUSED,
> +		      enum disassembler_style st ATTRIBUTE_UNUSED,
> +		      const char *fmt ATTRIBUTE_UNUSED, ...)
> +{
> +  return 0;
> +}
> +
>  /* Get LENGTH bytes from info's buffer, at target address memaddr.
>     Transfer them to myaddr.  */
>  static int
> @@ -4347,6 +4355,7 @@ parse_x86_AVX_instruction (unsigned char *pc)
>    dis_info.octets_per_byte = 1;
>    dis_info.disassembler_needs_relocs = FALSE;
>    dis_info.fprintf_func = fprintf_func;
> +  dis_info.fprintf_styled_func = fprintf_styled_func;
>    dis_info.stream = NULL;
>    dis_info.disassembler_options = NULL;
>    dis_info.read_memory_func = read_memory_func;
> diff --git a/gprofng/src/Disasm.cc b/gprofng/src/Disasm.cc
> index 0fec9c3c76a..a5cca13950f 100644
> --- a/gprofng/src/Disasm.cc
> +++ b/gprofng/src/Disasm.cc
> @@ -88,6 +88,21 @@ fprintf_func (void *arg, const char *fmt, ...)
>    return cnt;
>  }
>  
> +static int
> +fprintf_styled_func (void *arg, enum disassembler_style st ATTRIBUTE_UNUSED,
> +		      const char *fmt, ...)
> +{
> +  char buf[512];
> +  va_list vp;
> +  va_start (vp, fmt);
> +  int cnt = vsnprintf (buf, sizeof (buf), fmt, vp);
> +  va_end (vp);
> +
> +  Disasm *dis = (Disasm *) arg;
> +  dis->dis_str->append (buf);
> +  return cnt;
> +}
> +
>  /* Get LENGTH bytes from info's buffer, at target address memaddr.
>     Transfer them to myaddr.  */
>  static int
> @@ -165,6 +180,7 @@ Disasm::disasm_open ()
>    dis_info.octets_per_byte = 1;
>    dis_info.disassembler_needs_relocs = FALSE;
>    dis_info.fprintf_func = fprintf_func;
> +  dis_info.fprintf_styled_func = fprintf_styled_func;
>    dis_info.stream = this;
>    dis_info.disassembler_options = NULL;
>    dis_info.read_memory_func = read_memory_func;
> -- 
> 2.27.0


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

end of thread, other threads:[~2022-04-10 16:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07  7:19 [PATCH 2/2] gprofng: fprintf_styled_func not inizialized for disassembler vladimir.mezentsev
2022-04-10 16:13 ` Andrew Burgess

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).