Ejemplo n.º 1
0
    HRESULT FormatPointer( IValueBinder* binder, const DataObject& objVal, std::wstring& outStr )
    {
        _ASSERT( objVal._Type->IsPointer() );

        HRESULT hr = S_OK;
        RefPtr<Type>    pointed = objVal._Type->AsTypeNext()->GetNext();

        hr = FormatAddress( objVal.Value.Addr, objVal._Type, outStr );
        if ( FAILED( hr ) )
            return hr;

        if ( pointed->IsChar() )
        {
            bool    foundTerm = false;

            outStr.append( L" \"" );

            FormatString( binder, objVal.Value.Addr, pointed->GetSize(), false, 0, outStr, foundTerm );
            // don't worry about an error here, we still want to show the address

            if ( foundTerm )
                outStr.append( 1, L'"' );
        }

        return S_OK;
    }
Ejemplo n.º 2
0
//===========================================================================
const char* GetSymbol (WORD nAddress, int nBytes)
{
	const char* pSymbol = FindSymbolFromAddress( nAddress );
	if (pSymbol)
		return pSymbol;

	return FormatAddress( nAddress, nBytes );
}
Ejemplo n.º 3
0
    HRESULT FormatDArray( IValueBinder* binder, DArray array, Type* type, int radix, std::wstring& outStr )
    {
        _ASSERT( type->IsDArray() );

        HRESULT         hr = S_OK;
        ITypeDArray*    arrayType = type->AsTypeDArray();

        if ( arrayType == NULL )
            return E_FAIL;

        outStr.append( L"{length=" );

        hr = FormatInt( array.Length, arrayType->GetLengthType(), radix, outStr );
        if ( FAILED( hr ) )
            return hr;

        if ( !arrayType->GetElement()->IsChar() )
        {
            outStr.append( L" ptr=" );

            hr = FormatAddress( array.Addr, arrayType->GetPointerType(), outStr );
            if ( FAILED( hr ) )
                return hr;
        }

        if ( arrayType->GetElement()->IsChar() )
        {
            bool        foundTerm = true;
            uint32_t    len = MaxStringLen;

            // cap it somewhere under the range of a long
            // do it this way, otherwise only truncating could leave us with a tiny array
            // which would not be useful

            if ( array.Length < MaxStringLen )
                len = (uint32_t) array.Length;

            outStr.append( L" \"" );

            FormatString( 
                binder, 
                array.Addr, 
                arrayType->GetElement()->GetSize(),
                true,
                len,
                outStr,
                foundTerm );

            outStr.append( 1, L'"' );
        }

        outStr.append( 1, L'}' );

        return S_OK;
    }
Ejemplo n.º 4
0
    HRESULT StackFrame::AppendFunctionNameWithAddress( 
        FRAMEINFO_FLAGS flags, 
        UINT radix, 
        CString& fullName )
    {
        wchar_t addrStr[MaxAddrStringLength + 1] = L"";

        FormatAddress( addrStr, _countof( addrStr ), mPC, mPtrSize, false );

        fullName.Append( addrStr );

        return S_OK;
    }
