VirtualBox

Changeset 81040 in vbox


Ignore:
Timestamp:
Sep 27, 2019 9:45:46 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
133643
Message:

Additions/VBoxClient: Revamped and unified local logging infrastructure; cleaned up a lot of different logging styles / ways. Fixed logging memory leaks.

Location:
trunk/src/VBox/Additions/x11/VBoxClient
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/VBoxClient.h

    r76563 r81040  
    2727#include <iprt/string.h>
    2828
    29 /** Exit with a fatal error. */
    30 #define VBClFatalError(format) \
    31 do { \
    32     char *pszMessage = RTStrAPrintf2 format; \
    33     LogRel(format); \
    34     vbclFatalError(pszMessage); \
    35 } while(0)
    36 
    37 /** Exit with a fatal error. */
    38 extern DECLNORETURN(void) vbclFatalError(char *pszMessage);
     29void VBClLogInfo(const char *pszFormat, ...);
     30void VBClLogError(const char *pszFormat, ...);
     31void VBClLogFatalError(const char *pszFormat, ...);
    3932
    4033/** Call clean-up for the current service and exit. */
  • trunk/src/VBox/Additions/x11/VBoxClient/clipboard.cpp

    r81028 r81040  
    7070    LogRelFlowFunc(("u32Format=%d, pv=%p, cb=%d\n", u32Format, pv, cb));
    7171    rc = VbglR3ClipboardWriteData(g_ctx.client, u32Format, pv, cb);
    72     LogRelFlowFunc(("rc=%Rrc\n", rc));
     72    LogRelFlowFuncLeaveRC(rc);
    7373    return rc;
    7474}
     
    8888int ClipRequestDataForX11(SHCLCONTEXT *pCtx, uint32_t u32Format, void **ppv, uint32_t *pcb)
    8989{
    90     RT_NOREF1(pCtx);
     90    RT_NOREF(pCtx);
    9191    int rc = VINF_SUCCESS;
    9292    uint32_t cb = 1024;
     
    127127            RTMemFree(pv);
    128128    }
    129     LogRelFlowFunc(("returning %Rrc\n", rc));
     129    LogRelFlowFuncLeaveRC(rc);
    130130    if (RT_SUCCESS(rc))
    131131        LogRelFlow(("    *pcb=%d\n", *pcb));
     
    150150void ClipReportX11Formats(SHCLCONTEXT *pCtx, uint32_t u32Formats)
    151151{
    152     RT_NOREF1(pCtx);
     152    RT_NOREF(pCtx);
    153153    LogRelFlowFunc(("u32Formats=%d\n", u32Formats));
    154154    int rc = VbglR3ClipboardFormatsReport(g_ctx.client, u32Formats);
    155     LogRelFlowFunc(("rc=%Rrc\n", rc));
     155    LogRelFlowFuncLeaveRC(rc);
    156156}
    157157
     
    168168void ClipRequestFromX11CompleteCallback(SHCLCONTEXT *pCtx, int rc, CLIPREADCBREQ *pReq, void *pv, uint32_t cb)
    169169{
    170     RT_NOREF1(pCtx);
     170    RT_NOREF(pCtx);
    171171    if (RT_SUCCESS(rc))
    172172        vboxClipboardSendData(pReq->u32Format, pv, cb);
     
    197197        rc = VbglR3ClipboardConnect(&g_ctx.client);
    198198        if (RT_FAILURE(rc))
    199             LogRel(("Error connecting to host. rc=%Rrc\n", rc));
     199            VBClLogError("Error connecting to host, rc=%Rrc\n", rc);
    200200        else if (!g_ctx.client)
    201201        {
    202             LogRel(("Invalid client ID of 0\n"));
     202            VBClLogError("Invalid client ID of 0\n");
    203203            rc = VERR_NOT_SUPPORTED;
    204204        }
     
    207207    if (rc != VINF_SUCCESS && g_ctx.pBackend)
    208208        ClipDestructX11(g_ctx.pBackend);
    209     LogRelFlowFunc(("g_ctx.client=%u rc=%Rrc\n", g_ctx.client, rc));
     209
     210    LogRelFlowFuncLeaveRC(rc);
    210211    return rc;
    211212}
     
    271272
    272273                default:
    273                     LogRel2(("Unsupported message from host!!!\n"));
     274                {
     275                    VBClLogInfo("Unsupported message from host (%RU32)\n", Msg);
     276                    break;
     277                }
    274278            }
    275279        }
     
    277281        LogRelFlow(("processed host event rc = %d\n", rc));
    278282    }
    279     LogRelFlowFunc(("rc=%d\n", rc));
     283    LogRelFlowFuncLeaveRC(rc);
    280284    return rc;
    281285}
     
    288292static int run(struct VBCLSERVICE **ppInterface, bool fDaemonised)
    289293{
    290     RT_NOREF2(ppInterface, fDaemonised);
     294    RT_NOREF(ppInterface, fDaemonised);
    291295
    292296    /* Initialise the guest library. */
     
    327331
    328332    if (!pService)
    329         VBClFatalError(("Out of memory\n"));
     333        VBClLogFatalError("Out of memory\n");
    330334    pService->pInterface = &vbclClipboardInterface;
    331335    return &pService->pInterface;
  • trunk/src/VBox/Additions/x11/VBoxClient/display-svga-x11.cpp

    r81028 r81040  
    6363
    6464    if (uname(&name) == -1)
    65         VBClFatalError(("Failed to get kernel name.\n"));
     65        VBClLogFatalError("Failed to get kernel name\n");
    6666    if (strcmp(name.sysname, "Linux"))
    6767        return false;
     
    8181
    8282    if (pContext->pDisplay != NULL)
    83         VBClFatalError(("%s called with bad argument\n", __func__));
     83        VBClLogFatalError("%s called with bad argument\n", __func__);
    8484    pContext->pDisplay = XOpenDisplay(NULL);
    8585    if (pContext->pDisplay == NULL)
     
    156156        _XFlush(pContext->pDisplay);
    157157    if (pContext->pDisplay->bufptr + cb > pContext->pDisplay->bufmax)
    158         VBClFatalError(("%s display buffer overflow.\n", __func__));
     158        VBClLogFatalError("%s display buffer overflow\n", __func__);
    159159    if (cb % 4 != 0)
    160         VBClFatalError(("%s bad parameter.\n", __func__));
     160        VBClLogFatalError("%s bad parameter\n", __func__);
    161161    pContext->pDisplay->last_req = pContext->pDisplay->bufptr;
    162162    *ppReq = (struct X11REQHEADER *)pContext->pDisplay->bufptr;
     
    178178
    179179    if (!VALID_PTR(pContext->pDisplay))
    180         VBClFatalError(("%s bad display argument.\n", __func__));
     180        VBClLogFatalError("%s bad display argument\n", __func__);
    181181    if (cRects == 0)
    182182        return;
     
    205205        return;
    206206    /* What now? */
    207     VBClFatalError(("%s failed to set resolution\n", __func__));
     207    VBClLogFatalError("%s failed to set resolution\n", __func__);
    208208}
    209209
     
    215215
    216216    if (!VALID_PTR(pContext->pDisplay))
    217         VBClFatalError(("%s bad display argument.\n", __func__));
     217        VBClLogFatalError("%s bad display argument\n", __func__);
    218218    x11GetRequest(pContext, pContext->hRandRMajor, X11_RANDR_GET_SCREEN_REQUEST,
    219219                    sizeof(struct X11RANDRGETSCREENREQ),
     
    222222    _XSend(pContext->pDisplay, NULL, 0);
    223223    if (!_XReply(pContext->pDisplay, (xReply *)&repGetScreen, 0, xTrue))
    224         VBClFatalError(("%s failed to set resolution\n", __func__));
     224        VBClLogFatalError("%s failed to set resolution\n", __func__);
    225225}
    226226
     
    247247    rc = VbglR3CtlFilterMask(VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, 0);
    248248    if (RT_FAILURE(rc))
    249         VBClFatalError(("Failed to request display change events, rc=%Rrc\n", rc));
     249        VBClLogFatalError("Failed to request display change events, rc=%Rrc\n", rc);
    250250    rc = VbglR3AcquireGuestCaps(VMMDEV_GUEST_SUPPORTS_GRAPHICS, 0, false);
    251251    if (rc == VERR_RESOURCE_BUSY)  /* Someone else has already acquired it. */
    252252        return VINF_SUCCESS;
    253253    if (RT_FAILURE(rc))
    254         VBClFatalError(("Failed to register resizing support, rc=%Rrc\n", rc));
     254        VBClLogFatalError("Failed to register resizing support, rc=%Rrc\n", rc);
    255255    for (;;)
    256256    {
     
    263263        rc = VbglR3GetDisplayChangeRequestMulti(VMW_MAX_HEADS, &cDisplaysOut, aDisplays, true);
    264264        if (RT_FAILURE(rc))
    265             VBClFatalError(("Failed to get display change request, rc=%Rrc\n", rc));
     265            VBClLogFatalError("Failed to get display change request, rc=%Rrc\n", rc);
    266266        if (cDisplaysOut > VMW_MAX_HEADS)
    267             VBClFatalError(("Display change request contained, rc=%Rrc\n", rc));
     267            VBClLogFatalError("Display change request contained, rc=%Rrc\n", rc);
    268268        for (i = 0, cHeads = 0; i < cDisplaysOut && i < VMW_MAX_HEADS; ++i)
    269269        {
     
    289289        rc = VbglR3WaitEvent(VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, RT_INDEFINITE_WAIT, &events);
    290290        if (RT_FAILURE(rc))
    291             VBClFatalError(("Failure waiting for event, rc=%Rrc\n", rc));
     291            VBClLogFatalError("Failure waiting for event, rc=%Rrc\n", rc);
    292292    }
    293293}
  • trunk/src/VBox/Additions/x11/VBoxClient/display-svga.cpp

    r81028 r81040  
    102102
    103103    if (pContext->hDevice != NIL_RTFILE)
    104         VBClFatalError(("%s called with bad argument\n", __func__));
     104        VBClLogFatalError("%s called with bad argument\n", __func__);
    105105    /* Try to open the SVGA DRM device. */
    106106    for (i = 0; i < 128; ++i)
     
    121121            rc = RTStrPrintf(szPath, sizeof(szPath), "/dev/dri/controlD%u", i / 2 + 64);
    122122        if (RT_FAILURE(rc))
    123             VBClFatalError(("RTStrPrintf of device path failed, rc=%Rrc\n", rc));
     123            VBClLogFatalError("RTStrPrintf of device path failed, rc=%Rrc\n", rc);
    124124        rc = RTFileOpen(&hDevice, szPath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    125125        if (RT_FAILURE(rc))
     
    158158
    159159    if (pContext->hDevice == NIL_RTFILE)
    160         VBClFatalError(("%s bad device argument.\n", __func__));
     160        VBClLogFatalError("%s bad device argument\n", __func__);
    161161    ioctlLayout.cOutputs = cHeads;
    162162    ioctlLayout.ptrRects = (uint64_t)paRects;
     
    164164                     &ioctlLayout, sizeof(ioctlLayout), NULL);
    165165    if (RT_FAILURE(rc) && rc != VERR_INVALID_PARAMETER)
    166         VBClFatalError(("Failure updating layout, rc=%Rrc\n", rc));
     166        VBClLogFatalError("Failure updating layout, rc=%Rrc\n", rc);
    167167}
    168168
     
    190190    rc = VbglR3CtlFilterMask(VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, 0);
    191191    if (RT_FAILURE(rc))
    192         VBClFatalError(("Failed to request display change events, rc=%Rrc\n", rc));
     192        VBClLogFatalError("Failed to request display change events, rc=%Rrc\n", rc);
    193193    rc = VbglR3AcquireGuestCaps(VMMDEV_GUEST_SUPPORTS_GRAPHICS, 0, false);
    194194    if (rc == VERR_RESOURCE_BUSY)  /* Someone else has already acquired it. */
    195195        return VINF_SUCCESS;
    196196    if (RT_FAILURE(rc))
    197         VBClFatalError(("Failed to register resizing support, rc=%Rrc\n", rc));
     197        VBClLogFatalError("Failed to register resizing support, rc=%Rrc\n", rc);
    198198    for (;;)
    199199    {
     
    207207        fAck = true;
    208208        if (RT_FAILURE(rc))
    209             VBClFatalError(("Failed to get display change request, rc=%Rrc\n", rc));
     209            VBClLogFatalError("Failed to get display change request, rc=%Rrc\n", rc);
    210210        if (cDisplaysOut > VMW_MAX_HEADS)
    211             VBClFatalError(("Display change request contained, rc=%Rrc\n", rc));
     211            VBClLogFatalError("Display change request contained, rc=%Rrc\n", rc);
    212212        for (i = 0, cHeads = 0; i < cDisplaysOut && i < VMW_MAX_HEADS; ++i)
    213213        {
     
    233233        rc = VbglR3WaitEvent(VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, RT_INDEFINITE_WAIT, &events);
    234234        if (RT_FAILURE(rc))
    235             VBClFatalError(("Failure waiting for event, rc=%Rrc\n", rc));
     235            VBClLogFatalError("Failure waiting for event, rc=%Rrc\n", rc);
    236236    }
    237237}
  • trunk/src/VBox/Additions/x11/VBoxClient/display.cpp

    r76553 r81040  
    214214    status = system(pState->pcszXrandr);
    215215    if (WEXITSTATUS(status) != 0)  /* Utility or extension not available. */
    216         VBClFatalError(("Failed to execute the xrandr utility.\n"));
     216        VBClLogFatalError("Failed to execute the xrandr utility\n");
    217217    RTStrPrintf(szCommand, sizeof(szCommand), "%s --q12", pState->pcszXrandr);
    218218    status = system(szCommand);
     
    231231    struct DISPLAYSTATE *pSelf = (struct DISPLAYSTATE *)ppInterface;
    232232    if (pSelf->magic != DISPLAYSTATE_MAGIC)
    233         VBClFatalError(("Bad display service object!\n"));
     233        VBClLogFatalError("Bad display service object!\n");
    234234    return pSelf;
    235235}
     
    274274
    275275    if (!pService)
    276         VBClFatalError(("Out of memory\n"));
     276        VBClLogFatalError("Out of memory\n");
    277277    pService->pInterface = &vbclDisplayInterface;
    278278    pService->magic = DISPLAYSTATE_MAGIC;
  • trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp

    r81028 r81040  
    523523    void uninit(void);
    524524    void reset(void);
    525 
    526     /* Logging. */
    527     VBOX_DND_FN_DECL_LOG(void) logInfo(const char *pszFormat, ...);
    528     VBOX_DND_FN_DECL_LOG(void) logError(const char *pszFormat, ...);
    529525
    530526    /* X11 message processing. */
     
    860856        if (!m_wndProxy.hWnd)
    861857        {
    862             LogRel(("DnD: Error creating proxy window\n"));
     858            VBClLogError("Error creating proxy window\n");
    863859            rc = VERR_GENERAL_FAILURE;
    864860            break;
     
    868864        if (RT_FAILURE(rc))
    869865        {
    870             LogRel(("DnD: Error initializing proxy window, rc=%Rrc\n", rc));
     866            VBClLogError("Error initializing proxy window, rc=%Rrc\n", rc);
    871867            break;
    872868        }
     
    878874        XFlush(m_pDisplay);
    879875#endif
    880         logInfo("Proxy window=%RU32, root window=%RU32 ...\n", m_wndProxy.hWnd, m_wndRoot);
     876        VBClLogInfo("Proxy window=%RU32, root window=%RU32 ...\n", m_wndProxy.hWnd, m_wndRoot);
    881877
    882878        /* Set the window's name for easier lookup. */
     
    894890    }
    895891    else
    896         logError("Initializing drag instance for screen %RU32 failed with rc=%Rrc\n", uScreenID, rc);
     892        VBClLogError("Initializing drag instance for screen %RU32 failed with rc=%Rrc\n", uScreenID, rc);
    897893
    898894    LogFlowFuncLeaveRC(rc);
    899895    return rc;
    900 }
    901 
    902 /**
    903  * Logs an error message to the (release) logging instance.
    904  *
    905  * @param   pszFormat               Format string to log.
    906  */
    907 VBOX_DND_FN_DECL_LOG(void) DragInstance::logError(const char *pszFormat, ...)
    908 {
    909     va_list args;
    910     va_start(args, pszFormat);
    911     char *psz = NULL;
    912     RTStrAPrintfV(&psz, pszFormat, args);
    913     va_end(args);
    914 
    915     AssertPtr(psz);
    916     LogFlowFunc(("%s", psz));
    917     LogRel(("DnD: %s", psz));
    918 
    919     RTStrFree(psz);
    920 }
    921 
    922 /**
    923  * Logs an info message to the (release) logging instance.
    924  *
    925  * @param   pszFormat               Format string to log.
    926  */
    927 VBOX_DND_FN_DECL_LOG(void) DragInstance::logInfo(const char *pszFormat, ...)
    928 {
    929     va_list args;
    930     va_start(args, pszFormat);
    931     char *psz = NULL;
    932     RTStrAPrintfV(&psz, pszFormat, args);
    933     va_end(args);
    934 
    935     AssertPtr(psz);
    936     LogFlowFunc(("%s", psz));
    937     LogRel2(("DnD: %s", psz));
    938 
    939     RTStrFree(psz);
    940896}
    941897
     
    11541110                                     False /* Propagate */, NoEventMask, reinterpret_cast<XEvent *>(&m));
    11551111                if (xRc == 0)
    1156                     logError("Error sending position XA_XdndStatus event to current window=%#x: %s\n",
    1157                               m_wndCur, gX11->xErrorToString(xRc).c_str());
     1112                    VBClLogError("Error sending position XA_XdndStatus event to current window=%#x: %s\n",
     1113                                 m_wndCur, gX11->xErrorToString(xRc).c_str());
    11581114            }
    11591115            else if (   e.xclient.message_type == xAtom(XA_XdndLeave)
     
    11611117            {
    11621118                LogFlowThisFunc(("XA_XdndLeave\n"));
    1163                 logInfo("Guest to host transfer canceled by the guest source window\n");
     1119                VBClLogInfo("Guest to host transfer canceled by the guest source window\n");
    11641120
    11651121                /* Start over. */
     
    11741130                {
    11751131                    /* Can occur when dragging from guest->host, but then back in to the guest again. */
    1176                     logInfo("Could not drop on own proxy window\n"); /* Not fatal. */
     1132                    VBClLogInfo("Could not drop on own proxy window\n"); /* Not fatal. */
    11771133
    11781134                    /* Let the source know. */
     
    11891145            else /* Unhandled event, abort. */
    11901146            {
    1191                 logInfo("Unhandled event from wnd=%#x, msg=%s\n", e.xclient.window, xAtomToString(e.xclient.message_type).c_str());
     1147                VBClLogInfo("Unhandled event from wnd=%#x, msg=%s\n", e.xclient.window, xAtomToString(e.xclient.message_type).c_str());
    11921148
    11931149                /* Let the source know. */
     
    13351291            if (pReq->target == xAtom(XA_TARGETS))
    13361292            {
    1337                 logInfo("Target window %#x ('%s') asking for target list\n", e.xselectionrequest.requestor, pszWndName);
     1293                VBClLogInfo("Target window %#x ('%s') asking for target list\n", e.xselectionrequest.requestor, pszWndName);
    13381294
    13391295                /* If so, set the window property with the formats on the requestor
     
    13461302            else if (m_lstFormats.contains(pReq->target))
    13471303            {
    1348                 logInfo("Target window %#x ('%s') is asking for data as '%s'\n",
    1349                          pReq->requestor, pszWndName, xAtomToString(pReq->target).c_str());
     1304                VBClLogInfo("Target window %#x ('%s') is asking for data as '%s'\n",
     1305                            pReq->requestor, pszWndName, xAtomToString(pReq->target).c_str());
    13501306
    13511307                /* Did we not drop our stuff to the guest yet? Bail out. */
     
    13601316                    RTCString strFormat = xAtomToString(pReq->target);
    13611317                    Assert(strFormat.isNotEmpty());
    1362                     logInfo("Target window=%#x requested data from host as '%s', rc=%Rrc\n",
    1363                             pReq->requestor, strFormat.c_str(), rc);
     1318                    VBClLogInfo("Target window=%#x requested data from host as '%s', rc=%Rrc\n",
     1319                                pReq->requestor, strFormat.c_str(), rc);
    13641320
    13651321                    /* Make a copy of the MIME data to be passed back. The X server will be become
     
    13881344            else
    13891345            {
    1390                 logError("Refusing unknown command/format '%s' of wnd=%#x ('%s')\n",
    1391                          xAtomToString(e.xselectionrequest.target).c_str(), pReq->requestor, pszWndName);
     1346                VBClLogError("Refusing unknown command/format '%s' of wnd=%#x ('%s')\n",
     1347                             xAtomToString(e.xselectionrequest.target).c_str(), pReq->requestor, pszWndName);
    13921348                rc = VERR_NOT_SUPPORTED;
    13931349            }
     
    13991355            int xRc = XSendEvent(pReq->display, pReq->requestor, True /* Propagate */, 0, &s);
    14001356            if (xRc == 0)
    1401                 logError("Error sending SelectionNotify(1) event to wnd=%#x: %s\n", pReq->requestor,
    1402                          gX11->xErrorToString(xRc).c_str());
     1357                VBClLogError("Error sending SelectionNotify(1) event to wnd=%#x: %s\n", pReq->requestor,
     1358                             gX11->xErrorToString(xRc).c_str());
    14031359            XFlush(pReq->display);
    14041360
     
    17491705        if (xRc != Success)
    17501706        {
    1751             logError("Error getting properties of cursor window=%#x: %s\n", wndCursor, gX11->xErrorToString(xRc).c_str());
     1707            VBClLogError("Error getting properties of cursor window=%#x: %s\n", wndCursor, gX11->xErrorToString(xRc).c_str());
    17521708        }
    17531709        else
     
    17561712            {
    17571713                /** @todo Do we need to deal with this? */
    1758                 logError("Wrong window properties for window %#x: pcData=%#x, iFmt=%d, cItems=%ul\n",
    1759                          wndCursor, pcData, fmt, cItems);
     1714                VBClLogError("Wrong window properties for window %#x: pcData=%#x, iFmt=%d, cItems=%ul\n",
     1715                             wndCursor, pcData, fmt, cItems);
    17601716            }
    17611717            else
     
    17891745        char *pszWndName = wndX11GetNameA(m_wndCur);
    17901746        AssertPtr(pszWndName);
    1791         logInfo("Left old window %#x ('%s'), Xdnd version=%ld\n", m_wndCur, pszWndName, newVer);
     1747        VBClLogInfo("Left old window %#x ('%s'), Xdnd version=%ld\n", m_wndCur, pszWndName, newVer);
    17921748        RTStrFree(pszWndName);
    17931749
     
    18041760        xRc = XSendEvent(m_pDisplay, m_wndCur, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
    18051761        if (xRc == 0)
    1806             logError("Error sending XA_XdndLeave event to old window=%#x: %s\n", m_wndCur, gX11->xErrorToString(xRc).c_str());
     1762            VBClLogError("Error sending XA_XdndLeave event to old window=%#x: %s\n", m_wndCur, gX11->xErrorToString(xRc).c_str());
    18071763
    18081764        /* Reset our current window. */
     
    18211777        char *pszWndName = wndX11GetNameA(wndCursor);
    18221778        AssertPtr(pszWndName);
    1823         logInfo("Entered new window %#x ('%s'), supports Xdnd version=%ld\n", wndCursor, pszWndName, newVer);
     1779        VBClLogInfo("Entered new window %#x ('%s'), supports Xdnd version=%ld\n", wndCursor, pszWndName, newVer);
    18241780        RTStrFree(pszWndName);
    18251781
     
    18511807        xRc = XSendEvent(m_pDisplay, wndCursor, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
    18521808        if (xRc == 0)
    1853             logError("Error sending XA_XdndEnter event to window=%#x: %s\n", wndCursor, gX11->xErrorToString(xRc).c_str());
     1809            VBClLogError("Error sending XA_XdndEnter event to window=%#x: %s\n", wndCursor, gX11->xErrorToString(xRc).c_str());
    18541810    }
    18551811
     
    18801836        xRc = XSendEvent(m_pDisplay, wndCursor, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
    18811837        if (xRc == 0)
    1882             logError("Error sending XA_XdndPosition event to current window=%#x: %s\n", wndCursor, gX11->xErrorToString(xRc).c_str());
     1838            VBClLogError("Error sending XA_XdndPosition event to current window=%#x: %s\n", wndCursor, gX11->xErrorToString(xRc).c_str());
    18831839    }
    18841840
     
    19331889
    19341890    int rc = VbglR3DnDHGSendReqData(&m_dndCtx, szFormat);
    1935     logInfo("Drop event from host resulted in: %Rrc\n", rc);
     1891    VBClLogInfo("Drop event from host resulted in: %Rrc\n", rc);
    19361892
    19371893    LogFlowFuncLeaveRC(rc);
     
    19721928     * be on the guest, so proceed working on communicating with the target window.
    19731929     */
    1974     logInfo("Received %RU32 bytes of URI list meta data from host\n", cbData);
     1930    VBClLogInfo("Received %RU32 bytes of URI list meta data from host\n", cbData);
    19751931
    19761932    /* Destroy any old data. */
     
    20171973    int xRc = XSendEvent(m_pDisplay, m_wndCur, False /* Propagate */, NoEventMask, reinterpret_cast<XEvent*>(&m));
    20181974    if (xRc == 0)
    2019         logError("Error sending XA_XdndDrop event to window=%#x: %s\n", m_wndCur, gX11->xErrorToString(xRc).c_str());
     1975        VBClLogError("Error sending XA_XdndDrop event to window=%#x: %s\n", m_wndCur, gX11->xErrorToString(xRc).c_str());
    20201976    XFlush(m_pDisplay);
    20211977
     
    20972053            char *pszWndName = wndX11GetNameA(wndSelection);
    20982054            AssertPtr(pszWndName);
    2099             logInfo("New guest source window %#x ('%s')\n", wndSelection, pszWndName);
     2055            VBClLogInfo("New guest source window %#x ('%s')\n", wndSelection, pszWndName);
    21002056
    21012057            /* Start over. */
     
    21412097                    if (fWaitFailed)
    21422098                    {
    2143                         logError("Error mapping proxy window to guest source window %#x ('%s'), rc=%Rrc\n",
    2144                                  wndSelection, pszWndName, rc);
     2099                        VBClLogError("Error mapping proxy window to guest source window %#x ('%s'), rc=%Rrc\n",
     2100                                     wndSelection, pszWndName, rc);
    21452101
    21462102                        /* Reset the counter in any case. */
     
    21532109        }
    21542110        else
    2155             logInfo("No guest source window\n");
     2111            VBClLogInfo("No guest source window\n");
    21562112    }
    21572113
     
    21822138    if (RT_FAILURE(rc2))
    21832139    {
    2184         logError("Error reporting pending drag and drop operation status to host: %Rrc\n", rc2);
     2140        VBClLogError("Error reporting pending drag and drop operation status to host: %Rrc\n", rc2);
    21852141        if (RT_SUCCESS(rc))
    21862142            rc = rc2;
     
    22942250                                             &aPropType, &iPropFormat, &cItems, &cbRemaining, &pcData);
    22952251                if (xRc != Success)
    2296                     logError("Error getting XA_XdndSelection property of proxy window=%#x: %s\n",
    2297                              m_wndProxy.hWnd, gX11->xErrorToString(xRc).c_str());
     2252                    VBClLogError("Error getting XA_XdndSelection property of proxy window=%#x: %s\n",
     2253                                 m_wndProxy.hWnd, gX11->xErrorToString(xRc).c_str());
    22982254
    22992255                LogFlowThisFunc(("strType=%s, iPropFormat=%d, cItems=%RU32, cbRemaining=%RU32\n",
     
    23482304                        AssertMsgFailed(("Incremental transfers are not supported yet\n"));
    23492305
    2350                         logError("Incremental transfers are not supported yet\n");
     2306                        VBClLogError("Incremental transfers are not supported yet\n");
    23512307                        rc = VERR_NOT_IMPLEMENTED;
    23522308                    }
    23532309                    else
    23542310                    {
    2355                         logError("Not supported data type: %s\n", gX11->xAtomToString(aPropType).c_str());
     2311                        VBClLogError("Not supported data type: %s\n", gX11->xAtomToString(aPropType).c_str());
    23562312                        rc = VERR_NOT_SUPPORTED;
    23572313                    }
     
    23622318                if (fCancel)
    23632319                {
    2364                     logInfo("Cancelling dropping to host\n");
     2320                    VBClLogInfo("Cancelling dropping to host\n");
    23652321
    23662322                    /* Cancel the operation -- inform the source window by
     
    25042460        int xRc = XTestFakeButtonEvent(m_pDisplay, 1, fPress ? True : False, CurrentTime);
    25052461        if (Rc == 0)
    2506             logError("Error sending XTestFakeButtonEvent event: %s\n", gX11->xErrorToString(xRc).c_str());
     2462            VBClLogError("Error sending XTestFakeButtonEvent event: %s\n", gX11->xErrorToString(xRc).c_str());
    25072463        XFlush(m_pDisplay);
    25082464    }
     
    25502506                             reinterpret_cast<XEvent*>(&eBtn));
    25512507        if (xRc == 0)
    2552             logError("Error sending XButtonEvent event to window=%#x: %s\n", wndDest, gX11->xErrorToString(xRc).c_str());
     2508            VBClLogError("Error sending XButtonEvent event to window=%#x: %s\n", wndDest, gX11->xErrorToString(xRc).c_str());
    25532509
    25542510        XFlush(m_pDisplay);
     
    30222978    if (xRc == 0)
    30232979    {
    3024         LogRel(("DnD: Error sending XA_XdndFinished event to source window=%#x: %s\n",
    3025                 hWndSource, gX11->xErrorToString(xRc).c_str()));
     2980        VBClLogError("Error sending XA_XdndFinished event to source window=%#x: %s\n",
     2981                      hWndSource, gX11->xErrorToString(xRc).c_str());
    30262982
    30272983        return VERR_GENERAL_FAILURE; /** @todo Fudge. */
     
    30483004    if (!m_pDisplay)
    30493005    {
    3050         VBClFatalError(("DnD: Unable to connect to X server -- running in a terminal session?\n"));
     3006        VBClLogFatalError("Unable to connect to X server -- running in a terminal session?\n");
    30513007        return VERR_NOT_FOUND;
    30523008    }
     
    31003056
    31013057    if (RT_FAILURE(rc))
    3102         LogRel(("DnD: Failed to initialize, rc=%Rrc\n", rc));
     3058        VBClLogError("Failed to initialize, rc=%Rrc\n", rc);
    31033059
    31043060    LogFlowFuncLeaveRC(rc);
     
    31373093        {
    31383094            if (RT_FAILURE(rc))
    3139                 LogRel(("DnD: Unable to connect to drag and drop service, rc=%Rrc\n", rc));
     3095                VBClLogError("Unable to connect to drag and drop service, rc=%Rrc\n", rc);
    31403096            else if (rc == VINF_PERMISSION_DENIED)
    3141                 LogRel(("DnD: Not available on host, terminating\n"));
     3097                VBClLogError("Not available on host, terminating\n");
    31423098            break;
    31433099        }
    31443100
    3145         LogRel(("DnD: Started\n"));
    3146         LogRel2(("DnD: %sr%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr()));
     3101        VBClLogInfo("Started\n");
     3102        VBClLogInfo("%sr%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr());
    31473103
    31483104        /* Enter the main event processing loop. */
     
    32553211                    default:
    32563212                    {
    3257                         m_pCurDnD->logError("Received unsupported message '%RU32'\n", pVbglR3Event->enmType);
     3213                       VBClLogError("Received unsupported message '%RU32'\n", pVbglR3Event->enmType);
    32583214                        rc = VERR_NOT_SUPPORTED;
    32593215                        break;
     
    32653221                {
    32663222                    /* Tell the user. */
    3267                     m_pCurDnD->logError("Processing message %RU32 failed with %Rrc\n", pVbglR3Event->enmType, rc);
     3223                   VBClLogError("Processing message %RU32 failed with %Rrc\n", pVbglR3Event->enmType, rc);
    32683224
    32693225                    /* If anything went wrong, do a reset and start over. */
     
    32903246        } while (!ASMAtomicReadBool(&m_fSrvStopping));
    32913247
    3292         LogRel(("DnD: Stopped with rc=%Rrc\n", rc));
     3248        VBClLogInfo("Stopped with rc=%Rrc\n", rc);
    32933249
    32943250    } while (0);
     
    33083264    LogFlowFuncEnter();
    33093265
    3310     LogRel2(("DnD: Terminating threads ...\n"));
     3266    VBClLogInfo("Terminating threads ...\n");
    33113267
    33123268    ASMAtomicXchgBool(&m_fSrvStopping, true);
     
    33273283
    33283284        if (RT_FAILURE(rc2))
    3329             LogRel(("DnD: Error waiting for HGCM thread to terminate: %Rrc\n", rc2));
     3285            VBClLogInfo("Error waiting for HGCM thread to terminate: %Rrc\n", rc2);
    33303286    }
    33313287
     
    33413297
    33423298        if (RT_FAILURE(rc2))
    3343             LogRel(("DnD: Error waiting for X11 thread to terminate: %Rrc\n", rc2));
    3344     }
    3345 
    3346     LogRel2(("DnD: Terminating threads done\n"));
     3299            VBClLogError("Error waiting for X11 thread to terminate: %Rrc\n", rc2);
     3300    }
     3301
     3302    VBClLogInfo("Terminating threads done\n");
    33473303
    33483304    xHelpers::destroyInstance();
     
    34083364        else
    34093365        {
    3410             LogRel(("DnD: Processing next message failed with rc=%Rrc\n", rc));
     3366            VBClLogError("Processing next message failed with rc=%Rrc\n", rc);
    34113367
    34123368            /* Old(er) hosts either are broken regarding DnD support or otherwise
     
    34153371            if (cMsgSkippedInvalid++ > 32)
    34163372            {
    3417                 LogRel(("DnD: Too many invalid/skipped messages from host, exiting ...\n"));
     3373                VBClLogError("Too many invalid/skipped messages from host, exiting ...\n");
    34183374                break;
    34193375            }
     
    35333489
    35343490    if (pSelf->uMagic != DRAGANDDROPSERVICE_MAGIC)
    3535         VBClFatalError(("Bad DnD service object!\n"));
     3491        VBClLogFatalError("Bad DnD service object!\n");
    35363492    return pSelf->mDragAndDrop.init();
    35373493}
     
    35423498
    35433499    if (pSelf->uMagic != DRAGANDDROPSERVICE_MAGIC)
    3544         VBClFatalError(("Bad DnD service object!\n"));
     3500        VBClLogFatalError("Bad DnD service object!\n");
    35453501    return pSelf->mDragAndDrop.run(fDaemonised);
    35463502}
     
    35513507
    35523508    if (pSelf->uMagic != DRAGANDDROPSERVICE_MAGIC)
    3553         VBClFatalError(("Bad DnD service object!\n"));
     3509        VBClLogFatalError("Bad DnD service object!\n");
    35543510    return pSelf->mDragAndDrop.cleanup();
    35553511}
     
    35703526
    35713527    if (!pService)
    3572         VBClFatalError(("Out of memory\n"));
     3528        VBClLogFatalError("Out of memory\n");
    35733529    pService->pInterface = &vbclDragAndDropInterface;
    35743530    pService->uMagic = DRAGANDDROPSERVICE_MAGIC;
  • trunk/src/VBox/Additions/x11/VBoxClient/hostversion.cpp

    r81028 r81040  
    5959        if (msg == NULL)
    6060        {
    61             LogRel(("Could not create D-BUS message!\n"));
     61            VBClLogError("Could not create D-BUS message!\n");
    6262            rc = VERR_INVALID_HANDLE;
    6363        }
     
    103103        reply = dbus_connection_send_with_reply_and_block(conn, msg, 30 * 1000 /* 30 seconds timeout */, &err);
    104104        if (dbus_error_is_set(&err))
    105             LogRel(("D-BUS returned an error while sending the notification: %s", err.message));
     105            VBClLogError("D-BUS returned an error while sending the notification: %s", err.message);
    106106        else if (reply)
    107107        {
     
    139139    rc = RTDBusLoadLib();
    140140    if (RT_FAILURE(rc))
    141         LogRel(("VBoxClient: D-Bus seems not to be installed; no host version check/notification done.\n"));
     141        VBClLogError("D-Bus seems not to be installed; no host version check/notification done\n");
    142142# else
    143143    rc = VERR_NOT_IMPLEMENTED;
     
    150150        rc = VbglR3GuestPropConnect(&uGuestPropSvcClientID);
    151151        if (RT_FAILURE(rc))
    152             LogRel(("VBoxClient: Cannot connect to guest property service while chcking for host version! rc = %Rrc\n", rc));
     152            VBClLogError("Cannot connect to guest property service while chcking for host version! rc = %Rrc\n", rc);
    153153    }
    154154
     
    179179#endif
    180180                rc = showNotify(szTitle, szMsg);
    181                 LogRel(("VBoxClient: VirtualBox Guest Additions update available!"));
     181                VBClLogInfo("VirtualBox Guest Additions update available!\n");
    182182                if (RT_FAILURE(rc))
    183                     LogRel(("VBoxClient: Could not show version notifier tooltip! rc = %d\n", rc));
     183                    VBClLogError("Could not show version notifier tooltip! rc = %d\n", rc);
    184184            }
    185185
     
    218218
    219219    if (!pService)
    220         VBClFatalError(("Out of memory\n"));
     220        VBClLogFatalError("Out of memory\n");
    221221    pService->pInterface = &vbclHostVersionInterface;
    222222    return &pService->pInterface;
  • trunk/src/VBox/Additions/x11/VBoxClient/main.cpp

    r81038 r81040  
    7070 */
    7171RTCRITSECT g_critSect;
    72 /** Counter of how often our deamon has been respawned. */
    73 unsigned cRespawn = 0;
    74 
    75 
    76 
    77 /**
    78  * Exit with a fatal error.
    79  *
    80  * This is used by the VBClFatalError macro and thus needs to be external.
    81  */
    82 void vbclFatalError(char *pszMessage)
    83 {
    84     char *pszCommand;
    85     int status;
    86     if (pszMessage && cRespawn == 0)
    87     {
    88         pszCommand = RTStrAPrintf2("notify-send \"VBoxClient: %s\"", pszMessage);
     72/** Counter of how often our daemon has been respawned. */
     73unsigned g_cRespawn = 0;
     74/** Logging verbosity level. */
     75unsigned g_cVerbosity = 0;
     76
     77/**
     78 * Notifies the desktop environment with a message.
     79 *
     80 * @param   pszMessage          Message to notify desktop environment with.
     81 */
     82int vbclLogNotify(const char *pszMessage)
     83{
     84    AssertPtrReturn(pszMessage, VERR_INVALID_POINTER);
     85
     86    int rc = VINF_SUCCESS;
     87
     88    if (g_cRespawn == 0)
     89    {
     90        char *pszCommand = RTStrAPrintf2("notify-send \"VBoxClient: %s\"", pszMessage);
    8991        if (pszCommand)
    9092        {
    91             status = system(pszCommand);
     93            int status = system(pszCommand);
     94
     95            RTStrFree(pszCommand);
     96
    9297            if (WEXITSTATUS(status) != 0)  /* Utility or extension not available. */
    9398            {
     
    101106                        RTPrintf("VBoxClient: %s", pszMessage);
    102107                    }
     108
     109                    RTStrFree(pszCommand);
    103110                }
     111                else
     112                    rc = VERR_NO_MEMORY;
    104113            }
    105114        }
    106     }
    107     _exit(RTEXITCODE_FAILURE);
     115        else
     116            rc = VERR_NO_MEMORY;
     117    }
     118
     119    return rc;
     120}
     121
     122/**
     123 * Logs a fatal error, notifies the desktop environment via a message and
     124 * exits the application immediately.
     125 *
     126 * @param   pszFormat           Format string to log.
     127 * @param   ...                 Variable arguments for format string. Optional.
     128 */
     129void VBClLogFatalError(const char *pszFormat, ...)
     130{
     131    va_list args;
     132    va_start(args, pszFormat);
     133    char *psz = NULL;
     134    RTStrAPrintfV(&psz, pszFormat, args);
     135    va_end(args);
     136
     137    AssertPtr(psz);
     138    LogFlowFunc(("%s", psz));
     139    LogRel(("%s", psz));
     140
     141    vbclLogNotify(psz);
     142
     143    RTStrFree(psz);
     144}
     145
     146/**
     147 * Logs an error message to the (release) logging instance.
     148 *
     149 * @param   pszFormat               Format string to log.
     150 */
     151void VBClLogError(const char *pszFormat, ...)
     152{
     153    va_list args;
     154    va_start(args, pszFormat);
     155    char *psz = NULL;
     156    RTStrAPrintfV(&psz, pszFormat, args);
     157    va_end(args);
     158
     159    AssertPtr(psz);
     160    LogFlowFunc(("%s", psz));
     161    LogRel(("%s", psz));
     162
     163    RTStrFree(psz);
     164}
     165
     166/**
     167 * Logs an info message to the (release) logging instance.
     168 *
     169 * @param   pszFormat               Format string to log.
     170 */
     171void  VBClLogInfo(const char *pszFormat, ...)
     172{
     173    va_list args;
     174    va_start(args, pszFormat);
     175    char *psz = NULL;
     176    RTStrAPrintfV(&psz, pszFormat, args);
     177    va_end(args);
     178
     179    AssertPtr(psz);
     180    LogFlowFunc(("%s", psz));
     181    LogRel2(("%s", psz));
     182
     183    RTStrFree(psz);
    108184}
    109185
     
    120196    int rc = RTCritSectEnter(&g_critSect);
    121197    if (RT_FAILURE(rc))
    122         VBClFatalError(("VBoxClient: Failure while acquiring the global critical section, rc=%Rrc\n", rc));
     198        VBClLogFatalError("Failure while acquiring the global critical section, rc=%Rrc\n", rc);
    123199    if (g_pService)
    124200        (*g_pService)->cleanup(g_pService);
     
    134210static void vboxClientSignalHandler(int cSignal)
    135211{
    136     LogRel(("VBoxClient: terminated with signal %d\n", cSignal));
     212    VBClLogInfo("Terminated with signal %d\n", cSignal);
    137213    /** Disable seamless mode */
    138     RTPrintf(("VBoxClient: terminating...\n"));
     214    VBClLogInfo("Terminating ...\n");
    139215    VBClCleanUp();
    140216}
     
    148224
    149225    XGetErrorText(pDisplay, pError->error_code, errorText, sizeof(errorText));
    150     LogRelFlow(("VBoxClient: an X Window protocol error occurred: %s (error code %d).  Request code: %d, minor code: %d, serial number: %d\n", errorText, pError->error_code, pError->request_code, pError->minor_code, pError->serial));
     226    VBClLogError("An X Window protocol error occurred: %s (error code %d).  Request code: %d, minor code: %d, serial number: %d\n", errorText, pError->error_code, pError->request_code, pError->minor_code, pError->serial);
    151227    return 0;
    152228}
     
    159235{
    160236    RT_NOREF1(pDisplay);
    161     LogRel(("VBoxClient: a fatal guest X Window error occurred.  This may just mean that the Window system was shut down while the client was still running.\n"));
     237    VBClLogError("A fatal guest X Window error occurred.  This may just mean that the Window system was shut down while the client was still running\n");
    162238    VBClCleanUp();
    163239    return 0;  /* We should never reach this. */
     
    172248    struct sigaction sigAction;
    173249
    174     LogRelFlowFunc(("\n"));
     250    LogRelFlowFuncEnter();
    175251    sigAction.sa_handler = vboxClientSignalHandler;
    176252    sigemptyset(&sigAction.sa_mask);
     
    184260    sigaction(SIGUSR1, &sigAction, NULL);
    185261    sigaction(SIGUSR2, &sigAction, NULL);
    186     LogRelFlowFunc(("returning\n"));
     262    LogRelFlowFuncLeave();
    187263}
    188264
     
    224300    RTPrintf("  -d, --nodaemon     continues running as a system service\n");
    225301    RTPrintf("  -h, --help         shows this help text\n");
     302    RTPrintf("  -v, --verbose      increases logging verbosity level\n");
    226303    RTPrintf("  -V, --version      shows version information\n");
    227304    RTPrintf("\n");
     
    253330     * object should probably never be used from multiple threads anyway. */
    254331    if (!XInitThreads())
    255         VBClFatalError(("Failed to initialize X11 threads\n"));
     332        VBClLogFatalError("Failed to initialize X11 threads\n");
    256333
    257334    /* Get our file name for usage info and hints. */
     
    336413            return RTEXITCODE_SUCCESS;
    337414        }
     415        else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--verbose"))
     416        {
     417            g_cVerbosity++;
     418        }
    338419        else
    339420        {
     
    352433    rc = VbglR3InitUser();
    353434    if (RT_FAILURE(rc))
    354         VBClFatalError(("VbglR3InitUser failed: %Rrc", rc));
     435        VBClLogFatalError("VbglR3InitUser failed: %Rrc", rc);
    355436
    356437    if (!fDaemonise)
     
    368449    rc = RTCritSectInit(&g_critSect);
    369450    if (RT_FAILURE(rc))
    370         VBClFatalError(("Initialising critical section failed: %Rrc\n", rc));
     451        VBClLogFatalError("Initialising critical section failed: %Rrc\n", rc);
    371452    if ((*g_pService)->getPidFilePath)
    372453    {
    373454        rc = RTPathUserHome(g_szPidFile, sizeof(g_szPidFile));
    374455        if (RT_FAILURE(rc))
    375             VBClFatalError(("Getting home directory for PID file failed: %Rrc\n", rc));
     456            VBClLogFatalError("Getting home directory for PID file failed: %Rrc\n", rc);
    376457        rc = RTPathAppend(g_szPidFile, sizeof(g_szPidFile),
    377458                          (*g_pService)->getPidFilePath());
    378459        if (RT_FAILURE(rc))
    379             VBClFatalError(("Creating PID file path failed: %Rrc\n", rc));
     460            VBClLogFatalError("Creating PID file path failed: %Rrc\n", rc);
    380461        if (fDaemonise)
    381             rc = VbglR3Daemonize(false /* fNoChDir */, false /* fNoClose */, fRespawn, &cRespawn);
     462            rc = VbglR3Daemonize(false /* fNoChDir */, false /* fNoClose */, fRespawn, &g_cRespawn);
    382463        if (RT_FAILURE(rc))
    383             VBClFatalError(("Daemonizing failed: %Rrc\n", rc));
     464            VBClLogFatalError("Daemonizing failed: %Rrc\n", rc);
    384465        if (g_szPidFile[0])
    385466            rc = VbglR3PidFile(g_szPidFile, &g_hPidFile);
     
    387468            return RTEXITCODE_SUCCESS;
    388469        if (RT_FAILURE(rc))
    389             VBClFatalError(("Creating PID file failed: %Rrc\n", rc));
     470            VBClLogFatalError("Creating PID file failed: %Rrc\n", rc);
    390471    }
    391472    /* Set signal handlers to clean up on exit. */
     
    404485        rc = (*g_pService)->run(g_pService, fDaemonise);
    405486        if (RT_FAILURE(rc))
    406             LogRel2(("Running service failed: %Rrc\n", rc));
     487            VBClLogError("Running service failed: %Rrc\n", rc);
    407488    }
    408489    else
     
    410491        /** @todo r=andy Should we return an appropriate exit code if the service failed to init?
    411492         *               Must be tested carefully with our init scripts first. */
    412         LogRel2(("Initializing service failed: %Rrc\n", rc));
     493        VBClLogError("Initializing service failed: %Rrc\n", rc);
    413494    }
    414495    VBClCleanUp(false /*fExit*/);
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless-x11.cpp

    r76553 r81040  
    4646                                    const char *aPropName, unsigned long *nItems)
    4747{
    48     LogRelFlowFunc(("\n"));
     48    LogRelFlowFuncEnter();
    4949    Atom propNameAtom = XInternAtom (aDpy, aPropName,
    5050                                     True /* only_if_exists */);
     
    6565        return NULL;
    6666
    67     LogRelFlowFunc(("returning\n"));
     67    LogRelFlowFuncLeave();
    6868    return propVal;
    6969}
     
    7979    int rc = VINF_SUCCESS;
    8080
    81     LogRelFlowFunc(("\n"));
     81    LogRelFlowFuncEnter();
    8282    if (mHostCallback != NULL)  /* Assertion */
    8383    {
    84         LogRel(("VBoxClient: ERROR: attempt to initialise seamless guest object twice!\n"));
     84        VBClLogError("Attempting to initialise seamless guest object twice!\n");
    8585        return VERR_INTERNAL_ERROR;
    8686    }
    8787    if (!(mDisplay = XOpenDisplay(NULL)))
    8888    {
    89         LogRel(("VBoxClient: seamless guest object failed to acquire a connection to the display.\n"));
     89        VBClLogError("Seamless guest object failed to acquire a connection to the display\n");
    9090        return VERR_ACCESS_DENIED;
    9191    }
     
    9393    mEnabled = false;
    9494    unmonitorClientList();
    95     LogRelFlowFunc(("returning %Rrc\n", rc));
     95    LogRelFlowFuncLeaveRC(rc);
    9696    return rc;
    9797}
     
    111111    int error, event;
    112112
    113     LogRelFlowFunc(("\n"));
     113    LogRelFlowFuncEnter();
    114114    if (mEnabled)
    115115        return VINF_SUCCESS;
     
    118118    monitorClientList();
    119119    rebuildWindowTree();
    120     LogRelFlowFunc(("returning %Rrc\n", rc));
     120    LogRelFlowFuncLeaveRC(rc);
    121121    return rc;
    122122}
     
    126126void SeamlessX11::stop(void)
    127127{
    128     LogRelFlowFunc(("\n"));
     128    LogRelFlowFuncEnter();
    129129    if (!mEnabled)
    130130        return;
     
    132132    unmonitorClientList();
    133133    freeWindowTree();
    134     LogRelFlowFunc(("returning\n"));
     134    LogRelFlowFuncLeave();
    135135}
    136136
    137137void SeamlessX11::monitorClientList(void)
    138138{
    139     LogRelFlowFunc(("called\n"));
     139    LogRelFlowFuncEnter();
    140140    XSelectInput(mDisplay, DefaultRootWindow(mDisplay), PropertyChangeMask | SubstructureNotifyMask);
    141141}
     
    143143void SeamlessX11::unmonitorClientList(void)
    144144{
    145     LogRelFlowFunc(("called\n"));
     145    LogRelFlowFuncEnter();
    146146    XSelectInput(mDisplay, DefaultRootWindow(mDisplay), PropertyChangeMask);
    147147}
     
    153153void SeamlessX11::rebuildWindowTree(void)
    154154{
    155     LogRelFlowFunc(("called\n"));
     155    LogRelFlowFuncEnter();
    156156    freeWindowTree();
    157157    addClients(DefaultRootWindow(mDisplay));
     
    177177    unsigned cChildren;
    178178
    179     LogRelFlowFunc(("\n"));
     179    LogRelFlowFuncEnter();
    180180    if (!XQueryTree(mDisplay, hRoot, &hRealRoot, &hParent, &phChildrenRaw, &cChildren))
    181181        return;
     
    184184        addClientWindow(phChildren[i]);
    185185    XFree(phChildrenRaw);
    186     LogRelFlowFunc(("returning\n"));
     186    LogRelFlowFuncLeave();
    187187}
    188188
     
    190190void SeamlessX11::addClientWindow(const Window hWin)
    191191{
    192     LogRelFlowFunc(("\n"));
     192    LogRelFlowFuncEnter();
    193193    XWindowAttributes winAttrib;
    194194    bool fAddWin = true;
     
    199199    if (fAddWin && !XGetWindowAttributes(mDisplay, hWin, &winAttrib))
    200200    {
    201         LogRelFunc(("VBoxClient: Failed to get the window attributes for window %d\n", hWin));
     201        VBClLogError("Failed to get the window attributes for window %d\n", hWin);
    202202        fAddWin = false;
    203203    }
     
    211211                                       &dummyLong)))
    212212    {
    213         LogRelFlowFunc(("window %lu, client window %lu has no size hints\n",
    214                      hWin, hClient));
     213        LogRelFlowFunc(("window %lu, client window %lu has no size hints\n", hWin, hClient));
    215214        fAddWin = false;
    216215    }
     
    244243                                pRects);
    245244    }
    246     LogRelFlowFunc(("returning\n"));
     245    LogRelFlowFuncLeave();
    247246}
    248247
     
    260259    bool rc = false;
    261260
    262     LogRelFlowFunc(("\n"));
     261    LogRelFlowFuncEnter();
    263262    windowTypeRaw = XXGetProperty(mDisplay, hWin, XA_ATOM, WM_TYPE_PROP, &ulCount);
    264263    if (windowTypeRaw != NULL)
     
    290289{
    291290    /* We use post-increment in the operation to prevent the iterator from being invalidated. */
    292     LogRelFlowFunc(("\n"));
     291    LogRelFlowFuncEnter();
    293292    mGuestWindows.detachAll(VBoxGuestWinFree, mDisplay);
    294     LogRelFlowFunc(("returning\n"));
     293    LogRelFlowFuncLeave();
    295294}
    296295
     
    305304    XEvent event;
    306305
    307     LogRelFlowFunc(("\n"));
     306    LogRelFlowFuncEnter();
    308307    /* Start by sending information about the current window setup to the host.  We do this
    309308       here because we want to send all such information from a single thread. */
     
    341340            || event.xproperty.window != DefaultRootWindow(mDisplay))
    342341            break;
    343         LogRelFlowFunc(("_NET_CLIENT_LIST property event on root window.\n"));
     342        LogRelFlowFunc(("_NET_CLIENT_LIST property event on root window\n"));
    344343        rebuildWindowTree();
    345344        break;
     
    392391void SeamlessX11::doShapeEvent(Window hWin)
    393392{
    394     LogRelFlowFunc(("\n"));
     393    LogRelFlowFuncEnter();
    395394    VBoxGuestWinInfo *pInfo = mGuestWindows.find(hWin);
    396395    if (pInfo)
     
    410409        mChanged = true;
    411410    }
    412     LogRelFlowFunc(("returning\n"));
     411    LogRelFlowFuncLeave();
    413412}
    414413
     
    477476int SeamlessX11::updateRects(void)
    478477{
    479     LogRelFlowFunc(("\n"));
     478    LogRelFlowFuncEnter();
    480479    struct RectList rects = RTVEC_INITIALIZER;
    481480
     
    492491    mcRects = RectListSize(&rects);
    493492    mpRects = RectListDetach(&rects);
    494     LogRelFlowFunc(("returning\n"));
     493    LogRelFlowFuncLeave();
    495494    return VINF_SUCCESS;
    496495}
     
    506505    Display *pDisplay = XOpenDisplay(NULL);
    507506
    508     LogRelFlowFunc(("\n"));
     507    LogRelFlowFuncEnter();
    509508    if (pDisplay == NULL)
    510         VBClFatalError(("Failed to open X11 display.\n"));
     509        VBClLogFatalError("Failed to open X11 display\n");
    511510    /* Message contents set to zero. */
    512511    XClientMessageEvent clientMessage = { ClientMessage, 0, 0, 0, 0, 0, 8 };
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless-x11.h

    r79482 r81040  
    155155                                                       pRects);
    156156        pInfo->Core.Key = hWin;
    157         LogRelFlowFunc(("returning\n"));
     157        LogRelFlowFuncLeave();
    158158        return RTAvlU32Insert(&mWindows, &pInfo->Core);
    159159    }
     
    161161    VBoxGuestWinInfo *removeWindow(Window hWin)
    162162    {
    163         LogRelFlowFunc(("called\n"));
     163        LogRelFlowFuncEnter();
    164164        return (VBoxGuestWinInfo *)RTAvlU32Remove(&mWindows, hWin);
    165165    }
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless.cpp

    r81028 r81040  
    3636SeamlessMain::SeamlessMain(void)
    3737{
    38     LogRelFlowFunc(("\n"));
     38    LogRelFlowFuncEnter();
    3939    mX11MonitorThread = NIL_RTTHREAD;
    4040    mX11MonitorThreadStopping = false;
     
    4545SeamlessMain::~SeamlessMain()
    4646{
    47     LogRelFlowFunc(("\n"));
     47    LogRelFlowFuncEnter();
    4848    stop();
    4949}
     
    5454static void sendRegionUpdate(RTRECT *pRects, size_t cRects)
    5555{
    56     LogRelFlowFunc(("\n"));
     56    LogRelFlowFuncEnter();
    5757    if (cRects && !pRects)  /* Assertion */
    5858    {
    59         LogRelFunc(("ERROR: called with null pointer!\n"));
     59        VBClLogError(("Region update called with NULL pointer!\n"));
    6060        return;
    6161    }
    6262    VbglR3SeamlessSendRects(cRects, pRects);
    63     LogRelFlowFunc(("returning\n"));
     63    LogRelFlowFuncLeave();
    6464}
    6565
     
    7272    const char *pcszStage;
    7373
    74     LogRelFlowFunc(("\n"));
     74    LogRelFlowFuncEnter();
    7575    do {
    7676        pcszStage = "Connecting to the X server";
     
    9191    } while(0);
    9292    if (RT_FAILURE(rc))
    93         VBClFatalError(("VBoxClient (seamless): failed to start.  Stage: \"%s\"  Error: %Rrc\n",
    94                 pcszStage, rc));
     93        VBClLogError("Failed to start in stage '%s' -- error: %Rrc\n", pcszStage, rc);
    9594    return rc;
    9695}
     
    106105    int rc = VINF_SUCCESS;
    107106
    108     LogRelFlowFunc(("\n"));
     107    LogRelFlowFuncEnter();
    109108    /* This will only exit if something goes wrong. */
    110109    while (RT_SUCCESS(rc) || rc == VERR_INTERRUPTED)
     
    118117    if (RT_FAILURE(rc))
    119118    {
    120         LogRel(("VBoxClient (seamless): event loop failed with error: %Rrc\n",
    121                 rc));
     119        VBClLogError("Event loop failed with error: %Rrc\n", rc);
    122120        stop();
    123121    }
     
    128126void SeamlessMain::stop()
    129127{
    130     LogRelFlowFunc(("\n"));
     128    LogRelFlowFuncEnter();
    131129    VbglR3SeamlessSetCap(false);
    132130    VbglR3CtlFilterMask(0, VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST);
    133131    stopX11MonitorThread();
    134132    mX11Monitor.uninit();
    135     LogRelFlowFunc(("returning\n"));
     133    LogRelFlowFuncLeave();
    136134}
    137135
     
    145143    VMMDevSeamlessMode newMode = VMMDev_Seamless_Disabled;
    146144
    147     LogRelFlowFunc(("\n"));
     145    LogRelFlowFuncEnter();
    148146    int rc = VbglR3SeamlessWaitEvent(&newMode);
    149147    if (RT_SUCCESS(rc))
     
    155153            /* A simplified seamless mode, obtained by making the host VM window
    156154             * borderless and making the guest desktop transparent. */
    157                 LogRelFlowFunc(("\"Visible region\" mode requested (VBoxClient).\n"));
     155                LogRelFlowFunc(("\"Visible region\" mode requested (VBoxClient)\n"));
    158156                break;
    159157            case VMMDev_Seamless_Disabled:
    160                 LogRelFlowFunc(("\"Disabled\" mode requested (VBoxClient).\n"));
     158                LogRelFlowFunc(("\"Disabled\" mode requested (VBoxClient)\n"));
    161159                break;
    162160            case VMMDev_Seamless_Host_Window:
    163161            /* One host window represents one guest window.  Not yet implemented. */
    164                 LogRelFunc(("Unsupported \"host window\" mode requested (VBoxClient).\n"));
     162                LogRelFunc(("Unsupported \"host window\" mode requested (VBoxClient)\n"));
    165163                return VERR_NOT_SUPPORTED;
    166164            default:
    167                 LogRelFunc(("Unsupported mode %d requested (VBoxClient).\n",
     165                LogRelFunc(("Unsupported mode %d requested (VBoxClient)\n",
    168166                            newMode));
    169167                return VERR_NOT_SUPPORTED;
     
    182180        LogRelFunc(("VbglR3SeamlessWaitEvent returned %Rrc (VBoxClient)\n", rc));
    183181    }
    184     LogRelFlowFunc(("returning %Rrc\n", rc));
     182    LogRelFlowFuncLeaveRC(rc);
    185183    return rc;
    186184}
     
    195193    int rc = VINF_SUCCESS;
    196194
    197     LogRelFlowFunc(("\n"));
     195    LogRelFlowFuncEnter();
    198196    while (!pHost->mX11MonitorThreadStopping)
    199197    {
     
    202200            rc = pHost->mX11Monitor.start();
    203201            if (RT_FAILURE(rc))
    204                 VBClFatalError(("Failed to change the X11 seamless service state, mfPaused=%RTbool, rc=%Rrc\n",
    205                                 pHost->mfPaused, rc));
     202                VBClLogFatalError("Failed to change the X11 seamless service state, mfPaused=%RTbool, rc=%Rrc\n",
     203                                  pHost->mfPaused, rc);
    206204        }
    207205        pHost->mX11Monitor.nextConfigurationEvent();
     
    209207            pHost->mX11Monitor.stop();
    210208    }
    211     LogRelFlowFunc(("returning %Rrc\n", rc));
     209    LogRelFlowFuncLeaveRC(rc);
    212210    return rc;
    213211}
     
    227225                        "X11 events");
    228226    if (RT_FAILURE(rc))
    229         LogRelFunc(("Warning: failed to start X11 monitor thread (VBoxClient).\n"));
     227        LogRelFunc(("Warning: failed to start X11 monitor thread (VBoxClient)\n"));
    230228    return rc;
    231229}
     
    279277    struct SEAMLESSSERVICE *pSelf = (struct SEAMLESSSERVICE *)ppInterface;
    280278    if (pSelf->magic != SEAMLESSSERVICE_MAGIC)
    281         VBClFatalError(("Bad seamless service object!\n"));
     279        VBClLogFatalError("Bad seamless service object!\n");
    282280    return pSelf;
    283281}
     
    332330
    333331    if (!pService)
    334         VBClFatalError(("Out of memory\n"));
     332        VBClLogFatalError("Out of memory\n");
    335333    pService->pInterface = &vbclSeamlessInterface;
    336334    pService->magic = SEAMLESSSERVICE_MAGIC;
  • trunk/src/VBox/Additions/x11/VBoxClient/testcase/tstSeamlessX11-auto.cpp

    r76553 r81040  
    4646#define TEST_ROOT ((Window)1)
    4747
    48 extern void vbclFatalError(char *psz)
    49 {
    50     RTPrintf("Fatal error: %s\n", psz);
     48void VBClLogError(const char *pszFormat, ...)
     49{
     50    va_list args;
     51    va_start(args, pszFormat);
     52    char *psz = NULL;
     53    RTStrAPrintfV(&psz, pszFormat, args);
     54    va_end(args);
     55
     56    AssertPtr(psz);
     57    RTPrintf("Error: %s", psz);
     58
     59    RTStrFree(psz);
     60}
     61
     62/** Exit with a fatal error. */
     63void VBClLogFatalError(const char *pszFormat, ...)
     64{
     65    va_list args;
     66    va_start(args, pszFormat);
     67    char *psz = NULL;
     68    RTStrAPrintfV(&psz, pszFormat, args);
     69    va_end(args);
     70
     71    AssertPtr(psz);
     72    RTPrintf("Fatal error: %s", psz);
     73
     74    RTStrFree(psz);
     75
    5176    exit(1);
    5277}
  • trunk/src/VBox/Additions/x11/VBoxClient/testcase/tstSeamlessX11.cpp

    r76553 r81040  
    2121#include <iprt/initterm.h>
    2222#include <iprt/semaphore.h>
     23#include <iprt/string.h>
    2324#include <iprt/stream.h>
    2425#include <VBox/VBoxGuestLib.h>
     
    2829static RTSEMEVENT eventSem;
    2930
     31void VBClLogError(const char *pszFormat, ...)
     32{
     33    va_list args;
     34    va_start(args, pszFormat);
     35    char *psz = NULL;
     36    RTStrAPrintfV(&psz, pszFormat, args);
     37    va_end(args);
     38
     39    AssertPtr(psz);
     40    RTPrintf("Error: %s", psz);
     41
     42    RTStrFree(psz);
     43}
     44
    3045/** Exit with a fatal error. */
    31 void vbclFatalError(char *pszMessage)
     46void VBClLogFatalError(const char *pszFormat, ...)
    3247{
    33     RTPrintf("Fatal error: %s", pszMessage);
     48    va_list args;
     49    va_start(args, pszFormat);
     50    char *psz = NULL;
     51    RTStrAPrintfV(&psz, pszFormat, args);
     52    va_end(args);
     53
     54    AssertPtr(psz);
     55    RTPrintf("Fatal error: %s", psz);
     56
     57    RTStrFree(psz);
     58
    3459    exit(1);
    3560}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette