예제 #1
0
 public override bool Equals(System.Object object_Renamed)
 {
     if (object_Renamed is LineRecord)
     {
         LineRecord other = (LineRecord)object_Renamed;
         return(base.Equals(other) && other.lineno == this.lineno && equals(other.module, this.module));
     }
     else
     {
         return(false);
     }
 }
예제 #2
0
		public virtual bool addOffset(LineRecord lr, int offset)
		{
			bool worked = true;
			if (lr.lineno < offsets.Length)
			{
				offsets[lr.lineno] = offset;
			}
			else
			{
				// We have a condition 81918/78188 whereby Matador can produce a swd
				// where module ids were not unique, resulting in collision of offset records.
				// The best we can do is to mark the entire module as bad
				corrupt = true;
				worked = false;
			}
			return worked;
		}
예제 #3
0
        public virtual bool addOffset(LineRecord lr, int offset)
        {
            bool worked = true;

            if (lr.lineno < offsets.Length)
            {
                offsets[lr.lineno] = offset;
            }
            else
            {
                // We have a condition 81918/78188 whereby Matador can produce a swd
                // where module ids were not unique, resulting in collision of offset records.
                // The best we can do is to mark the entire module as bad
                corrupt = true;
                worked  = false;
            }
            return(worked);
        }
		public virtual void  lineRecord(LineRecord line)
		{
		}
		public virtual void  printLines(LineRecord lr, StreamWriter out_Renamed)
		{
			DebugModule script = lr.module;
			
			if (script != null)
			{
				int lineno = lr.lineno;
				if (lineno > 0)
				{
					while (lineno - 1 > 0 && script.offsets[lineno - 1] == 0)
					{
						lineno--;
					}
					if (lineno == 1)
					{
						indent();
						out_Renamed.WriteLine(script.name);
					}
					int off = script.index[lineno - 1];
					int len = script.index[lr.lineno] - off;
					out_Renamed.Write(script.text.ToCharArray(), off, len);
				}
			}
		}
		public override void  lineRecord(LineRecord line)
		{
			if (!showLineRecord)
			{
			}
			else if (showDebugSource)
			{
				printLines(line, out_Renamed);
			}
			else
			{
				start(line);
				out_Renamed.WriteLine(" " + line.module.name + ":" + line.lineno);
			}
		}
		public override void  doInitAction(DoInitAction tag)
		{
			if (header_field.version > 6 && tag.sprite != null)
			{
				String __Packages = idRef(tag.sprite);
				className = (__Packages != null && __Packages.StartsWith("__Packages"))?__Packages.Substring(11):null; // length("__Packages.") = 11
				
				if (isRegisterClass(tag.actionList))
				{
					DebugModule dm = new DebugModule();
					// C: We actually want the class name here, not the linkage ID.
					dm.name = "<" + __Packages + ".2>";
					// C: We want the class name as the second input argument. Fortunately, we don't
					//    really do anything with the source, so it's okay.
					dm.Text = "Object.registerClass(" + __Packages + ", " + __Packages + ");";
					dm.bitmap = 1;
					
					LineRecord lr = new LineRecord(1, dm);
					
					int startOffset = tag.actionList.getOffset(0);
					dm.addOffset(lr, startOffset);
					
					tag.actionList.insert(startOffset, lr);
					modules.put((int) (SupportClass.Random.NextDouble() * System.Int32.MaxValue), dm);
				}
			}
			
			String[] temp = pool;
			collectActions(tag.actionList);
			pool = temp;
			
			className = null;
		}
예제 #8
0
 public override void offset(int offset, LineRecord lr)
 {
     lines.put(offset, lr);
 }
예제 #9
0
            public override void offset(int offset, LineRecord lr)
			{
				Console.Out.WriteLine("DebugOffset #" + lr.module.id + ":" + lr.lineno + " " + offset);
			}
