Пример #1
0
        /// <summary>
        /// Returns the resolved stack call. </summary>
        /// <returns> An array of <seealso cref="NativeStackCallInfo"/> or <code>null</code> if the stack call
        /// was not resolved. </returns>
        /// <seealso cref= #setResolvedStackCall(ArrayList) </seealso>
        /// <seealso cref= #isStackCallResolved() </seealso>
        //[MethodImpl(MethodImplOptions.Synchronized)]

        /// <summary>
        /// Indicates whether some other object is "equal to" this one. </summary>
        /// <param name="obj"> the reference object with which to compare. </param>
        /// <returns> <code>true</code> if this object is equal to the obj argument;
        /// <code>false</code> otherwise. </returns>
        /// <seealso cref= java.lang.Object#equals(java.lang.Object) </seealso>
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            if (obj is NativeAllocationInfo)
            {
                NativeAllocationInfo mi = (NativeAllocationInfo)obj;
                // quick compare of size, alloc, and stackcall size
                if (mSize != mi.mSize || mAllocations != mi.mAllocations || mStackCallAddresses.Count != mi.mStackCallAddresses.Count)
                {
                    return(false);
                }
                // compare the stack addresses
                int count = mStackCallAddresses.Count;
                for (int i = 0; i < count; i++)
                {
                    long a = mStackCallAddresses[i];
                    long b = mi.mStackCallAddresses[i];
                    if (a != b)
                    {
                        return(false);
                    }
                }

                return(true);
            }
            return(false);
        }
Пример #2
0
        /*
         * Handle our native heap data.
         */
        private void handleNHGT(Client client, ByteBuffer data)
        {
            ClientData cd = client.clientData;

            Log.d("ddm-nativeheap", "NHGT: " + data.limit + " bytes");

            // TODO - process incoming data and save in "cd"
            var copy = new byte[data.limit];

            data.get(copy);

            // clear the previous run
            cd.clearNativeAllocationInfo();

            ByteBuffer buffer = ByteBuffer.wrap(copy);

            buffer.order = ByteOrder.LITTLE_ENDIAN;

            //        read the header
            //        typedef struct Header {
            //            uint32_t mapSize;
            //            uint32_t allocSize;
            //            uint32_t allocInfoSize;
            //            uint32_t totalMemory;
            //              uint32_t backtraceSize;
            //        };

            int mapSize       = buffer.getInt();
            int allocSize     = buffer.getInt();
            int allocInfoSize = buffer.getInt();
            int totalMemory   = buffer.getInt();
            int backtraceSize = buffer.getInt();

            Log.d("ddms", "mapSize: " + mapSize);
            Log.d("ddms", "allocSize: " + allocSize);
            Log.d("ddms", "allocInfoSize: " + allocInfoSize);
            Log.d("ddms", "totalMemory: " + totalMemory);

            cd.totalNativeMemory = totalMemory;

            // this means that updates aren't turned on.
            if (allocInfoSize == 0)
            {
                return;
            }

            if (mapSize > 0)
            {
                var maps = new byte[mapSize];
                buffer.get(maps, 0, mapSize);
                parseMaps(cd, maps);
            }

            int iterations = allocSize / allocInfoSize;

            for (int i = 0; i < iterations; i++)
            {
                NativeAllocationInfo info = new NativeAllocationInfo(buffer.getInt(), buffer.getInt()); // allocations -  size

                for (int j = 0; j < backtraceSize; j++)
                {
                    long addr = (buffer.getInt()) & 0x00000000ffffffffL;

                    if (addr == 0x0)
                    {
                        // skip past null addresses
                        continue;
                    }

                    info.addStackCallAddress(addr);
                }

                cd.addNativeAllocation(info);
            }
        }
Пример #3
0
		internal virtual void addNativeAllocation(NativeAllocationInfo allocInfo)
		{
			mNativeAllocationList.Add(allocInfo);
		}
Пример #4
0
 internal virtual void addNativeAllocation(NativeAllocationInfo allocInfo)
 {
     mNativeAllocationList.Add(allocInfo);
 }
Пример #5
0
		/*
		 * Handle our native heap data.
		 */
		private void handleNHGT(Client client, ByteBuffer data)
		{
			ClientData cd = client.clientData;

			Log.d("ddm-nativeheap", "NHGT: " + data.limit + " bytes");

			// TODO - process incoming data and save in "cd"
			var copy = new byte[data.limit];
			data.get(copy);

			// clear the previous run
			cd.clearNativeAllocationInfo();

			ByteBuffer buffer = ByteBuffer.wrap(copy);
			buffer.order = ByteOrder.LITTLE_ENDIAN;

	//        read the header
	//        typedef struct Header {
	//            uint32_t mapSize;
	//            uint32_t allocSize;
	//            uint32_t allocInfoSize;
	//            uint32_t totalMemory;
	//              uint32_t backtraceSize;
	//        };

			int mapSize = buffer.getInt();
            int allocSize = buffer.getInt();
            int allocInfoSize = buffer.getInt();
            int totalMemory = buffer.getInt();
            int backtraceSize = buffer.getInt();

			Log.d("ddms", "mapSize: " + mapSize);
			Log.d("ddms", "allocSize: " + allocSize);
			Log.d("ddms", "allocInfoSize: " + allocInfoSize);
			Log.d("ddms", "totalMemory: " + totalMemory);

			cd.totalNativeMemory = totalMemory;

			// this means that updates aren't turned on.
			if (allocInfoSize == 0)
			{
			  return;
			}

			if (mapSize > 0)
			{
				var maps = new byte[mapSize];
				buffer.get(maps, 0, mapSize);
				parseMaps(cd, maps);
			}

			int iterations = allocSize / allocInfoSize;

			for (int i = 0 ; i < iterations ; i++)
			{
                NativeAllocationInfo info = new NativeAllocationInfo(buffer.getInt(), buffer.getInt()); // allocations -  size

				for (int j = 0 ; j < backtraceSize ; j++)
				{
                    long addr = (buffer.getInt()) & 0x00000000ffffffffL;

					if (addr == 0x0)
					{
						// skip past null addresses
						continue;
					}

					info.addStackCallAddress(addr);
				}

				cd.addNativeAllocation(info);
			}
		}