Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TUI Support Infrastructure #1620

Merged
merged 115 commits into from
Jan 27, 2021
Merged

TUI Support Infrastructure #1620

merged 115 commits into from
Jan 27, 2021

Conversation

ehennenfent
Copy link
Contributor

Adds preliminary support for the TUI to Manticore. Lots of limitations and shortcomings right now. In no particular order:

  • The log capture doesn't work with multiprocessing. Logs created in different processes (unsurprisingly) don't fire the callback that inserts them into the server's buffer. Fixing this will probably require using the multiprocessing module's concurrency mechanisms.
  • The state capture requires acquiring the global state lock. It'd be better to use a plugin system to keep track of a state model over time, but since plugins run in the worker processes this would require us to use the locked context. For now, this way is simpler.
  • Only captures state IDs and what list they're in - nothing about current status, instruction counts, or termination messages. That's a consequence of looking at the state lists instead of the states themselves.
  • Very synchronous - Uses a socket server that creates a new connection every time the TUI polls for an update. Ideally, we'd open a pipe and just stream log/state messages through that. That said, I highly doubt a dozen-ish TCP packets per second are going to have any substantial performance impact, but we should profile this to make sure.

pwang00 and others added 7 commits February 6, 2020 11:02
* Update worker thread for server creation

* Add necessary files for TUI connectivity

* Add necessary files for TUI connectivity

* Update MonitorWorker

* Update protocol

* Blacken

* Update setup.py dependencies

* Remove state debugging messages

* Update setup.py to build protobuf protocol upon install

* Remove previously generated state_pb2.py

* Change subprocess.Popen to subprocess.check_output

* Remove extraneous output

* First attempt at fixing protobuf installation

It might work, it might not. We'll let the CI sort it out.

* Can't forget the f-string

* Error on missing protoc

* Disable auto-generation of protobuf file

* Ignore pb2_errors

* Disable monitor start

See if this makes the EVM tests pass

Co-authored-by: Eric Hennenfent <ecapstone@gmail.com>
@ehennenfent ehennenfent linked an issue Jun 19, 2020 that may be closed by this pull request
Eric Hennenfent added 2 commits August 28, 2020 11:27
Haven't been able to figure out why, but somehow other loggers get "stuck" at this high verbosity and the integration tests try to print out the values of every single register.
@ehennenfent
Copy link
Contributor Author

This builds heavily on top of #1775, so that will need to be merged first, but pending that it's ready for review.

@ehennenfent ehennenfent added this to the Manticore 0.3.5 milestone Sep 3, 2020
@ehennenfent ehennenfent requested review from feliam, ekilmer and sschriner and removed request for ekilmer October 13, 2020 16:04
Copy link
Contributor

@ekilmer ekilmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far! I'm hoping we can have the protobuf compiler generate the serialization file during installation though. Thoughts?

manticore/core/manticore.py Show resolved Hide resolved
manticore/core/state_pb2.py Show resolved Hide resolved
manticore/core/worker.py Outdated Show resolved Hide resolved
Copy link
Contributor Author

@ehennenfent ehennenfent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been sitting open for a while, so to make it easier to review I added a couple of comments pointing to parts that I think might be controversial.

@@ -134,20 +134,3 @@ def test_integration_basic_stdin(self):
else:
self.assertTrue(a <= 0x41)
self.assertTrue(b > 0x41)


class ManticoreLogger(unittest.TestCase):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@feliam I moved this from this file over to test_logging.py in order to avoid the problem where the log level gets stuck at the max level. I seem to recall you having dealt with something similar, but I can't remember where. Did you come up with a better solution?

server.dump = dump_states # type: ignore
server.serve_forever()
except OSError as e:
# TODO - this should be logger.warning, but we need to rewrite several unit tests that depend on
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@feliam Do you think it's worth fixing this in this PR, or should we do a more general rewrite of the tests separately?

