diff mbox

[4/4] toolchain: instrument external toolchain wrapper

Message ID 574ef0eb7e941dcc6c9dba3540f4aa1c213472bc.1374182572.git.yann.morin.1998@free.fr
State Superseded
Headers show

Commit Message

Yann E. MORIN July 18, 2013, 9:24 p.m. UTC
From: "Yann E. MORIN" <yann.morin.1998@free.fr>

If BR_DEBUG_WRAPPER is set in the envirnment, dump the actual command
being exec()uted, to ease debugging issues with the wrapper.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
 toolchain/toolchain-external/ext-toolchain-wrapper.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Thomas Petazzoni July 18, 2013, 9:32 p.m. UTC | #1
Dear Yann E. MORIN,

I like the feature, but it would be nice if the coding was more
consistent with the rest of the code, see below:

On Thu, 18 Jul 2013 23:24:15 +0200, Yann E. MORIN wrote:

> +	if( getenv("BR_DEBUG_WRAPPER") ) {

No space after ( and before ).

> +		fprintf( stderr, "path='%s'\n", path );

Dirro.

> +		int i;

Variable declaration in the middle of the code. I know it's C99 ok, but
I'd prefer not to have that (just like the kernel).

> +		for( i=0; args[i]; i++ ) {

		for (i = 0; args[i]; i++)

> +			fprintf(stderr, "argv[%d]='%s'\n", i, args[i] );

Ditto space before ).

Thomas
Yann E. MORIN July 18, 2013, 9:39 p.m. UTC | #2
Thomas, All,

On 2013-07-18 23:32 +0200, Thomas Petazzoni spake thusly:
> I like the feature, but it would be nice if the coding was more
> consistent with the rest of the code, see below:

Sure! :-)

It initially was a quick'n'dirty hack, and I eventually thought it might
be useful upstream too. I'll re-read my code better next time... :-/

> On Thu, 18 Jul 2013 23:24:15 +0200, Yann E. MORIN wrote:
> > +	if( getenv("BR_DEBUG_WRAPPER") ) {
> No space after ( and before ).

Ack.

> > +		fprintf( stderr, "path='%s'\n", path );
> Dirro.

Ditto?
Ditto! ;-)

> > +		int i;
> Variable declaration in the middle of the code. I know it's C99 ok, but
> I'd prefer not to have that (just like the kernel).

Doh. Right.

gcc also whines about this (which was my original code):
	for( int i=0; args[i]; i++ ) {

> > +		for( i=0; args[i]; i++ ) {
> 		for (i = 0; args[i]; i++)

Ack.

> > +			fprintf(stderr, "argv[%d]='%s'\n", i, args[i] );
> Ditto space before ).

Atta! I'll fix and respin. Thanks! :-)

Regsards,
Yann E. MORIN.
diff mbox

Patch

diff --git a/toolchain/toolchain-external/ext-toolchain-wrapper.c b/toolchain/toolchain-external/ext-toolchain-wrapper.c
index 460f255..8e56414 100644
--- a/toolchain/toolchain-external/ext-toolchain-wrapper.c
+++ b/toolchain/toolchain-external/ext-toolchain-wrapper.c
@@ -136,6 +136,14 @@  int main(int argc, char **argv)
 	/* finish with NULL termination */
 	*cur = NULL;
 
+	if( getenv("BR_DEBUG_WRAPPER") ) {
+		fprintf( stderr, "path='%s'\n", path );
+		int i;
+		for( i=0; args[i]; i++ ) {
+			fprintf(stderr, "argv[%d]='%s'\n", i, args[i] );
+		}
+	}
+
 	if (execv(path, args))
 		perror(path);