-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Util to resolve combined line to orig file/line
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/python | ||
# | ||
# Resolve a line number in the combined source into an uncombined file/line | ||
# using a dist/src/metadata.json file. | ||
# | ||
# Usage: $ python resolve_combined_lineno.py dist/src/metadata.json 12345 | ||
# | ||
|
||
import os | ||
import sys | ||
import json | ||
|
||
def main(): | ||
with open(sys.argv[1], 'rb') as f: | ||
metadata = json.loads(f.read()) | ||
lineno = int(sys.argv[2]) | ||
|
||
for e in reversed(metadata['line_map']): | ||
if lineno >= e['combined_line']: | ||
orig_lineno = e['original_line'] + (lineno - e['combined_line']) | ||
print('%s:%d -> %s:%d' % ('duktape.c', lineno, | ||
e['original_file'], orig_lineno)) | ||
break | ||
|
||
if __name__ == '__main__': | ||
main() |