Skip to content

Commit

Permalink
adds functionality to parse a list of traces
Browse files Browse the repository at this point in the history
  • Loading branch information
christophkloeffel committed Jun 14, 2024
1 parent 748fdcd commit aa30288
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions lobster/tools/core/online_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def main():

rel_path_from_root = os.path.relpath(item.location.filename,
repo_root)
# pylint: disable=possibly-used-before-assignment
actual_repo = gh_root
actual_sha = options.commit
actual_path = rel_path_from_root
Expand Down
16 changes: 9 additions & 7 deletions lobster/tools/cpp_raw/cpp_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,15 @@ def write_to_file(options: Namespace, data: Dict[str, Implementation]) -> None:
print("Written output for %u items to %s" % (len(data), options.out))


def find_lobster_traces(all_lines: List[str]) -> List[Tuple[re.Match, int]]:
def find_lobster_traces(all_lines: List[str]) -> List[Tuple[List[str], int]]:
matches = []
i = 0
while i < len(all_lines):
line = all_lines[i]
match = re.search(r'lobster-trace:\s*(\w+\.\w+)', line)
match = re.search(r'lobster-trace:\s*(.*)', line)
if match:
matches.append((match, i))
items = match.group(1).split(',')
matches.append(([item.strip() for item in items], i))
i += 1
return matches

Expand Down Expand Up @@ -119,7 +120,7 @@ def find_all_function_decl(file_content: str) -> List[Tuple[re.Match, int]]:

def create_raw_entry(data: Dict[str, Implementation], file_name: str,
name: str, line_number: int) -> Tracing_Tag:
tag = Tracing_Tag("cpp", f"{file_name}::{name}::{line_number}")
tag = Tracing_Tag("cpp", f"{file_name}:{name}:{line_number}")
loc = File_Reference(file_name, line_number)
data[tag.key()] = Implementation(
tag = tag,
Expand All @@ -130,7 +131,7 @@ def create_raw_entry(data: Dict[str, Implementation], file_name: str,
return tag


def create_entry(match: Tuple[re.Match, int],
def create_entry(match: Tuple[List[str], int],
data: Dict[str, Implementation],
all_lines: List[str], file: TextIOWrapper,
tag_type: str) -> Tracing_Tag:
Expand All @@ -144,11 +145,12 @@ def create_entry(match: Tuple[re.Match, int],
return create_raw_entry(data, file.name, name, function_line + 1)


def create_trace_entry(match: Tuple[re.Match, int],
def create_trace_entry(match: Tuple[List[str], int],
data: Dict[str, Implementation],
all_lines: List[str], file: TextIOWrapper) -> None:
tag = create_entry(match, data, all_lines, file, "lobster-trace")
data[tag.key()].add_tracing_target(Tracing_Tag("req", match[0].group(1)))
for req in match[0]:
data[tag.key()].add_tracing_target(Tracing_Tag("req", req))


def create_exclude_entry(match: Tuple[re.Match, int],
Expand Down
1 change: 1 addition & 0 deletions lobster/tools/trlc/trlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ def main():
ok = False
if ok:
stab = sm.process()
# pylint: disable=possibly-used-before-assignment
if not ok or stab is None:
print("lobster-trlc: aborting due to earlier error")
return 1
Expand Down

0 comments on commit aa30288

Please sign in to comment.