an turn them in to livelink (unless already transformed).
diff test1.tmp test1.base
python copyfile.py test1.in
diff test1.in test1.in.out
+ python refclassfixup.py test2.in
+ diff test2.in.out test2.base
+ python refclassfixup.py test2.in.out
+ # checking for idempotence
+ diff test2.in.out test2.in.out.out
cur = 1
filelist = []
while len(sys.argv) > cur:
- print "argv[",cur,"] = ", sys.argv[cur]
v = sys.argv[cur]
filelist += [v]
cur = int(cur) + 1
self._label = []
# Class is "id", "ind","other","none"
self._class = "none"
+ def insertid(self,string):
+ self._class = "id"
+ self._tex = list(string)
+ self._underbar = self._tex
+ self._std = self._tex
+ self._label = self._tex
def setIndivid(self,c):
self._tex = [c]
self._underbar = [c]
for t in self._toks:
t.dwwrite(outfile)
outfile.write("\n")
+ def dwtransformline(self,callfunc):
+ toks = callfunc(self._toks)
+ self._toks = toks
class dwfile:
for l in self._lines:
l.dwwrite(outfile,lnum)
lnum = lnum + 1
+ def dwtransformline(self,callfunc):
+ for l in self._lines:
+ l.dwtransformline(callfunc)
def dwwrite(self):
for f in self._files:
f.dwwrite()
-
+ def dwtransformline(self,callfunc):
+ for f in self._files:
+ f.dwtransformline(callfunc)
def readFilelist(filelist):
cur = 1
filelist = []
while len(sys.argv) > cur:
- print "argv[",cur,"] = ", sys.argv[cur]
v = sys.argv[cur]
filelist += [v]
cur = int(cur) + 1
--- /dev/null
+# Copyright 2012 DWARF Debugging Information Format Committee
+# This reads the input tokens and then
+# writes them out in new files.
+# Used to verify that the output matches the input byte-for-byte
+
+import sys
+import fileio
+
+refclass = {
+"address":"chap:address",
+"block":"chap:block",
+"constant":"chap:constant",
+"exprloc":"chap:exprloc",
+"flag":"chap:flag",
+"lineptr":"chap:lineptr",
+"loclistptr":"chap:loclistptr",
+"macptr":"chap:macptr",
+"rangelistptr":"chap:rangelistptr",
+"reference":"chap:reference",
+"string":"chap:string" }
+
+def ischar(tok,c):
+ if tok._class != "ind":
+ return "n"
+ if len(tok._tex) != 1:
+ return "n"
+ if tok._tex[0] != c:
+ return "n"
+ return "y"
+
+def transformone(tok, string):
+ label = refclass[string]
+ # output is \livelink{label}{string}
+ t1=fileio.dwtoken()
+ t1.insertid("\livelink")
+ t2=fileio.dwtoken()
+ t2.setIndivid("{")
+ t3=fileio.dwtoken()
+ t3.insertid(label)
+ t4=fileio.dwtoken()
+ t4.setIndivid("}")
+ t5 = t2
+ t6=fileio.dwtoken()
+ t6.insertid(string)
+ t7 = t4
+ return [t1,t2,t3,t4,t5,t6,t7]
+
+def append_to_out(out,addthese):
+ for a in addthese:
+ out += [a]
+
+def transfunc(linetoks):
+ if len(linetoks) < 1:
+ return linetoks
+ tnumin = 0
+ changes = 0
+ lasttoknum = len(linetoks) -1
+ outtoks = []
+ for t in linetoks:
+ rawtok = ''.join(t._tex)
+ if refclass.has_key(rawtok) == 1:
+ if tnumin == 0 or tnumin == lasttoknum:
+ tmp = transformone(t, rawtok);
+ changes = changes + 1
+ append_to_out(outtoks,tmp)
+ else:
+ if ischar(linetoks[tnumin - 1],"{") != "y" or ischar(linetoks[tnumin+1],"}") != "y":
+ tmp = transformone(t, rawtok);
+ append_to_out(outtoks,tmp)
+ changes = changes + 1
+ else:
+ outtoks += [t]
+ else:
+ outtoks += [t]
+ tnumin = tnumin+ 1
+ # End of for loop.
+ return outtoks
+
+def read_args():
+ cur = 1
+ filelist = []
+ while len(sys.argv) > cur:
+ v = sys.argv[cur]
+ filelist += [v]
+ cur = int(cur) + 1
+
+ dwf = fileio.readFilelist(filelist)
+ dwf.dwtransformline(transfunc)
+ dwf.dwwrite()
+
+if __name__ == '__main__':
+ read_args()
+
+
+
-argv[ 1 ] = test1.in
Number of files: 1
Number of lines in test1.in : 16
Number of tokens in line 1 : 0
--- /dev/null
+
+appropriate prefix (DW\_TAG_foo, DW\_AT_foo,
+DW\_END_line, DW\_ATE_x, DW\_OP_foo,
+DW\_LANG, DW\_LNE, DW\_CC or DW\_CFA respectively) followed by
+\_lo\_user or \_hi\_user.
+this is \livelink{chap:macptr}{macptr} and \livelink{chap:block}{block} . Which should transform.
+this is \livelink{chap:address}{address} and \livelink{chap:string}{string} . Which should transform.
+this should be untouched \livelink{chap:reference}{reference} for example.
+this should be untouched \livetarg{chap:block}{block} for example.
+this should be untouched \livetargi{chap:address}{address} for example.
+
+\endlastfoot
+\livelink{chap:DWTAGaccessdeclaration}{DW\-\_TAG\-\_access\-\_declaration}
+& DECL \\
+
+information entry with the tag
+\livetarg{chap:DWTAGaccessdeclaration}{DW\_TAG\_access\_declaration}.
+Each
+such entry is a child of the class or structure type entry.
+
--- /dev/null
+
+appropriate prefix (DW\_TAG_foo, DW\_AT_foo,
+DW\_END_line, DW\_ATE_x, DW\_OP_foo,
+DW\_LANG, DW\_LNE, DW\_CC or DW\_CFA respectively) followed by
+\_lo\_user or \_hi\_user.
+this is macptr and block . Which should transform.
+this is address and string . Which should transform.
+this should be untouched \livelink{chap:reference}{reference} for example.
+this should be untouched \livetarg{chap:block}{block} for example.
+this should be untouched \livetargi{chap:address}{address} for example.
+
+\endlastfoot
+\livelink{chap:DWTAGaccessdeclaration}{DW\-\_TAG\-\_access\-\_declaration}
+& DECL \\
+
+information entry with the tag
+\livetarg{chap:DWTAGaccessdeclaration}{DW\_TAG\_access\_declaration}.
+Each
+such entry is a child of the class or structure type entry.
+