0

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)

1

2 Answers 2

1

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.

0

You just need to do the file redirection within gdb.

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.