diff options
author | Nilay Vaish <nilay@cs.wisc.edu> | 2015-09-03 15:40:20 -0500 |
---|---|---|
committer | Nilay Vaish <nilay@cs.wisc.edu> | 2015-09-03 15:40:20 -0500 |
commit | 80b911afd573ecda0cefb8f24b83d94b7faf4b7b (patch) | |
tree | 95aa2f9794fe70fa812c63583f9db6602457b69e /util/cpt_upgraders/process-fdmap-rename.py | |
parent | 2ab38ba13c6245480a08cd5b8651b5af8fce5a4b (diff) | |
parent | 87b9da2df4d4dc0028566a7803ee55159343d735 (diff) | |
download | gem5-80b911afd573ecda0cefb8f24b83d94b7faf4b7b.tar.xz |
merged with recent commits.
Diffstat (limited to 'util/cpt_upgraders/process-fdmap-rename.py')
-rw-r--r-- | util/cpt_upgraders/process-fdmap-rename.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/util/cpt_upgraders/process-fdmap-rename.py b/util/cpt_upgraders/process-fdmap-rename.py new file mode 100644 index 000000000..6bbbd5459 --- /dev/null +++ b/util/cpt_upgraders/process-fdmap-rename.py @@ -0,0 +1,32 @@ +# http://stackoverflow.com/questions/15069127/python-configparser-module-\ +# rename-a-section +def rename_section(cp, section_from, section_to): + items = cp.items(section_from) + cp.add_section(section_to) + for item in items: + cp.set(section_to, item[0], item[1]) + cp.remove_section(section_from) + +# Checkpoint version F renames an internal member of Process class. +def upgrader(cpt): + import re + for sec in cpt.sections(): + fdm = 'FdMap' + fde = 'FDEntry' + if re.match('.*\.%s.*' % fdm, sec): + rename = re.sub(fdm, fde, sec) + split = re.split(fde, rename) + + # rename the section and add the 'mode' field + rename_section(cpt, sec, rename) + cpt.set(rename, 'mode', "0") # no proper value to set :( + + # add in entries 257 to 1023 + if split[1] == "0": + for x in range(257, 1024): + seq = (split[0], fde, "%s" % x) + section = "".join(seq) + cpt.add_section(section) + cpt.set(section, 'fd', '-1') + +legacy_version = 15 |