[Interest] Get QtDbus interface name?

Nate Rogers bob119er at yahoo.com
Fri Sep 19 22:19:23 CEST 2014


Here is some info about the segfault...


0??0xb6fe1d20
1ServiceData::setOcssCountServiceData.cpp480xd5e0
2ServiceData::qt_metacallmoc_ServiceData.cpp1520xfda4
3??0xb6da1f48




Thread3(Thread9270):
#00x43bedabcin??()
Nosymboltableinfoavailable.
#10xb6b11cccin??()
Nosymboltableinfoavailable.
Backtracestopped:framedidnotsavethePC

Thread2(Thread9269):
#00x43bedabcin??()
Nosymboltableinfoavailable.
#10xb6b11cccin??()
Nosymboltableinfoavailable.
Backtracestopped:framedidnotsavethePC

Thread1(Thread9266):
#00xb6fe1d20in??()
Nosymboltableinfoavailable.
#10x0000d5e0inServiceData::setOcssCount(this=this at entry=0x1b6f0<auxvars+548>,count=<optimizedout>)at../../../dbustest/DataProcess/ServiceData.cpp:48
__PRETTY_FUNCTION__="voidServiceData::setOcssCount(quint8)"
#20x0000fda4inServiceData::qt_metacall(this=0x1b6f0<auxvars+548>,_c=QMetaObject::WriteProperty,_id=0,_a=0xbefff698)atmoc_ServiceData.cpp:152
_v=<optimizedout>
#30xb6da1f48in??()
Nosymboltableinfoavailable.
Backtracestopped:framedidnotsavethePC



