All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] trace-cmd: add the ability to install libtracecmd
@ 2014-07-10 21:22 Josef Bacik
  2014-07-10 21:22 ` [PATCH 1/2] trace-cmd: add install_libs target to trace-cmd Josef Bacik
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Josef Bacik @ 2014-07-10 21:22 UTC (permalink / raw)
  To: linux-kernel, rostedt

Hello,

I'm trying to build some custom tracing tools on top of trace-cmd but they
aren't really usefull outside of Facebook so I don't want to shove them into the
actual trace-cmd project.  Instead I'd like to be able to just build libtracecmd
and install that as well as the necessary header files and just link my tools
against that.  I'm shit at userspace stuff like this, so I've just hacked
something together that works for me.  I'm mostly hoping somebody will look at
the Makefile horribleness that I came up with and tell me how to do it right (or
better yet do it for me!)  The second patch just cleans up some stuff to make
the shared library more library esque.  Any feedback would be great.  Thanks,

Josef


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

* [PATCH 1/2] trace-cmd: add install_libs target to trace-cmd
  2014-07-10 21:22 [RFC] trace-cmd: add the ability to install libtracecmd Josef Bacik
@ 2014-07-10 21:22 ` Josef Bacik
  2014-07-10 21:22 ` [PATCH 2/2] trace-cmd: make libtracecmd a little more library friendly Josef Bacik
  2014-07-10 22:53 ` [RFC] trace-cmd: add the ability to install libtracecmd Steven Rostedt
  2 siblings, 0 replies; 5+ messages in thread
From: Josef Bacik @ 2014-07-10 21:22 UTC (permalink / raw)
  To: linux-kernel, rostedt

I'd like to be able to build and link against libtracecmd, so add a make target
to build libtracecmd and install it into lib as well as the supporting header
files.  This allows me to be able to make stand alone apps that build and link
against trace-cmd for custom trace tools that don't have a place in the generic
trace-cmd tool.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 Makefile | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index cbe0eb9..df5ec72 100644
--- a/Makefile
+++ b/Makefile
@@ -47,7 +47,10 @@ html_install = $(prefix)/share/kernelshark/html
 html_install_SQ = '$(subst ','\'',$(html_install))'
 img_install = $(prefix)/share/kernelshark/html/images
 img_install_SQ = '$(subst ','\'',$(img_install))'
-libdir ?= lib
+libdir ?= $(prefix)/lib
+libdir_SQ = '$(subst ','\'',$(libdir))'
+includedir = $(prefix)/include/trace-cmd
+includedir_SQ = '$(subst ','\'',$(includedir))'
 
 export man_dir man_dir_SQ html_install html_install_SQ INSTALL
 export img_install img_install_SQ
@@ -57,8 +60,8 @@ ifeq ($(prefix),$(HOME))
 plugin_dir = $(HOME)/.trace-cmd/plugins
 python_dir = $(HOME)/.trace-cmd/python
 else
-plugin_dir = $(prefix)/$(libdir)/trace-cmd/plugins
-python_dir = $(prefix)/$(libdir)/trace-cmd/python
+plugin_dir = $(libdir)/trace-cmd/plugins
+python_dir = $(libdir)/trace-cmd/python
 PLUGIN_DIR = -DPLUGIN_DIR="$(plugin_dir)"
 PYTHON_DIR = -DPYTHON_DIR="$(python_dir)"
 PLUGIN_DIR_SQ = '$(subst ','\'',$(PLUGIN_DIR))'
@@ -399,6 +402,8 @@ libtracecmd.so: $(TCMD_LIB_OBJS)
 libtracecmd.a: $(TCMD_LIB_OBJS)
 	$(Q)$(do_build_static_lib)
 
+libs: libtracecmd.so libparsevent.so
+
 trace-util.o: trace_plugin_dir
 
 $(PLUGIN_OBJS): %.o : $(src)/%.c
@@ -558,6 +563,12 @@ install_gui: install_cmd gui
 	$(Q)$(call do_install,trace-graph,$(bindir_SQ))
 	$(Q)$(call do_install,kernelshark,$(bindir_SQ))
 
+install_libs: libs
+	$(Q)$(call do_install,libtracecmd.so,$(libdir_SQ))
+	$(Q)$(call do_install,libparsevent.so,$(libdir_SQ))
+	$(Q)$(call do_install,event-parse.h,$(includedir_SQ))
+	$(Q)$(call do_install,trace-cmd.h,$(includedir_SQ))
+
 doc:
 	$(MAKE) -C $(src)/Documentation all
 
-- 
1.8.3.1


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

