PKU-ASAL / SeeWasm

A native symbolic execution engine for WebAssembly
40 stars 4 forks source link

Code Refactoring -- data structures #35

Closed AlfredThiel closed 2 years ago

AlfredThiel commented 2 years ago

Is your feature request related to a problem? Please describe. For the convenience of future development, it is of great importance to organize the project code in a neat and well-structured way. This issue is one request for data structure refactoring. Some of refactoring targets:

Describe the solution you'd like Since most of the crucial functions in this engine manipulate some basic data structures, it will be quite helpful if the purposes of the members (both fields and methods) of those devised classes are listed at the very beginning of the classes/methods. The interpretative comment can be of any sort you like. For example:

class BasicBlock(object):
    """
    The purposes of all the fields are listed here.
    start_offset: ...
    start_instr: ...
    ...
    The purposes of all the methods can be listed here. It depends.
    """

    def __init__(self, start_offset=0x00, start_instr=None,
                 name='block_default_name'):
        """
        The purpose of the method can also be explained here.
        ...
        :param start_offset: ...
        :param start_instr: ...
        :param name: ...
        :return: ...
        """
        self.start_offset = start_offset
        self.start_instr = start_instr
        self.name = name
        self.end_offset = start_offset
        self.end_instr = start_instr
        self.instructions = list()

        self.states = []
        self.function_name = "unknown"

        # user dsl
        self.dsl = []

Describe alternatives you've considered /

Additional context /

HNYuuu commented 2 years ago

The description about some key data structures, i.e., basic block, instruction and function, is added in commit 7edc966

HNYuuu commented 2 years ago

The file cfg.py and graph.py is refactored and add necessary comments.

However, the refactor of DFS-traversal algorithm is postponed, please refer to #39. Also, some work still need to be done on graph.py, see #40.

I will temporarily close this issue and if you @AlfredThiel have any problems, please reopen this issue and add necessary information and description. The following refactoring work on graph.py will still perform on branch refine-graph, which I will not delete right now.