From: Datesfat Chicks on 29 Apr 2010 11:02 I've been provided with a library where a debugging statement was left in so that it emits a single debugging line to stdout or stderr when a certain function is called. I'm not able at this time to get a recompiled version of the library with the debugging statement removed. Is there a way to turn off writing to stdout or stderr for a period of time, i.e. turn_off_stdout_stderr_output(); LibraryFunctionWithDebuggingLineLeftIn(); turn_on_stdout_stderr_output(); Any way to do that? It might involve internals and file descriptors and all that, but I'd be willing to look it up if anyone has suggestions that need further refinement .... Thanks, Datesfat
From: David Mathog on 29 Apr 2010 11:49 On Apr 29, 8:02 am, "Datesfat Chicks" <datesfat.chi...(a)gmail.com> wrote: > Is there a way to turn off writing to stdout or stderr for a period of time, > i.e. > > turn_off_stdout_stderr_output(); > LibraryFunctionWithDebuggingLineLeftIn(); > turn_on_stdout_stderr_output(); Probably not a good idea. The problem is that if something does go wrong in that function you would not be notified. I would be tempted to take a binary editor to the library and remove the one debug statement. At the very least you should be able to reduce it to just a single blank line, and if you are lucky and the EOL is hardcoded into the error message the message could be entirely eliminated. Regards, David Mathog
From: Moi on 29 Apr 2010 11:58 On Thu, 29 Apr 2010 11:02:28 -0400, Datesfat Chicks wrote: > I've been provided with a library where a debugging statement was left > in so that it emits a single debugging line to stdout or stderr when a > certain function is called. > > I'm not able at this time to get a recompiled version of the library > with the debugging statement removed. > > Is there a way to turn off writing to stdout or stderr for a period of > time, i.e. > > turn_off_stdout_stderr_output(); > LibraryFunctionWithDebuggingLineLeftIn(); > turn_on_stdout_stderr_output(); > > Any way to do that? > > It might involve internals and file descriptors and all that, but I'd be > willing to look it up if anyone has suggestions that need further > refinement ... The obvious way would be to use dup2() to swap file descriptors with one you opened to /dev/null. You may need to fflush(), as well. a very simple workaround: if you are able to locate the [f]printf()'s format string in the library, you could change it's first character to '\0'. HTH, AvK
From: Datesfat Chicks on 29 Apr 2010 15:12 "Moi" <root(a)invalid.address.org> wrote in message news:e0d5c$4bd9aca7$5350c024$26915(a)cache120.multikabel.net... > On Thu, 29 Apr 2010 11:02:28 -0400, Datesfat Chicks wrote: > >> I've been provided with a library where a debugging statement was left >> in so that it emits a single debugging line to stdout or stderr when a >> certain function is called. >> >> I'm not able at this time to get a recompiled version of the library >> with the debugging statement removed. >> >> Is there a way to turn off writing to stdout or stderr for a period of >> time, i.e. >> >> turn_off_stdout_stderr_output(); >> LibraryFunctionWithDebuggingLineLeftIn(); >> turn_on_stdout_stderr_output(); >> >> Any way to do that? >> >> It might involve internals and file descriptors and all that, but I'd be >> willing to look it up if anyone has suggestions that need further >> refinement ... > > > The obvious way would be to use dup2() to swap file descriptors with > one you opened to /dev/null. You may need to fflush(), as well. > > a very simple workaround: if you are able to locate the [f]printf()'s > format string in the library, you could change it's first character to > '\0'. What tool would I use to modify a library file (.so or .a, can't remember) in that way? Thanks, Datesfat
From: Jens Thoms Toerring on 29 Apr 2010 15:41
Datesfat Chicks <datesfat.chicks(a)gmail.com> wrote: > "Moi" <root(a)invalid.address.org> wrote in message > news:e0d5c$4bd9aca7$5350c024$26915(a)cache120.multikabel.net... > > a very simple workaround: if you are able to locate the [f]printf()'s > > format string in the library, you could change it's first character to > > '\0'. > What tool would I use to modify a library file (.so or .a, can't remember) > in that way? One possible tool is emacs - load the .a or .so file, switch to 'hexl-mode' (M-x hexl-mode) and then you can search in the file for the offending format string and replace the first of its characters by 0. Regards, Jens -- \ Jens Thoms Toerring ___ jt(a)toerring.de \__________________________ http://toerring.de |