* [PATCH 2/2] trace-cmd: make libtracecmd a little more library friendly
  2014-07-10 21:22 [RFC] trace-cmd: add the ability to install libtracecmd Josef Bacik
  2014-07-10 21:22 ` [PATCH 1/2] trace-cmd: add install_libs target to trace-cmd Josef Bacik
@ 2014-07-10 21:22 ` Josef Bacik
  2014-07-10 22:53 ` [RFC] trace-cmd: add the ability to install libtracecmd Steven Rostedt
  2 siblings, 0 replies; 5+ messages in thread
From: Josef Bacik @ 2014-07-10 21:22 UTC (permalink / raw)
  To: linux-kernel, rostedt

You get a lot of debug output if you link directly against libtracecmd if you
don't provide your own pr_stat() function because we default to something that
actually prints stuff out.  Fix this by making pr_stat() do nothing by default.
This also changes the printf() for the version number to a pr_stat().  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 parse-utils.c     | 6 ------
 plugin_function.c | 1 +
 trace-cmd-local.h | 1 +
 trace-cmd.c       | 1 +
 trace-cmd.h       | 2 --
 trace-input.c     | 2 +-
 trace-local.h     | 1 +
 trace-recorder.c  | 1 +
 trace-util.c      | 1 +
 9 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/parse-utils.c b/parse-utils.c
index f023a13..c5b0487 100644
--- a/parse-utils.c
+++ b/parse-utils.c
@@ -87,16 +87,10 @@ void __pr_stat(const char *fmt, ...)
 
 void __weak vpr_stat(const char *fmt, va_list ap)
 {
-	__vpr_stat(fmt, ap);
 }
 
 void __weak pr_stat(const char *fmt, ...)
 {
-	va_list ap;
-
-	va_start(ap, fmt);
-	__vpr_stat(fmt, ap);
-	va_end(ap);
 }
 
 void __weak *malloc_or_die(unsigned int size)
diff --git a/plugin_function.c b/plugin_function.c
index 0defd11..9ae4cf1 100644
--- a/plugin_function.c
+++ b/plugin_function.c
@@ -22,6 +22,7 @@
 #include <string.h>
 
 #include "trace-cmd.h"
+#include "event-utils.h"
 
 static struct func_stack {
 	int size;
diff --git a/trace-cmd-local.h b/trace-cmd-local.h
index 6f502c5..06809dd 100644
--- a/trace-cmd-local.h
+++ b/trace-cmd-local.h
@@ -23,6 +23,7 @@
 /* Local for trace-input.c and trace-output.c */
 
 #include "trace-cmd.h"
+#include "event-utils.h"
 
 static ssize_t __do_write(int fd, void *data, size_t size)
 {
diff --git a/trace-cmd.c b/trace-cmd.c
index ebf9c7a..1b776de 100644
--- a/trace-cmd.c
+++ b/trace-cmd.c
@@ -23,6 +23,7 @@
 #include <unistd.h>
 #include <dirent.h>
 #include <errno.h>
+#include <stdlib.h>
 
 #include "trace-local.h"
 
diff --git a/trace-cmd.h b/trace-cmd.h
index 92b4ff2..37d2fa8 100644
--- a/trace-cmd.h
+++ b/trace-cmd.h
@@ -20,8 +20,6 @@
 #ifndef _TRACE_CMD_H
 #define _TRACE_CMD_H
 
-#include <stdlib.h>
-#include "event-utils.h"
 #include "event-parse.h"
 
 #define TRACECMD_ERR_MSK	((unsigned long)(-1) & ~((1UL << 14) - 1))
diff --git a/trace-input.c b/trace-input.c
index 8118b22..090ee59 100644
--- a/trace-input.c
+++ b/trace-input.c
@@ -2237,7 +2237,7 @@ struct tracecmd_input *tracecmd_alloc_fd(int fd)
 	version = read_string(handle);
 	if (!version)
 		goto failed_read;
-	printf("version = %s\n", version);
+	pr_stat("version = %s\n", version);
 	free(version);
 
 	if (do_read_check(handle, buf, 1))
diff --git a/trace-local.h b/trace-local.h
index 3c82c2f..d187005 100644
--- a/trace-local.h
+++ b/trace-local.h
@@ -21,6 +21,7 @@
 #define __TRACE_LOCAL_H
 
 #include "trace-cmd.h"
+#include "event-utils.h"
 
 /* fix stupid glib guint64 typecasts and printf formats */
 typedef unsigned long long u64;
diff --git a/trace-recorder.c b/trace-recorder.c
index 247bb2d..e922f26 100644
--- a/trace-recorder.c
+++ b/trace-recorder.c
@@ -34,6 +34,7 @@
 #include <errno.h>
 
 #include "trace-cmd.h"
+#include "event-utils.h"
 
 struct tracecmd_recorder {
 	int		fd;
diff --git a/trace-util.c b/trace-util.c
index 208f150..e1f8230 100644
--- a/trace-util.c
+++ b/trace-util.c
@@ -32,6 +32,7 @@
 #include <sys/stat.h>
 
 #include "trace-cmd.h"
+#include "event-utils.h"
 
 #define LOCAL_PLUGIN_DIR ".trace-cmd/plugins"
 #define DEBUGFS_PATH "/sys/kernel/debug"
-- 
1.8.3.1


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

* Re: [RFC] trace-cmd: add the ability to install libtracecmd
  2014-07-10 21:22 [RFC] trace-cmd: add the ability to install libtracecmd Josef Bacik
  2014-07-10 21:22 ` [PATCH 1/2] trace-cmd: add install_libs target to trace-cmd Josef Bacik
  2014-07-10 21:22 ` [PATCH 2/2] trace-cmd: make libtracecmd a little more library friendly Josef Bacik
@ 2014-07-10 22:53 ` Steven Rostedt
  2014-07-11 18:27   ` Josef Bacik
  2 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2014-07-10 22:53 UTC (permalink / raw)
  To: Josef Bacik; +Cc: linux-kernel

On Thu, 10 Jul 2014 17:22:45 -0400
Josef Bacik <jbacik@fb.com> wrote:

> Hello,
> 
> I'm trying to build some custom tracing tools on top of trace-cmd but they
> aren't really usefull outside of Facebook so I don't want to shove them into the
> actual trace-cmd project.  Instead I'd like to be able to just build libtracecmd
> and install that as well as the necessary header files and just link my tools
> against that.  I'm shit at userspace stuff like this, so I've just hacked
> something together that works for me.  I'm mostly hoping somebody will look at
> the Makefile horribleness that I came up with and tell me how to do it right (or
> better yet do it for me!)  The second patch just cleans up some stuff to make
> the shared library more library esque.  Any feedback would be great.  Thanks,
> 

I'm shit at userspace too ;-)  I just like simple makefiles and other
non "autocrap" stuff.

Anyway, I did plan on getting a libtracecmd out someday (at a bottom of
a very long todo list), so I'm all game for this. I was hoping to get
libtraceevent out first. That's now homed in the kernel tools
directory and I've been porting stuff to and from trace-cmd for that as
well. But there's still a bit of work on that front.

I'll have to take a look at your patches and see how they are after I
get some other things out of the way first.

-- Steve

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

* Re: [RFC] trace-cmd: add the ability to install libtracecmd
  2014-07-10 22:53 ` [RFC] trace-cmd: add the ability to install libtracecmd Steven Rostedt
