lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20060918154532.GF15605@Krystal>
Date:	Mon, 18 Sep 2006 11:45:32 -0400
From:	Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
To:	Ingo Molnar <mingo@...e.hu>
Cc:	"Frank Ch. Eigler" <fche@...hat.com>,
	Paul Mundt <lethal@...ux-sh.org>,
	linux-kernel <linux-kernel@...r.kernel.org>,
	Jes Sorensen <jes@....com>, Andrew Morton <akpm@...l.org>,
	Tom Zanussi <zanussi@...ibm.com>,
	Richard J Moore <richardj_moore@...ibm.com>,
	Michel Dagenais <michel.dagenais@...ymtl.ca>,
	Christoph Hellwig <hch@...radead.org>,
	Greg Kroah-Hartman <gregkh@...e.de>,
	Thomas Gleixner <tglx@...utronix.de>,
	William Cohen <wcohen@...hat.com>,
	"Martin J. Bligh" <mbligh@...igh.org>
Subject: Re: tracepoint maintainance models

Hi Ingo,

If it is less visually intrusive to declare markers as a macro, let's do it this
way. I have no preference : as long as both dynamic probes and static ones can
be hooked and that it does imply so much black magic that kernel developers
won't know what code will be called from the marker when tracing is enabled.

Back in 2005, I made a quick macro example that would benefit to everybody. It
changes following config options to either :

- nothing
- a call to printk
- a call to a static tracer (either inline function or a real call)
- no operations (a 5 bytes site for an enhanced kprobe)

The 5 bytes of NOOP used here is absolutely not the way to go : djprobes guys
has much better alternatives.

Note that this example is a userspace program that can be trivially moved to a
kernel header (printf->printk, etc).

I also wanted to identify the trace point by a symbol, so it could be easily
found dynamically, but this part is not completed.

What are your thoughts about it ? (think of it as a proof of concept, and
search+replace MAGIC_TRACE for MARK). :)


Mathieu


----- BEGIN -----


/* ltt-macro.c
 *
 * Macro example for instrumentation
 *
 * Version 0.0.1
 * 
 * Mathieu Desnoyers mathieu.desnoyers@...ymtl.ca
 *
 * This is released under the GPL v2 (or better) license.
 */



/* This is an example of noop, get this from the current arch header */
#define GENERIC_NOP1    ".byte 0x90\n"


/* PUT THIS IN A INCLUDE/LINUX HEADER */

#define __stringify_1(x) #x //see include/linux/stringify.h
#define __stringify(x) __stringify_1(x)

#define KBUILD_BASENAME basename
#define KBUILD_MODNAME modulename

#define MAGIC_TRACE_SYM(event)	\
	char * __trace_symbol_##event =__stringify(KBUILD_MODNAME) "_" \
					__stringify(KBUILD_BASENAME) "_" \
					#event ;

/* With config menu mutual exclusion of choice */
#ifdef CONFIG_NOLOG
#define MAGIC_TRACE(event, format, args...)
#endif

#ifdef CONFIG_PRINTLOG
#define MAGIC_TRACE(event, format, args...) \
	printf(format, ##args);
#endif

#ifdef CONFIG_TRACELOG
#define MAGIC_TRACE(event, format, args...) \
	trace_##event( args );
#endif

#ifdef CONFIG_KPROBELOG
#define MAGIC_TRACE(event, format, args...) \
	__asm__ ( GENERIC_NOP1 GENERIC_NOP1 GENERIC_NOP1 GENERIC_NOP1 GENERIC_NOP1 )
#endif

/* PUT THIS IN A HEADER NEAR THE .C FILE */
#ifdef CONFIG_TRACELOG
static inline void trace_eventname(int a, char *b)
{
	/* log.... */
	printf("Tracing event : first arg %d, second arg %s", a, b);
}
#endif

/* PUT THIS IN THE .C FILE */

MAGIC_TRACE_SYM(eventname);

int main()
{
	int myint = 55;
	char * mystring = "blah";
	
	MAGIC_TRACE(eventname, "%d %s", myint, mystring);
	
	printf("\n");

	return 0;
}

------ END  -----




OpenPGP public key:              http://krystal.dyndns.org:8080/key/compudj.gpg
Key fingerprint:     8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