1 2 3 4 5 6 7 8 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 44	{
0xd524  <+0x0000>         push	{r4, r5, r6, r7, r8, lr}
0xd528  <+0x0004>         mov	r4, r0
0xd530  <+0x000c>         sub	sp, sp, #32
0xd534  <+0x0010>         mov	r6, r1 45	    // Has the value changed? 46	    if (count != ocssCount() )
0xd52c  <+0x0008>         ldrb	r3, [r0, #12]
0xd538  <+0x0014>         cmp	r3, r1
0xd53c  <+0x0018>         beq	0xd6ac <ServiceData::setOcssCount(unsigned char)+392> 47	    { 48	        qDebug() << "Service name: " << message().service();
0xd544  <+0x0020>         mov	r0, sp
0xd54c  <+0x0028>         add	r1, sp, #12
0xd584  <+0x0060>         bl	0xc7dc <_dl_relocate_object+4444>
0xd5d8  <+0x00b4>         add	r0, r4, #8
0xd5dc  <+0x00b8>         bl	0xca58 <_dl_relocate_object+5080>
0xd5e0  <+0x00bc>         add	r5, sp, #4
0xd5e4  <+0x00c0>         mov	r1, r0
0xd5e8  <+0x00c4>         mov	r0, r5
0xd5ec  <+0x00c8>         bl	0xc980 <_dl_relocate_object+4864>
0xd760  <+0x023c>         mov	r0, sp
0xd764  <+0x0240>         bl	0xce38 <QDebug::~QDebug()>
0xd768  <+0x0244>         bl	0xc8fc <_dl_relocate_object+4732>
0xd76c  <+0x0248>         b	0xd760 <ServiceData::setOcssCount(unsigned char)+572>
0xd770  <+0x024c>         mov	r0, r5
0xd774  <+0x0250>         bl	0xd7b0 <QString::~QString()>
0xd778  <+0x0254>         b	0xd760 <ServiceData::setOcssCount(unsigned char)+572>
0xd77c  <+0x0258>         cmp	r1, #1
0xd780  <+0x025c>         bne	0xd768 <ServiceData::setOcssCount(unsigned char)+580>
0xd784  <+0x0260>         bl	0xc734 <_dl_relocate_object+4276>
0xd788  <+0x0264>         bl	0xca34 <_dl_relocate_object+5044>
0xd78c  <+0x0268>         ldr	r5, [sp]
0xd790  <+0x026c>         b	0xd74c <ServiceData::setOcssCount(unsigned char)+552> 49 50	        // Yes, update the value 51	        m_OcssCount = count;
0xd6a0  <+0x017c>         strb	r6, [r4, #12] 52 53	        // Emit the value changed signal 54	        emit ocssCountChanged();
0xd6a4  <+0x0180>         mov	r0, r4
0xd6a8  <+0x0184>         bl	0xfb1c <ServiceData::ocssCountChanged()> 55	    } 56	}
0xd6ac  <+0x0188>         add	sp, sp, #32
0xd6b0  <+0x018c>         pop	{r4, r5, r6, r7, r8, pc} 


On Friday, September 19, 2014 3:32 PM, Nate Rogers <bob119er at yahoo.com> wrote:
 


I added protected QDBusContext to my .h file and now I get the ability to access message.service(), which is what I believe I needed.  The problem however is I am getting a segfault when I try to print the message.service value.  Am I using QDBusContext correctly?  Thanks!

ServiceData.h
---------------------------------------------------------------------
#ifndef SERVICEDATA_H
#define SERVICEDATA_H

#include <qt5/QtCore/QCoreApplication>
#include <qt5/QtDBus/QtDBus>
#include "ServiceDataAdaptor.h"

class ServiceData : public QObject, protected QDBusContext
{
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "com.GDM.ServiceData")

    Q_PROPERTY(quint8 ocssCount READ ocssCount WRITE setOcssCount NOTIFY ocssCountChanged)

public:
    quint8 ocssCount();
    void setOcssCount(quint8 count);

signals:
    void ocssCountChanged();

private:
    void initVariables();

    quint8 m_OcssCount;
};

#endif // SERVICEDATA_H
---------------------------------------------------------------------


ServiceData.cpp
---------------------------------------------------------------------
#include "ServiceData.h"

ServiceData::ServiceData(QObject *parent) : QObject(parent)
{
    initVariables();

    new ServiceDataAdaptor(this);
    QDBusConnection connection = QDBusConnection::systemBus();

    if (!connection.interface()->isServiceRegistered("com.GDM.ServiceData"))
    {
        if (!connection.registerService("com.GDM.ServiceData"))
        {
            qFatal("Could not register com.GDM.ServiceData service!");
        }

        if (!connection.registerObject("/ServiceData", this))
        {
            qFatal("Could not register ServiceData object!");
        }
    }
}

void ServiceData::initVariables()
{
    m_OcssCount = 12;
}

quint8 ServiceData::ocssCount()
{
    return m_OcssCount;
}

void ServiceData::setOcssCount(quint8 count)
{
    // Has the value changed?
    if (count != ocssCount())
    {
        qDebug() << "Service name: " << message().service();

        // Yes, update the value
        m_OcssCount = count;

        // Emit the value changed signal
        emit ocssCountChanged();
    }
}
---------------------------------------------------------------------

CanData.h
---------------------------------------------------------------------
#ifndef CANDATA_H
#define CANDATA_H

#include <qt5/QtDBus/QtDBus>
#include "ServiceDataInterface.h"

class CanData : public QObject, protected QDBusContext
{
    Q_OBJECT

public:
    explicit CanData(QObject *parent = 0);

private slots:
    void generateTestData();

private:
    com::GDM::ServiceData *m_ServiceData;
    QTimer *m_Timer;
};

#endif // CANDATA_H
---------------------------------------------------------------------

CanData.cpp
---------------------------------------------------------------------
#include <qt5/QtCore/QCoreApplication>
#include <qt5/QtDBus/QtDBus>
#include "CanData.h"

CanData::CanData(QObject *parent) : QObject(parent)
{
    m_ServiceData = new com::GDM::ServiceData("com.GDM.ServiceData", "/ServiceData", QDBusConnection::systemBus(), this);

    // Setup the timer
    m_Timer = new QTimer(this);
    connect(m_Timer, SIGNAL(timeout()), this, SLOT(generateTestData()));
    m_Timer->start(800);
}

void CanData::generateTestData()
{
    static int count = 0;

    count++;

    m_ServiceData->setOcssCount(count);
}
---------------------------------------------------------------------

ServiceData.xml
---------------------------------------------------------------------
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
  <interface name="com.GDM.ServiceData">
    <property name="ocssCount" type="y" access="readwrite"/>
    <signal name="ocssCountChanged">
    </signal>
  </interface>
</node>
---------------------------------------------------------------------


Nate




On Friday, September 19, 2014 10:54 AM, Thiago Macieira <thiago.macieira at intel.com> wrote:
 


On Friday 19 September 2014 06:15:47 Bob Hill wrote:

> Is there any trick
> to getting the name of the interface that called a function via
> QtDbus?

message().service()


Assuming your object derived from QDBusContext in addition to your QObject 
hierarchy.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center









On Friday, September 19, 2014 3:32 PM, Nate Rogers <bob119er at yahoo.com> wrote:
 


I added protected QDBusContext to my .h file and now I get the ability to access message.service(), which is what I believe I needed.  The problem however is I am getting a segfault when I try to print the message.service value.  Am I using QDBusContext correctly?  Thanks!

ServiceData.h
---------------------------------------------------------------------
#ifndef SERVICEDATA_H
#define SERVICEDATA_H

#include <qt5/QtCore/QCoreApplication>
#include <qt5/QtDBus/QtDBus>
#include "ServiceDataAdaptor.h"

class ServiceData : public QObject, protected QDBusContext
{
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "com.GDM.ServiceData")

    Q_PROPERTY(quint8 ocssCount READ ocssCount WRITE setOcssCount NOTIFY ocssCountChanged)

public:
    quint8 ocssCount();
    void setOcssCount(quint8 count);

signals:
    void ocssCountChanged();

private:
    void initVariables();

    quint8 m_OcssCount;
};

