I would like to create a new MCStreamer object inside the AsmPrinter class, which will be used in the AsmPrinter::EmitFunctionBody() method. This new MCStreamer object has to use the dbgs() raw_stream instead of the default Out stream as created in the LLVMTargetMachine::addPassesToEmitFile method.
In that method, there’s a call to the default OutStreamer.EmitInstruction(&MI) method. In my code, I need to call this method for my new MCStreamer object.
In summary, I want to print the asm instruction created by the EmitInstruction method to the dbgs() stream.
All the objects I need (at least I think) to create my new MCStreamer object are the running instances for the Target of the MCInstPrinter, MCAsmBackend and MCCodeEmitter classes. How can I retrieve these objects inside the AsmPrinter class?