def fetchSome(self): firstMeetFuncInfo=None funcInfoStr='' funcInfo = None ignore=False blockOfNormalLines=[] i=self.i-1 #======================================================================= # print "========" # for line in self.lines: # print line # print "========" #======================================================================= if abs(i)>len(self.lines): print "OH" while abs(i)<=len(self.lines): line=self.lines[i] if self.should_ignore_and_ingore_following(line): ignore=True #=========================================================== # rfx_free (ptr=0x81c3900) at mem.c:10 # 10 { # 11 if(!ptr) # 13 free(ptr); # __GI___libc_free (mem=0x81c3900) at malloc.c:2912 # 2912 malloc.c: No such file or directory. # 2917 in malloc.c # ... # 2946 in malloc.c # _int_free (av=0xb7fa7420 <main_arena>, p=0x81c38f8, have_lock=0) at malloc.c:3814 # 3814 in malloc.c # ... # 3827 in malloc.c # rfx_free (ptr=0x81c3900) at mem.c:14 <---------this line should also be removed # 14 } #=========================================================== i-=1 continue #if self.hexHeadPattern.match(line): #return True if ignore: #if headInfoPattern.match(line): if ('a'<=line[0] and line[0]<='z') or ('A'<=line[0] and line[0]<'Z') or line[0]=='_': if not self.singleStepPattern.match(line): ignore=False if '0x'==line[0:2]:#hex head line (optimization) if self.singleStepPattern.match(self.lines[i+1]): ignore=False i-=1 continue if re.search(r"^[0-9][1-9]*$",line.strip()):#null line i-=1 continue if self.isNormalLine(line):#normal line blockOfNormalLines.append(line) #LOG INFO print "find normal line:",line if "785" in line: print "HEY!" print self.lines[0] else:#func info line #if headInfoPattern.match(line): if ('a'<=line[0] and line[0]<='z') or ('A'<=line[0] and line[0]<'Z') or line[0]=='_': if i-1<len(self.lines):#look ahead if abs(i)!=len(self.lines) and self.should_ignore_and_ingore_following(self.lines[i-1]): #=========================================================== # 3827 in malloc.c # rfx_free (ptr=0x81c3900) at mem.c:14 <---------this line should also be removed # 14 } #=========================================================== ignore=True i-=1 continue else: ignore=False funcInfoStr=line.strip()+funcInfoStr print funcInfoStr funcInfo=FunctionCallInfo(funcInfoStr) self.l[0:0]=[LineOfCode(aline,funcInfo) for aline in blockOfNormalLines[::-1]] self.l.insert(0, funcInfo) if abs(i)==len(self.lines): break blockOfNormalLines=[] if firstMeetFuncInfo is None or funcInfo.get_func_name()==firstMeetFuncInfo.get_func_name(): if self.isNormalLine(self.lines[i-1]): callsite=LineOfCode(self.lines[i-1], None) print callsite funcname=funcInfo.get_func_name().split("::")[-1] if self.isObviousCallSite(funcname, callsite.codestr): #=============================================================================== # positive example #=============================================================================== # 515 if (jobs & FEDTJ_CALLBACK) # 516 callback(self, buf, advance, num, fid, fontsize, x, y, &color);<--------------callsite # textcallback (self=0xbfffe6a8, glyphs=0xbfffde40, advance=0xbfffe240, nr=15, fontid=5, fontsize=960, startx=0, starty=1053, color=0xbfffde14) at swfstrings.c:115 # 115 SWFFONT*font = 0; #=============================================================================== # negative example #=============================================================================== # 43 return mFirst = mLast = new ListItem<T>( data, NULL, user_data );<--------------not callsite # SWF::Header::parse (this=0x83c7ab0, r=0x83c7a98, end=32780, ctx=0xbfffe724) # at gSWFParser.cpp:423 # 423 if( r->getPosition() < myend || (r->getPosition()==myend && r->getBits() )) #=============================================================================== break else: filename=self.fetch_callsite_filename(i-1) if self.isMacroCall(callsite,filename,line): break if firstMeetFuncInfo is None: firstMeetFuncInfo=funcInfo elif 'main' in line: funcInfoStr=line.strip()+funcInfoStr funcInfo=FunctionCallInfo(funcInfoStr) ns=[LineOfCode(aline,funcInfo) for aline in blockOfNormalLines[::-1]] #ns = self.fixBlock(ns) self.l[0:0]=ns self.l.insert(0, funcInfo) blockOfNormalLines=[] else: print 1/0#ERROR IMPOSSIBLE funcInfoStr='' #LOG INFO print "find head info line:",line else: #Tail function call stack info funcInfoStr=line.strip()+funcInfoStr #LOG INFO print "find tail info line:",line if "_ctx=_ctx@entry=0xbfffe724, filesize=filesize@entry=505) at SWFFile.cpp:34" in line: print "HEY!" i-=1 self.i=i return self.l