#endif // SERVICEDATA_H
---------------------------------------------------------------------


ServiceData.cpp
---------------------------------------------------------------------
#include "ServiceData.h"

ServiceData::ServiceData(QObject *parent) : QObject(parent)
{
    initVariables();

    new ServiceDataAdaptor(this);
    QDBusConnection connection = QDBusConnection::systemBus();

    if (!connection.interface()->isServiceRegistered("com.GDM.ServiceData"))
    {
        if (!connection.registerService("com.GDM.ServiceData"))
        {
            qFatal("Could not register com.GDM.ServiceData service!");
        }

        if (!connection.registerObject("/ServiceData", this))
        {
            qFatal("Could not register ServiceData object!");
        }
    }
}

void ServiceData::initVariables()
{
    m_OcssCount = 12;
}

quint8 ServiceData::ocssCount()
{
    return m_OcssCount;
}

void ServiceData::setOcssCount(quint8 count)
{
    // Has the value changed?
    if (count != ocssCount())
    {
        qDebug() << "Service name: " << message().service();

        // Yes, update the value
        m_OcssCount = count;

        // Emit the value changed signal
        emit ocssCountChanged();
    }
}
---------------------------------------------------------------------

CanData.h
---------------------------------------------------------------------
#ifndef CANDATA_H
#define CANDATA_H

#include <qt5/QtDBus/QtDBus>
#include "ServiceDataInterface.h"

class CanData : public QObject, protected QDBusContext
{
    Q_OBJECT

public:
    explicit CanData(QObject *parent = 0);

private slots:
    void generateTestData();

private:
    com::GDM::ServiceData *m_ServiceData;
    QTimer *m_Timer;
};

#endif // CANDATA_H
---------------------------------------------------------------------

CanData.cpp
---------------------------------------------------------------------
#include <qt5/QtCore/QCoreApplication>
#include <qt5/QtDBus/QtDBus>
#include "CanData.h"

CanData::CanData(QObject *parent) : QObject(parent)
{
    m_ServiceData = new com::GDM::ServiceData("com.GDM.ServiceData", "/ServiceData", QDBusConnection::systemBus(), this);

    // Setup the timer
    m_Timer = new QTimer(this);
    connect(m_Timer, SIGNAL(timeout()), this, SLOT(generateTestData()));
    m_Timer->start(800);
}

void CanData::generateTestData()
{
    static int count = 0;

    count++;

    m_ServiceData->setOcssCount(count);
}
---------------------------------------------------------------------

ServiceData.xml
---------------------------------------------------------------------
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
  <interface name="com.GDM.ServiceData">
    <property name="ocssCount" type="y" access="readwrite"/>
    <signal name="ocssCountChanged">
    </signal>
  </interface>
</node>
---------------------------------------------------------------------


Nate




On Friday, September 19, 2014 10:54 AM, Thiago Macieira <thiago.macieira at intel.com> wrote:
 


On Friday 19 September 2014 06:15:47 Bob Hill wrote:

> Is there any trick
> to getting the name of the interface that called a function via
> QtDbus?

message().service()


Assuming your object derived from QDBusContext in addition to your QObject 
hierarchy.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140919/01df1bd0/attachment.html>


More information about the Interest mailing list