EFiore
EFiore

Reputation: 115

using GDB with arguments

For a class assignment we needed to write a compiler. This includes an optimizer portion. In other words, we take in a file with some "code". An output file is generated. In the second step we take in the outputted code and remove any "dead" code and re-output to a second file. I have some problems with the optimizer portion and would like to use gdb. But I can't get gdb to operate properly with the input and output files arguments. The way we would normally run the optimizer is:

./optimize <tinyL.out> optimized.out

where tinyL.out is the file outputted in the first step and optimized.out is the file I want to output with the new optimized and compiled code.

I have searched Google for the solution and the tips I have found do not seem to work for my situation. Most people seem to want to only accept an input file and not output a separate file as I need to do.

Any help is appreciated (of course)

Upvotes: 0

Views: 3329

Answers (2)

Felix Lechenbauer
Felix Lechenbauer

Reputation: 300

I'm not exactly sure what you're asking. But since I'm not yet able to comment everywhere, I write this answer with a guess and edit/delete if necessary.

When GDB is started and before you start the program you wish to debug, set the arguments you want to use with set args.

A reference to the documentation.

Upvotes: 1

laverya
laverya

Reputation: 242

You just need to do the file redirection within gdb.

gdb ./optimize
(gdb) run < tinyL.out > optimized.out

https://stackoverflow.com/a/2388594/5657035

Upvotes: 0

Related Questions