diff options
| author | Vladislav HrĨka <41523109+nofiv@users.noreply.github.com> | 2019-02-08 12:33:55 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-08 12:33:55 +0100 |
| commit | 1336fe271af73aa74f14ad57b0972776ae0cc9e2 (patch) | |
| tree | 4bd22b012a16c38c3c0bba086024cbefe0828f50 | |
| parent | e7684d8523f51f99ee78745bb856c9a3ddfa6fcc (diff) | |
| download | miasm-1336fe271af73aa74f14ad57b0972776ae0cc9e2.tar.gz miasm-1336fe271af73aa74f14ad57b0972776ae0cc9e2.zip | |
Added description
Added description according to: https://github.com/cea-sec/miasm/pull/963#issuecomment-461737259. Also added docstring for find_path
| -rw-r--r-- | miasm2/core/graph.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/miasm2/core/graph.py b/miasm2/core/graph.py index b7026953..e385b044 100644 --- a/miasm2/core/graph.py +++ b/miasm2/core/graph.py @@ -143,6 +143,14 @@ class DiGraph(object): return [x for x in self.heads_iter()] def find_path(self, src, dst, cycles_count=0, done=None): + """ + Searches for paths from @src to @dst + @src: loc_key of basic block from which it should start + @dst: loc_key of basic block where it should stop + @cycles_count: maximum number of times a basic block can be processed + @done: dictionary of already processed loc_keys, it's value is number of times it was processed + @out: list of paths from @src to @dst + """ if done is None: done = {} if dst in done and done[dst] > cycles_count: @@ -163,6 +171,11 @@ class DiGraph(object): This function does the same as function find_path. But it searches the paths from src to dst, not vice versa like find_path. This approach might be more efficient in some cases. + @src: loc_key of basic block from which it should start + @dst: loc_key of basic block where it should stop + @cycles_count: maximum number of times a basic block can be processed + @done: dictionary of already processed loc_keys, it's value is number of times it was processed + @out: list of paths from @src to @dst """ if done is None: @@ -172,7 +185,7 @@ class DiGraph(object): if src in done and done[src] > cycles_count: return [[]] out = [] - for node in self.mlt_blck.successors(src): + for node in self.successors(src): done_n = dict(done) done_n[src] = done_n.get(src, 0) + 1 for path in self.find_path_from_src(node, dst, cycles_count, done_n): |