From dff7c83542bace7cfa1fb16dfeb7bce0728cd74d Mon Sep 17 00:00:00 2001 From: caheckman <48068198+caheckman@users.noreply.github.com> Date: Fri, 3 Sep 2021 15:34:12 -0400 Subject: [PATCH 1/2] Add testfunction to ghidra_dbg. Push and pops scripts properly. --- Ghidra/Features/Decompiler/src/decompile/cpp/Makefile | 2 +- Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.cc | 5 +++++ Ghidra/Features/Decompiler/src/decompile/cpp/interface.cc | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/Makefile b/Ghidra/Features/Decompiler/src/decompile/cpp/Makefile index b278371b67..5d6e5643ba 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/Makefile +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/Makefile @@ -123,7 +123,7 @@ TEST_NAMES=$(CORE) $(DECCORE) $(SLEIGH) $(EXTRA) test TEST_DEBUG=-D__TERMINAL__ GHIDRA_NAMES=$(CORE) $(DECCORE) $(GHIDRA) -GHIDRA_NAMES_DBG=$(GHIDRA_NAMES) callgraph ifacedecomp ifaceterm interface +GHIDRA_NAMES_DBG=$(GHIDRA_NAMES) callgraph ifacedecomp testfunction ifaceterm interface GHIDRA_DEBUG=-DCPUI_DEBUG GHIDRA_OPT= diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.cc index 7cba748208..44a5843058 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.cc @@ -51,6 +51,11 @@ IfaceTerm::IfaceTerm(const string &prmpt,istream &is,ostream &os) IfaceTerm::~IfaceTerm(void) { + while(!inputstack.empty()) { + delete sptr; + sptr = inputstack.back(); + inputstack.pop_back(); + } #ifdef __TERMINAL__ if (is_terminal) { tcsetattr(ifd,TCSANOW,&itty); // Restore original terminal settings diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/interface.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/interface.cc index f0a98b6179..a95982ecb5 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/interface.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/interface.cc @@ -145,6 +145,7 @@ void IfaceStatus::pushScript(const string &filename,const string &newprompt) ifstream *s = new ifstream(filename.c_str()); if (!*s) throw IfaceParseError("Unable to open script file"); + pushScript(s,newprompt); } /// \brief Provide a new input stream to execute, with an associated command prompt From 407285176d8beab72ca9a9f48fad5b0f3539282e Mon Sep 17 00:00:00 2001 From: caheckman <48068198+caheckman@users.noreply.github.com> Date: Fri, 3 Sep 2021 16:10:31 -0400 Subject: [PATCH 2/2] Don't clear StringManager as part of local function analysis --- Ghidra/Features/Decompiler/src/decompile/cpp/architecture.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/architecture.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/architecture.cc index 54b3b01d5a..65b8c72049 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/architecture.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/architecture.cc @@ -286,7 +286,6 @@ void Architecture::clearAnalysis(Funcdata *fd) fd->clear(); // Clear stuff internal to function // Clear out any analysis generated comments commentdb->clearType(fd->getAddress(),Comment::warning|Comment::warningheader); - stringManager->clear(); } /// Symbols do not necessarily need to be available for the decompiler.