Ejemplo n.º 5
0
static void dump_addrinfo(struct addrinfo const * p_info, const char * file, unsigned int line)
{
    char host[NI_MAXHOST] = { 0 };
    FormatAddress(p_info->ai_addr, p_info->ai_addrlen, host, NI_MAXHOST);
    debug_outputln("%s %4.4u : flg:%d fam:%d sot:%d pro:%d can:%s hst:'%15s' nxt:%p", file, line,
        p_info->ai_flags,
        p_info->ai_family,
        p_info->ai_socktype,
        p_info->ai_protocol,
        p_info->ai_canonname,
        host,
        p_info->ai_next);
}
Ejemplo n.º 6
0
void LuaHostWindows::Detail::Poll()
{
	fd_set readfds;
	FD_ZERO(&readfds);
	FD_SET(m_serverSocket, &readfds);

	if(m_debuggerSocket != SOCKET_ERROR)
		FD_SET(m_debuggerSocket, &readfds);

	timeval timeout;
	timeout.tv_sec = 0;
	timeout.tv_usec = 0;
	int count = select(0, &readfds, NULL, NULL, &timeout);

	if(count == SOCKET_ERROR)
		error("select() failed (error %d)", SocketError);

	else if(count >= 1)
	{
		if(FD_ISSET(m_debuggerSocket, &readfds) && m_debuggerSocket != SOCKET_ERROR)
		{
			int bytes = recv(m_debuggerSocket, (char *) m_netBuffer, m_netBufferSize, 0);
			if(bytes == 0)
				Close();
			else if(bytes == SOCKET_ERROR)
			{
				warn("recv() failed (error %d)", SocketError);
				Close();
			}
			else
			{
				m_debuggerComms->Receive(m_netBuffer, bytes);
			}
		}

		if(FD_ISSET(m_serverSocket, &readfds) && m_debuggerSocket == SOCKET_ERROR && !m_debuggerComms->GetDebugger()->IsConnected())
		{
			sockaddr_in address;
			socklen_t addressLen = sizeof(address);
			m_debuggerSocket = accept(m_serverSocket, (sockaddr *) &address, &addressLen);

			if(m_debuggerSocket == SOCKET_ERROR)
				error ("accept() failed (error %d)", SocketError);

			print("Connection accepted from %s!\n", FormatAddress(address));

			m_debuggerComms->Open();
		}
	}
}
Ejemplo n.º 7
0
//
// Function: PrintInterfaceList
//
// Description:
//    This function prints all local IP interfaces.
//
void PrintInterfaceList()
{
    SOCKET_ADDRESS_LIST *slist=NULL;
    SOCKET               s = INVALID_SOCKET;
    char                *buf=NULL;
    DWORD                dwBytesRet = 0;
    int                  rc = 0,
    i  = 0, j = 0, k = 0;

    k = 0;
    for (i=0; i < sizeof(g_iFamilyMap)/sizeof(int) ;i++)
    {
        s = socket(g_iFamilyMap[i], SOCK_STREAM, 0);
        if (s != INVALID_SOCKET)
        {
            rc = WSAIoctl(
                         s, 
                         SIO_ADDRESS_LIST_QUERY, 
                         NULL, 
                         0, 
                         NULL, 
                         0,
                         &dwBytesRet, 
                         NULL, 
                         NULL
                         );
            if ((rc == SOCKET_ERROR) && (GetLastError() == WSAEFAULT))
            {
                char addrbuf[INET6_ADDRSTRLEN] = {'\0'};

                // Allocate the necessary size
                buf = (char *)HeapAlloc(GetProcessHeap(), 0, dwBytesRet);
                if (buf == NULL)
                {
                    if(INVALID_SOCKET != s)
                    {
                        closesocket(s);
                        s = INVALID_SOCKET;
                    }
                    
                    return;
                }

                rc = WSAIoctl(
                             s, 
                             SIO_ADDRESS_LIST_QUERY, 
                             NULL, 
                             0, 
                             buf, 
                             dwBytesRet, 
                             &dwBytesRet, 
                             NULL, 
                             NULL
                             );
                if (rc == SOCKET_ERROR)
                {
                    if (buf) HeapFree(GetProcessHeap(), 0, buf);
                    if (INVALID_SOCKET != s)
                    {
                        closesocket(s);
                        s = INVALID_SOCKET;
                    }
                    return;
                }

                // Display the addresses
                slist = (SOCKET_ADDRESS_LIST *)buf;
                for (j=0; j < slist->iAddressCount ;j++)
                {
                    FormatAddress(
                                 slist->Address[j].lpSockaddr,
                                 slist->Address[j].iSockaddrLength,
                                 addrbuf,
                                 INET6_ADDRSTRLEN
                                 );
                    printf("               %-2d ........ %s\n", 
                           ++k, addrbuf);
                }

                if(buf) HeapFree(GetProcessHeap(), 0, buf);

            } else
            {
                // Unexpected failure
                fprintf(stderr, "WSAIoctl: SIO_ADDRESS_LIST_QUERY failed with unexpected error: %d\n",
                        WSAGetLastError());
            }
            if (INVALID_SOCKET != s)
            {
                closesocket(s);
                s = INVALID_SOCKET;
            }
        } else
        {
            fprintf(stderr, "socket failed: %d\n", WSAGetLastError());
            return;
        }
    }
    return;
}
Ejemplo n.º 8
0
 HRESULT FormatAArray( Address addr, Type* type, int radix, std::wstring& outStr )
 {
     _ASSERT( type->IsAArray() );
     UNREFERENCED_PARAMETER( radix );
     return FormatAddress( addr, type, outStr );
 }