avast / avast/retdec

Add full address space support to llvmir-emul and capstone2llvmir unit test framework

Open
#406 0 comments 0 reactions 0 assignees View on GitHub
C-capstone2llvmir C-llvmir-emul C-tests enhancement
Dominant language
C++
Stars
8.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

`llvmir-emul` library and Capstone2llvmir unit tests framework (`Capstone2LlvmIrTranslatorTests`) can handle and check only the default address space (value 0). Work with any other address space is not supported.

However, there are some corner cases that use non-default address spaces and we are currently not able to properly unit-test the generated code. E.g. work with x86 segment registers implemented and tested in e83a8cc9dca24d7138a5bb9383e893e0993aec1f - the tests are checking the generated LLVM IR instructions instead of the effects of emulating these instructions. We should be able to set/check memory in different address spaces, and emulate and log work with this memory.

What needs to be done:
* All existing interfaces must be kept unchanged - the default address space of 0 does not have to be specified, existing unit test do not have to be changed.
* It is possible to specify address space to memory-related unit-test methods like `setMemory()`, `EXPECT_JUST_MEMORY_LOADED()`, etc.
* `llvmir-emul` handles work with non-default address spaces, logs everything, and provides query methods. There will need to be one more layer added to the `address -> value` map: `address space -> address -> value`.
* Modify existing unit tests added in e83a8cc9dca24d7138a5bb9383e893e0993aec1f.

This requires quite a lot of work for something that will be used in very small amount of tests.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the llvmir-emul interfaces and the Capstone2LlvmIrTranslatorTests framework, especially setMemory(), EXPECT_JUST_MEMORY_LOADED(), and related memory queries. Review the existing segment-register tests from commit e83a8cc9dca24d7138a5bb9383e893e0993aec1f. Done means preserving default-address-space behavior while supporting, logging, querying, and testing non-default address spaces.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.