예제 #10
0
		public virtual void  readTags(DebugHandler handler)
		{
			System.Collections.ArrayList lineRecords = new System.Collections.ArrayList();
			
			do 
			{
				int tag = (int) in_Renamed.readUI32();
				switch (tag)
				{
					
					case kDebugScript: 
						DebugModule m = new DebugModule();
						int id = (int) in_Renamed.readUI32();
						m.id = id;
						m.bitmap = (int) in_Renamed.readUI32();
						m.name = in_Renamed.readString();
						m.Text = in_Renamed.readString();
						
						adjustModuleName(m);
						
						if (modules.contains(id))
						{
							DebugModule m2 = (DebugModule) modules.get_Renamed(id);
							if (!m.Equals(m2))
							{
								handler.error("Module '" + m2.name + "' has the same ID as Module '" + m.name + "'");
								handler.error("Let's check for kDebugOffset that came before Module '" + m2.name + "'");
								handler.error("Before: Number of accumulated line records: " + lineRecords.Count);
								lineRecords = purgeLineRecords(lineRecords, id, handler);
								handler.error("After: Number of accumulated line records: " + lineRecords.Count);
							}
						}
						modules.put(id, m);
						handler.module(m);
						break;
					
					case kDebugOffset: 
						id = (int) in_Renamed.readUI32();
						int lineno = (int) in_Renamed.readUI32();
						DebugModule module = (DebugModule) modules.get_Renamed(id);
						LineRecord lr = new LineRecord(lineno, module);
						int offset = (int) in_Renamed.readUI32();
						
						if (module != null)
						{
							// not corrupted before we add the offset and offset add fails
							bool wasCorrupt = module.corrupt;
							if (!module.addOffset(lr, offset) && !wasCorrupt)
								handler.error(module.name + ":" + lineno + " does not exist for offset " + offset + ", module marked for exclusion from debugging");
							handler.offset(offset, lr);
						}
						else
						{
							lineRecords.Add((System.Int32) id);
							lineRecords.Add(lr);
							lineRecords.Add((System.Int32) offset);
						}
						break;
					
					case kDebugBreakpoint: 
						handler.breakpoint((int) in_Renamed.readUI32());
						break;
					
					case kDebugRegisters: 
					{
						offset = (int) in_Renamed.readUI32();
						int size = in_Renamed.readUI8();
						RegisterRecord r = new RegisterRecord(offset, size);
						for (int i = 0; i < size; i++)
						{
							int nbr = in_Renamed.readUI8();
							String name = in_Renamed.readString();
							r.addRegister(nbr, name);
						}
						handler.registers(offset, r);
						break;
					}
					
					
					case kDebugID: 
						FlashUUID uuid = new FlashUUID();
						in_Renamed.readFully(uuid.bytes);
						handler.uuid(uuid);
						break;
					
					case - 1: 
						break;
					
					default: 
						throw new SwfFormatException("Unexpected tag id " + tag);
					
				}
				
				if (tag == - 1)
				{
					break;
				}
			}
			while (true);
			
			int i2 = 0, size2 = lineRecords.Count;
			while (i2 < size2)
			{
				int id = ((System.Int32) lineRecords[i2]);
				LineRecord lr = (LineRecord) lineRecords[i2 + 1];
				int offset = ((System.Int32) lineRecords[i2 + 2]);
				lr.module = (DebugModule) modules.get_Renamed(id);
				
				if (lr.module != null)
				{
					//System.out.println("updated module "+id+" out of order");
					// not corrupted before we add the offset and offset add fails
					bool wasCorrupt = lr.module.corrupt;
					if (!lr.module.addOffset(lr, offset) && !wasCorrupt)
						handler.error(lr.module.name + ":" + lr.lineno + " does not exist for offset " + offset + ", module marked for exclusion from debugging");
					
					handler.offset(offset, lr);
				}
				else
				{
					handler.error("Could not find debug module (id = " + id + ") for offset = " + offset);
				}
				
				i2 += 3;
			}
		}
예제 #11
0
 public abstract void offset(int offset, LineRecord lr);
예제 #12
0
        public override void offset(int offset, LineRecord lr)
		{
			lines.put(offset, lr);
		}