A lot of our tests check for exact stdout output, which can be brittle if you want to add new logging messages. Maybe it'd be better to check that the lines we're looking for are contained in the output the correct number of times?

@ehennenfent
Copy link
Contributor Author

Per our discussion at the dev meeting, since this has been sitting unchanged for roughly a month and no one has had the cycles to fully review it, I'm going to merge it as-is (and take the flak if it breaks).

@ehennenfent ehennenfent merged commit 5a258f4 into master Jan 27, 2021
@ehennenfent ehennenfent deleted the dev-phillip branch January 27, 2021 16:17
ekilmer added a commit that referenced this pull request Feb 18, 2021
* master:
  Syscall specific hooks (#2389)
  TUI Support Infrastructure (#1620)
ekilmer added a commit that referenced this pull request Feb 27, 2021
* master: (43 commits)
  Syscall specific hooks (#2389)
  TUI Support Infrastructure (#1620)
  Fix coveralls upload (#2387)
  docs: fix simple typo, straigth -> straight (#2381)
  Attempt to allow symbolic balances from the start (#1818)
  Fix state.cpu.PC member (#1825)
  Bump black and mypy (#1824)
  Manticore 0.3.5 (#1808)
  Fix yices timeout argument (#1817)
  Detect default solver (#1820)
  Ignore Gas Calculations by Default (#1816)
  native/cpu/x86: Add support for CPUID EAX=80000000h (#1811)
  Change types.FunctionType=<class 'function'> (#1803)
  Fix test regressions (#1804)
  State Introspection API (#1775)
  Fix EVM account existence checks for selfdestruct and call (#1801)
  Add partial implementation of sendto syscall (#1791)
  crytic-compile: use latest release (#1795)
  Update gas metering for calls to empty accounts (#1774)
  Fix BitVec with symbolic offset and fix TranslatorSmtlib.unique thread safety (#1792)
  ...
ekilmer added a commit that referenced this pull request Apr 7, 2021
* master:
  Removed use of global solver from Native Memory (#2414)
  Support to use boolector as the SMT solver (#2410)
  Update CI and suggest to use pip3 instead of pip (#2409)
  Expressions use keyword-only arguments for init (#2395)
  Use Slots on all Expression objects (#2394)
  Allow double-adding exact same config option (#2397)
  Don't run OSX tests on PR
  Attempt to Fix solc Installation MacOS (#2392)
  Syscall specific hooks (#2389)
  TUI Support Infrastructure (#1620)
  Fix coveralls upload (#2387)
  docs: fix simple typo, straigth -> straight (#2381)
  Attempt to allow symbolic balances from the start (#1818)
  Fix state.cpu.PC member (#1825)
  Bump black and mypy (#1824)
ekilmer added a commit that referenced this pull request Apr 10, 2021
* master: (22 commits)
  Fix the generation of EVM tests (#2426)
  Disabled EVM events in testcases by default (#2417)
  added proper timeouts for cvc4 and boolector (#2418)
  Removed use of global solver from Native Memory (#2414)
  Support to use boolector as the SMT solver (#2410)
  Update CI and suggest to use pip3 instead of pip (#2409)
  Expressions use keyword-only arguments for init (#2395)
  Use Slots on all Expression objects (#2394)
  Allow double-adding exact same config option (#2397)
  Don't run OSX tests on PR
  Attempt to Fix solc Installation MacOS (#2392)
  Syscall specific hooks (#2389)
  TUI Support Infrastructure (#1620)
  Fix coveralls upload (#2387)
  docs: fix simple typo, straigth -> straight (#2381)
  Attempt to allow symbolic balances from the start (#1818)
  Fix state.cpu.PC member (#1825)
  Bump black and mypy (#1824)
  Manticore 0.3.5 (#1808)
  Fix yices timeout argument (#1817)
  ...
@ehennenfent ehennenfent mentioned this pull request May 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a real-time TUI
4 participants