Add commandline option for disabling stdout redirection (#2144)

* Add option for disabling stdout and stderr redirection.
* Add command line option description to documentation.
This commit is contained in:
karliss 2020-04-17 15:02:44 +03:00 committed by GitHub
parent 4d2ef58e6a
commit b69dff0fcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 99 additions and 3 deletions

View File

@ -16,7 +16,7 @@ Compilation error
-----------------
r_core development package not found
~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you installed radare2 and still encounter this error, it could be that your
``PATH`` environment variable is set improperly (doesnt contain

View File

@ -11,5 +11,6 @@ Cutter is an advanced reverse engineering platform that is powered by radare2. T
:titlesonly:
:glob:
user-docs/command-line
user-docs/menus

View File

@ -0,0 +1,63 @@
Command line options
====================
Synopsis
--------
**Cutter** [*options*] [<*filename*>]
Options
-------
.. option:: <filename>
Filename to open. If not specified file selection dialog will be shown.
.. option:: -h, --help
Displays help on commandline options.
.. option:: --help-all
Displays help including Qt specific options.
.. option:: -v, --version
Displays version information.
.. option:: -A, --anal <level>
When opening a file automatically perform analysis at given level. Requires
:option:`<filename>` to be specified. Following levels are available:
**0**
No analysis.
**1**
aaa
**2**
aaaa (experimental)
.. option:: -F, --format <name>
Force using a specific file format (bin plugin)
.. option:: -B, --base <base address>
Load binary at a specific base address
.. option:: -i <file>
Run script file
.. option:: --pythonhome <PYTHONHOME>
PYTHONHOME to use for embedded python interpreter
.. option:: --no-output-redirect
Disable output redirection. Some of the output in console widget will not
be visible. Use this option when debuging a crash or freeze and output
redirection is causing some messages to be lost.

View File

@ -99,6 +99,13 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc
"PYTHONHOME");
cmd_parser.addOption(pythonHomeOption);
QCommandLineOption disableRedirectOption("no-output-redirect",
QObject::tr("Disable output redirection."
" Some of the output in console widget will not be visible."
" Use this option when debuging a crash or freeze and output "
" redirection is causing some messages to be lost."));
cmd_parser.addOption(disableRedirectOption);
cmd_parser.process(*this);
QStringList args = cmd_parser.positionalArguments();
@ -137,6 +144,10 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc
Config()->loadInitial();
Core()->loadCutterRC();
if (cmd_parser.isSet(disableRedirectOption)) {
Config()->setOutputRedirectionEnabled(false);
}
if (R2DecDecompiler::isAvailable()) {
Core()->registerDecompiler(new R2DecDecompiler(Core()));
}
@ -367,4 +378,3 @@ void CutterProxyStyle::polish(QWidget *widget)
}
#endif // QT_VERSION_CHECK(5, 10, 0) < QT_VERSION
}

View File

@ -728,3 +728,13 @@ void Configuration::setBitmapExportScaleFactor(double inputValueGraph)
s.setValue("bitmapGraphExportScale", inputValueGraph);
}
void Configuration::setOutputRedirectionEnabled(bool enabled)
{
this->outputRedirectEnabled = enabled;
}
bool Configuration::getOutputRedirectionEnabled() const
{
return outputRedirectEnabled;
}

View File

@ -41,6 +41,7 @@ private:
#ifdef CUTTER_ENABLE_KSYNTAXHIGHLIGHTING
KSyntaxHighlighting::Repository *kSyntaxHighlightingRepository;
#endif
bool outputRedirectEnabled = true;
// Colors
void loadBaseThemeNative();
@ -181,6 +182,15 @@ public:
void setBitmapTransparentState(bool inputValueGraph);
void setBitmapExportScaleFactor(double inputValueGraph);
/**
* @brief Enable or disable Cutter output redirection.
* Output redirection state can only be changed early during Cutter initalization.
* Changing it later will have no effect
* @param enabled set this to false for disabling output redirection
*/
void setOutputRedirectionEnabled(bool enabled);
bool getOutputRedirectionEnabled() const;
public slots:
void refreshFont();
signals:

View File

@ -128,7 +128,9 @@ ConsoleWidget::ConsoleWidget(MainWindow *main, QAction *action) :
completer->popup()->installEventFilter(this);
redirectOutput();
if (Config()->getOutputRedirectionEnabled()) {
redirectOutput();
}
}
ConsoleWidget::~ConsoleWidget()