@ 2014-07-11 18:27   ` Josef Bacik
  0 siblings, 0 replies; 5+ messages in thread
From: Josef Bacik @ 2014-07-11 18:27 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-kernel

On 07/10/2014 06:53 PM, Steven Rostedt wrote:
> On Thu, 10 Jul 2014 17:22:45 -0400
> Josef Bacik <jbacik@fb.com> wrote:
>
>> Hello,
>>
>> I'm trying to build some custom tracing tools on top of trace-cmd but they
>> aren't really usefull outside of Facebook so I don't want to shove them into the
>> actual trace-cmd project.  Instead I'd like to be able to just build libtracecmd
>> and install that as well as the necessary header files and just link my tools
>> against that.  I'm shit at userspace stuff like this, so I've just hacked
>> something together that works for me.  I'm mostly hoping somebody will look at
>> the Makefile horribleness that I came up with and tell me how to do it right (or
>> better yet do it for me!)  The second patch just cleans up some stuff to make
>> the shared library more library esque.  Any feedback would be great.  Thanks,
>>
>
> I'm shit at userspace too ;-)  I just like simple makefiles and other
> non "autocrap" stuff.
>
> Anyway, I did plan on getting a libtracecmd out someday (at a bottom of
> a very long todo list), so I'm all game for this. I was hoping to get
> libtraceevent out first. That's now homed in the kernel tools
> directory and I've been porting stuff to and from trace-cmd for that as
> well. But there's still a bit of work on that front.
>
> I'll have to take a look at your patches and see how they are after I
> get some other things out of the way first.
>

Ok I didn't notice the libtracecmd, so I'll send the second patch 
against that since it's just against the event parse stuff.  In reality 
all I need is the event parsing stuff, I just use the libtracecmd to 
open the trace.dat file.  I'll see if I can figure out how to just parse 
the events live without having to record with trace-cmd first and that 
will probably be good enough for me for now, then maybe when I care 
about post-processing trace.dat you will have gotten to the bottom of 
your TODO list.  Thanks,

Josef

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

end of thread, other threads:[~2014-07-11 18:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-10 21:22 [RFC] trace-cmd: add the ability to install libtracecmd Josef Bacik
2014-07-10 21:22 ` [PATCH 1/2] trace-cmd: add install_libs target to trace-cmd Josef Bacik
2014-07-10 21:22 ` [PATCH 2/2] trace-cmd: make libtracecmd a little more library friendly Josef Bacik
2014-07-10 22:53 ` [RFC] trace-cmd: add the ability to install libtracecmd Steven Rostedt
2014-07-11 18:27   ` Josef Bacik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.