Author Topic: redirect output of post-build step  (Read 5967 times)

Offline tom0769

  • Multiple posting newcomer
  • *
  • Posts: 42
redirect output of post-build step
« on: September 16, 2010, 08:53:08 am »
I am using CodeBlocks with mingw installed on a Win XP system.

I want to output all symbols of a debug exe to a file to parse it for later use.
I found that the binutil "nm.exe" does the job pefectly for me.
With the following command executed in the command shell, I can output the symbol table to a file:

"nm.exe .\bin\Debug\LT_Simulation.exe > symbols.txt"

Now I want to do this as a post-build step (Project - Build options - Pre/post build steps).
The nm-command works, but the output always goes to the build log window.

How can I redirect this to a file?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: redirect output of post-build step
« Reply #1 on: September 16, 2010, 09:33:40 am »
You can make a bat file and execute it as post build step.
There is a possibility to write a shell script, but it is harder to setup (I think)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: redirect output of post-build step
« Reply #2 on: September 16, 2010, 09:49:50 am »
How can I redirect this to a file?
Use the tools menu. Setup a tool (like a script or batch file) that does the re-direction. Use macros in the tool so that it is generic enough to work with any of your applications.

"nm.exe .\bin\Debug\LT_Simulation.exe > symbols.txt"
Are you aware that there is a symbol table plugin - the frontend to nm???
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: redirect output of post-build step
« Reply #3 on: September 16, 2010, 10:12:18 am »
Morten: can you execute a tool in a post build step?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: redirect output of post-build step
« Reply #4 on: September 16, 2010, 10:15:31 am »
Morten: can you execute a tool in a post build step?
No, but I can press the entry in the tools menu after the compilation. :-)

It might be possible to do the thing I've described using scripting in the post-build step though...

However, adding the ability to launch a tool (with a specific ID) from within the pre- post-build steps might be worth a thought though...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline tom0769

  • Multiple posting newcomer
  • *
  • Posts: 42
Re: redirect output of post-build step
« Reply #5 on: September 16, 2010, 11:26:20 am »
Hi all, thanks for replies!

Is there a macro for the location of the toolchain executables, so that it can be used to setup a tool?

I need to avoid absolute path names for both, project files and toolchain,
since this should be used by different people working with in different enviroments.

BTW
How can I get the symbol table plugin?
I found it listed at "http://wiki.codeblocks.org/index.php?title=Code::Blocks_Plugins" but page does not exist.
« Last Edit: September 16, 2010, 11:57:08 am by tom0769 »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5916
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: redirect output of post-build step
« Reply #6 on: September 16, 2010, 12:11:30 pm »
Is there a macro for the location of the toolchain executables, so that it can be used to setup a tool?
I guess you can get the toolchain path from the compiler plugin, but I'm not sure which function can get this. ( I have briefly read the public function of compiler plugin plugins\compilergcc\compilergcc.h, but does not find the answer..)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline tom0769

  • Multiple posting newcomer
  • *
  • Posts: 42
Re: redirect output of post-build step
« Reply #7 on: September 16, 2010, 12:54:25 pm »
Use the tools menu. Setup a tool (like a script or batch file) that does the re-direction. Use macros in the tool so that it is generic enough to work with any of your applications.
I setup a tool calling nm.exe using macros, but I still cannot write the output to a file.
The output goes either to a console or to stdout (Code::Blocks log window) depending on the launch option.

Offline tom0769

  • Multiple posting newcomer
  • *
  • Posts: 42
Re: redirect output of post-build step
« Reply #8 on: September 16, 2010, 02:50:54 pm »
In the configuration file "default.conf" there is an entry for each compiler:
<gcc>
    ...
    <MASTER_PATH>
        <str>
            <![CDATA[C:\Programme\CodeBlocks\MinGW]]>
        </str>
    </MASTER_PATH>
    ...
</gcc>   

Is it possible to get this information via a macro?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: redirect output of post-build step
« Reply #9 on: September 16, 2010, 04:46:15 pm »
How can I get the symbol table plugin?
If you use the installer, just enable it.
If you compile from sources, do the same.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