File tree Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -7952,24 +7952,20 @@ def test_dwarf(self):
7952
7952
7953
7953
# parse the sections
7954
7954
sections = {}
7955
- curr_section_name = ''
7956
- curr_section_body = ''
7957
7955
7958
- def add_section ():
7959
- if curr_section_name :
7960
- sections [ curr_section_name ] = curr_section_body
7956
+ lines = out . splitlines ()
7957
+ # Add a sentinel to ensure the last section gets flushed properly
7958
+ lines += [ ' dummy contents:' ]
7961
7959
7962
- for line in out .splitlines ():
7960
+ curr_section_name = ''
7961
+ curr_section_start = - 1
7962
+ for i , line in enumerate (lines ):
7963
7963
if ' contents:' in line :
7964
- # a new section, a line like ".debug_str contents:"
7965
- add_section ()
7964
+ if curr_section_start >= 0 :
7965
+ # a new section, a line like ".debug_str contents:"
7966
+ sections [curr_section_name ] = '\n ' .join (lines [curr_section_start :i ])
7966
7967
curr_section_name = line .split (' ' )[0 ]
7967
- curr_section_body = ''
7968
- else :
7969
- # possibly a line in a section
7970
- if curr_section_name :
7971
- curr_section_body += line + '\n '
7972
- add_section ()
7968
+ curr_section_start = i + 1
7973
7969
7974
7970
# make sure the right sections exist
7975
7971
self .assertIn ('.debug_abbrev' , sections )
You can’t perform that action at this time.
0 commit comments