crossplatform.ru

Здравствуйте, гость ( Вход | Регистрация )

 
Ответить в данную темуНачать новую тему
> Как выполнить трассировку приложения (MinGW32)
Litkevich Yuriy
  опции профиля:
сообщение 20.3.2010, 21:29
Сообщение #1


разработчик РЭА
*******

Группа: Сомодератор
Сообщений: 9669
Регистрация: 9.1.2008
Из: Тюмень
Пользователь №: 64

Спасибо сказали: 807 раз(а)




Репутация:   94  


У меня есть приложение (тыц), мне нужно каким-то средством провести трасировку, т.е. создать файл, представляющий собой последовательность вызова функций в программе.

Думал воспользоватся gprof, делал так:
В pro-файле

QMAKE_CXXFLAGS_DEBUG *= -pg
QMAKE_LFLAGS_DEBUG *= -pg

затем запускаю отладочную версию программы, рядом с бинарём создаётся файл gmon.out
затем командую:
gprof имябинаря gmon.out > ee.d.log
ee.d.log
Flat profile:

Each sample counts as 0.01 seconds.
no time accumulated

  %   cumulative   self              self     total          
time   seconds   seconds    calls  Ts/call  Ts/call  name    
  0.00      0.00     0.00      187     0.00     0.00  QBasicAtomicInt::deref()
  0.00      0.00     0.00      142     0.00     0.00  QString::~QString()
  0.00      0.00     0.00       74     0.00     0.00  QDebug::maybeSpace()
  0.00      0.00     0.00       64     0.00     0.00  QDebug::~QDebug()
  0.00      0.00     0.00       64     0.00     0.00  QDebug::operator<<(char const*)
  0.00      0.00     0.00       46     0.00     0.00  QBasicAtomicInt::ref()
  0.00      0.00     0.00       46     0.00     0.00  QString::QString()
  0.00      0.00     0.00       45     0.00     0.00  qDebug()
  0.00      0.00     0.00       45     0.00     0.00  QByteArray::data()
  0.00      0.00     0.00       45     0.00     0.00  QByteArray::detach()
  0.00      0.00     0.00       45     0.00     0.00  QByteArray::~QByteArray()
  0.00      0.00     0.00       45     0.00     0.00  QDebug::Stream::Stream(QtMsgType)
  0.00      0.00     0.00       45     0.00     0.00  QDebug::Stream::~Stream()
  0.00      0.00     0.00       45     0.00     0.00  QDebug::QDebug(QtMsgType)
  0.00      0.00     0.00       45     0.00     0.00  QFlags<QIODevice::OpenModeFlag>::QFlags(QIODevice::OpenModeFlag)
  0.00      0.00     0.00       45     0.00     0.00  QBasicAtomicInt::operator!=(int) const
  0.00      0.00     0.00       40     0.00     0.00  QModelIndex::~QModelIndex()
  0.00      0.00     0.00       30     0.00     0.00  QModelIndex::QModelIndex()
  0.00      0.00     0.00       13     0.00     0.00  QString::QString(char const*)
  0.00      0.00     0.00       10     0.00     0.00  QLatin1Char::QLatin1Char(char)
  0.00      0.00     0.00       10     0.00     0.00  QAbstractItemModel::insertRow(int, QModelIndex const&)
  0.00      0.00     0.00       10     0.00     0.00  QChar::QChar(QLatin1Char)
  0.00      0.00     0.00       10     0.00     0.00  QDebug::operator<<(QString const&)
  0.00      0.00     0.00       10     0.00     0.00  QLatin1Char::unicode() const
  0.00      0.00     0.00       10     0.00     0.00  QString::arg(int, int, int, QChar const&) const
  0.00      0.00     0.00        9     0.00     0.00  QDebug::QDebug(QDebug const&)
  0.00      0.00     0.00        4     0.00     0.00  QString::operator=(char const*)
  0.00      0.00     0.00        4     0.00     0.00  QVariant::Private::Private()
  0.00      0.00     0.00        4     0.00     0.00  QVariant::QVariant()
  0.00      0.00     0.00        1     0.00     0.00  connectToDatabse(QSettings&)
  0.00      0.00     0.00        1     0.00     0.00  work()
  0.00      0.00     0.00        1     0.00     0.00  QLatin1String::QLatin1String(char const*)
  0.00      0.00     0.00        1     0.00     0.00  QString::QString(QLatin1String const&)
  0.00      0.00     0.00        1     0.00     0.00  QLatin1String::latin1() const

%         the percentage of the total running time of the
time       program used by this function.

cumulative a running sum of the number of seconds accounted
seconds   for by this function and those listed above it.

self      the number of seconds accounted for by this
seconds    function alone.  This is the major sort for this
           listing.

calls      the number of times this function was invoked, if
           this function is profiled, else blank.

self      the average number of milliseconds spent in this
ms/call    function per call, if this function is profiled,
       else blank.

total     the average number of milliseconds spent in this
ms/call    function and its descendents per call, if this
       function is profiled, else blank.

name       the name of the function.  This is the minor sort
           for this listing. The index shows the location of
       the function in the gprof listing. If the index is
       in parenthesis it shows where it would appear in
       the gprof listing if it were to be printed.

             Call graph (explanation follows)


granularity: each sample hit covers 4 byte(s) no time propagated

index % time    self  children    called     name
                0.00    0.00      45/187         QByteArray::~QByteArray() [14]
                0.00    0.00     142/187         QString::~QString() [5]
[4]      0.0    0.00    0.00     187         QBasicAtomicInt::deref() [4]
-----------------------------------------------
                0.00    0.00       1/142         main [476]
                0.00    0.00       4/142         QString::operator=(char const*) [30]
                0.00    0.00       7/142         connectToDatabse(QSettings&) [33]
                0.00    0.00      21/142         work() [34]
                0.00    0.00      45/142         QDebug::Stream::~Stream() [16]
                0.00    0.00      64/142         QDebug::operator<<(char const*) [8]
[5]      0.0    0.00    0.00     142         QString::~QString() [5]
                0.00    0.00     142/187         QBasicAtomicInt::deref() [4]
-----------------------------------------------
                0.00    0.00      10/74          QDebug::operator<<(QString const&) [26]
                0.00    0.00      64/74          QDebug::operator<<(char const*) [8]
[6]      0.0    0.00    0.00      74         QDebug::maybeSpace() [6]
-----------------------------------------------
                0.00    0.00       2/64          connectToDatabse(QSettings&) [33]
                0.00    0.00      62/64          work() [34]
[7]      0.0    0.00    0.00      64         QDebug::~QDebug() [7]
                0.00    0.00      45/45          QByteArray::data() [12]
                0.00    0.00      45/45          QByteArray::~QByteArray() [14]
                0.00    0.00      45/45          QDebug::Stream::~Stream() [16]
-----------------------------------------------
                0.00    0.00      64/64          work() [34]
[8]      0.0    0.00    0.00      64         QDebug::operator<<(char const*) [8]
                0.00    0.00      64/142         QString::~QString() [5]
                0.00    0.00      64/74          QDebug::maybeSpace() [6]
-----------------------------------------------
                0.00    0.00      46/46          QString::QString() [10]
[9]      0.0    0.00    0.00      46         QBasicAtomicInt::ref() [9]
-----------------------------------------------
                0.00    0.00       1/46          connectToDatabse(QSettings&) [33]
                0.00    0.00      45/46          QDebug::Stream::Stream(QtMsgType) [15]
[10]     0.0    0.00    0.00      46         QString::QString() [10]
                0.00    0.00      46/46          QBasicAtomicInt::ref() [9]
-----------------------------------------------
                0.00    0.00       1/45          connectToDatabse(QSettings&) [33]
                0.00    0.00      44/45          work() [34]
[11]     0.0    0.00    0.00      45         qDebug() [11]
                0.00    0.00      45/45          QDebug::QDebug(QtMsgType) [17]
-----------------------------------------------
                0.00    0.00      45/45          QDebug::~QDebug() [7]
[12]     0.0    0.00    0.00      45         QByteArray::data() [12]
                0.00    0.00      45/45          QByteArray::detach() [13]
-----------------------------------------------
                0.00    0.00      45/45          QByteArray::data() [12]
[13]     0.0    0.00    0.00      45         QByteArray::detach() [13]
                0.00    0.00      45/45          QBasicAtomicInt::operator!=(int) const [19]
-----------------------------------------------
                0.00    0.00      45/45          QDebug::~QDebug() [7]
[14]     0.0    0.00    0.00      45         QByteArray::~QByteArray() [14]
                0.00    0.00      45/187         QBasicAtomicInt::deref() [4]
-----------------------------------------------
                0.00    0.00      45/45          QDebug::QDebug(QtMsgType) [17]
[15]     0.0    0.00    0.00      45         QDebug::Stream::Stream(QtMsgType) [15]
                0.00    0.00      45/45          QFlags<QIODevice::OpenModeFlag>::QFlags(QIODevice::OpenModeFlag) [18]
                0.00    0.00      45/46          QString::QString() [10]
-----------------------------------------------
                0.00    0.00      45/45          QDebug::~QDebug() [7]
[16]     0.0    0.00    0.00      45         QDebug::Stream::~Stream() [16]
                0.00    0.00      45/142         QString::~QString() [5]
-----------------------------------------------
                0.00    0.00      45/45          qDebug() [11]
[17]     0.0    0.00    0.00      45         QDebug::QDebug(QtMsgType) [17]
                0.00    0.00      45/45          QDebug::Stream::Stream(QtMsgType) [15]
-----------------------------------------------
                0.00    0.00      45/45          QDebug::Stream::Stream(QtMsgType) [15]
[18]     0.0    0.00    0.00      45         QFlags<QIODevice::OpenModeFlag>::QFlags(QIODevice::OpenModeFlag) [18]
-----------------------------------------------
                0.00    0.00      45/45          QByteArray::detach() [13]
[19]     0.0    0.00    0.00      45         QBasicAtomicInt::operator!=(int) const [19]
-----------------------------------------------
                0.00    0.00      40/40          work() [34]
[20]     0.0    0.00    0.00      40         QModelIndex::~QModelIndex() [20]
-----------------------------------------------
                0.00    0.00      30/30          work() [34]
[21]     0.0    0.00    0.00      30         QModelIndex::QModelIndex() [21]
-----------------------------------------------
                0.00    0.00       1/13          connectToDatabse(QSettings&) [33]
                0.00    0.00       1/13          main [476]
                0.00    0.00      11/13          work() [34]
[22]     0.0    0.00    0.00      13         QString::QString(char const*) [22]
-----------------------------------------------
                0.00    0.00      10/10          work() [34]
[23]     0.0    0.00    0.00      10         QLatin1Char::QLatin1Char(char) [23]
-----------------------------------------------
                0.00    0.00      10/10          work() [34]
[24]     0.0    0.00    0.00      10         QAbstractItemModel::insertRow(int, QModelIndex const&) [24]
-----------------------------------------------
                0.00    0.00      10/10          work() [34]
[25]     0.0    0.00    0.00      10         QChar::QChar(QLatin1Char) [25]
                0.00    0.00      10/10          QLatin1Char::unicode() const [27]
-----------------------------------------------
                0.00    0.00      10/10          work() [34]
[26]     0.0    0.00    0.00      10         QDebug::operator<<(QString const&) [26]
                0.00    0.00      10/74          QDebug::maybeSpace() [6]
-----------------------------------------------
                0.00    0.00      10/10          QChar::QChar(QLatin1Char) [25]
[27]     0.0    0.00    0.00      10         QLatin1Char::unicode() const [27]
-----------------------------------------------
                0.00    0.00      10/10          work() [34]
[28]     0.0    0.00    0.00      10         QString::arg(int, int, int, QChar const&) const [28]
-----------------------------------------------
                0.00    0.00       9/9           work() [34]
[29]     0.0    0.00    0.00       9         QDebug::QDebug(QDebug const&) [29]
-----------------------------------------------
                0.00    0.00       4/4           connectToDatabse(QSettings&) [33]
[30]     0.0    0.00    0.00       4         QString::operator=(char const*) [30]
                0.00    0.00       4/142         QString::~QString() [5]
-----------------------------------------------
                0.00    0.00       4/4           QVariant::QVariant() [32]
[31]     0.0    0.00    0.00       4         QVariant::Private::Private() [31]
-----------------------------------------------
                0.00    0.00       4/4           connectToDatabse(QSettings&) [33]
[32]     0.0    0.00    0.00       4         QVariant::QVariant() [32]
                0.00    0.00       4/4           QVariant::Private::Private() [31]
-----------------------------------------------
                0.00    0.00       1/1           main [476]
[33]     0.0    0.00    0.00       1         connectToDatabse(QSettings&) [33]
                0.00    0.00       7/142         QString::~QString() [5]
                0.00    0.00       4/4           QString::operator=(char const*) [30]
                0.00    0.00       4/4           QVariant::QVariant() [32]
                0.00    0.00       2/64          QDebug::~QDebug() [7]
                0.00    0.00       1/46          QString::QString() [10]
                0.00    0.00       1/13          QString::QString(char const*) [22]
                0.00    0.00       1/1           QLatin1String::QLatin1String(char const*) [35]
                0.00    0.00       1/1           QString::QString(QLatin1String const&) [36]
                0.00    0.00       1/45          qDebug() [11]
-----------------------------------------------
                0.00    0.00       1/1           main [476]
[34]     0.0    0.00    0.00       1         work() [34]
                0.00    0.00      64/64          QDebug::operator<<(char const*) [8]
                0.00    0.00      62/64          QDebug::~QDebug() [7]
                0.00    0.00      44/45          qDebug() [11]
                0.00    0.00      40/40          QModelIndex::~QModelIndex() [20]
                0.00    0.00      30/30          QModelIndex::QModelIndex() [21]
                0.00    0.00      21/142         QString::~QString() [5]
                0.00    0.00      11/13          QString::QString(char const*) [22]
                0.00    0.00      10/10          QLatin1Char::QLatin1Char(char) [23]
                0.00    0.00      10/10          QChar::QChar(QLatin1Char) [25]
                0.00    0.00      10/10          QString::arg(int, int, int, QChar const&) const [28]
                0.00    0.00      10/10          QDebug::operator<<(QString const&) [26]
                0.00    0.00      10/10          QAbstractItemModel::insertRow(int, QModelIndex const&) [24]
                0.00    0.00       9/9           QDebug::QDebug(QDebug const&) [29]
-----------------------------------------------
                0.00    0.00       1/1           connectToDatabse(QSettings&) [33]
[35]     0.0    0.00    0.00       1         QLatin1String::QLatin1String(char const*) [35]
-----------------------------------------------
                0.00    0.00       1/1           connectToDatabse(QSettings&) [33]
[36]     0.0    0.00    0.00       1         QString::QString(QLatin1String const&) [36]
                0.00    0.00       1/1           QLatin1String::latin1() const [37]
-----------------------------------------------
                0.00    0.00       1/1           QString::QString(QLatin1String const&) [36]
[37]     0.0    0.00    0.00       1         QLatin1String::latin1() const [37]
-----------------------------------------------

This table describes the call tree of the program, and was sorted by
the total amount of time spent in each function and its children.

Each entry in this table consists of several lines.  The line with the
index number at the left hand margin lists the current function.
The lines above it list the functions that called this function,
and the lines below it list the functions this one called.
This line lists:
     index    A unique number given to each element of the table.
        Index numbers are sorted numerically.
        The index number is printed next to every function name so
        it is easier to look up where the function in the table.

     % time    This is the percentage of the `total' time that was spent
        in this function and its children.  Note that due to
        different viewpoints, functions excluded by options, etc,
        these numbers will NOT add up to 100%.

     self    This is the total amount of time spent in this function.

     children    This is the total amount of time propagated into this
        function by its children.

     called    This is the number of times the function was called.
        If the function called itself recursively, the number
        only includes non-recursive calls, and is followed by
        a `+' and the number of recursive calls.

     name    The name of the current function.  The index number is
        printed after it.  If the function is a member of a
        cycle, the cycle number is printed between the
        function's name and the index number.


For the function's parents, the fields have the following meanings:

     self    This is the amount of time that was propagated directly
        from the function into this parent.

     children    This is the amount of time that was propagated from
        the function's children into this parent.

     called    This is the number of times this parent called the
        function `/' the total number of times the function
        was called.  Recursive calls to the function are not
        included in the number after the `/'.

     name    This is the name of the parent.  The parent's index
        number is printed after it.  If the parent is a
        member of a cycle, the cycle number is printed between
        the name and the index number.

If the parents of the function cannot be determined, the word
`<spontaneous>' is printed in the `name' field, and all the other
fields are blank.

For the function's children, the fields have the following meanings:

     self    This is the amount of time that was propagated directly
        from the child into the function.

     children    This is the amount of time that was propagated from the
        child's children to the function.

     called    This is the number of times the function called
        this child `/' the total number of times the child
        was called.  Recursive calls by the child are not
        listed in the number after the `/'.

     name    This is the name of the child.  The child's index
        number is printed after it.  If the child is a
        member of a cycle, the cycle number is printed
        between the name and the index number.

If there are any cycles (circles) in the call graph, there is an
entry for the cycle-as-a-whole.  This entry shows who called the
cycle (as parents) and the members of the cycle (as children.)
The `+' recursive calls entry shows the number of function calls that
were internal to the cycle, and the calls entry for each member shows,
for that member, how many times it was called from other members of
the cycle.


Index by function name

  [33] connectToDatabse(QSettings&) [24] QAbstractItemModel::insertRow(int, QModelIndex const&) [36] QString::QString(QLatin1String const&)
  [34] work()                 [25] QChar::QChar(QLatin1Char) [10] QString::QString()
  [11] qDebug()                [6] QDebug::maybeSpace()    [5] QString::~QString()
  [12] QByteArray::data()     [15] QDebug::Stream::Stream(QtMsgType) [30] QString::operator=(char const*)
  [13] QByteArray::detach()   [16] QDebug::Stream::~Stream() [31] QVariant::Private::Private()
  [14] QByteArray::~QByteArray() [17] QDebug::QDebug(QtMsgType) [32] QVariant::QVariant()
  [23] QLatin1Char::QLatin1Char(char) [29] QDebug::QDebug(QDebug const&) [27] QLatin1Char::unicode() const
  [21] QModelIndex::QModelIndex() [7] QDebug::~QDebug()   [37] QLatin1String::latin1() const
  [20] QModelIndex::~QModelIndex() [8] QDebug::operator<<(char const*) [19] QBasicAtomicInt::operator!=(int) const
  [35] QLatin1String::QLatin1String(char const*) [26] QDebug::operator<<(QString const&) [28] QString::arg(int, int, int, QChar const&) const
   [9] QBasicAtomicInt::ref() [18] QFlags<QIODevice::OpenModeFlag>::QFlags(QIODevice::OpenModeFlag)
   [4] QBasicAtomicInt::deref() [22] QString::QString(char const*)
однако в выводе нет ожидаемых функций, в частности соответствующих строке model->submitAll(). А меня она прежде всего и интерисует.
Может кто-то подскажет, как заполучить трассировку этой функции?
Перейти в начало страницы
 
Быстрая цитата+Цитировать сообщение
Tonal
  опции профиля:
сообщение 21.3.2010, 15:08
Сообщение #2


Активный участник
***

Группа: Участник
Сообщений: 452
Регистрация: 6.12.2007
Из: Новосибирск
Пользователь №: 34

Спасибо сказали: 69 раз(а)




Репутация:   17  


gprof - это профилятор а не трассировщик. Причём профилятор на уровне функций а не строк.
Трассировать можно с помощью gdb.
Перейти в начало страницы
 
Быстрая цитата+Цитировать сообщение
Litkevich Yuriy
  опции профиля:
сообщение 21.3.2010, 15:39
Сообщение #3


разработчик РЭА
*******

Группа: Сомодератор
Сообщений: 9669
Регистрация: 9.1.2008
Из: Тюмень
Пользователь №: 64

Спасибо сказали: 807 раз(а)




Репутация:   94  


Цитата(Tonal @ 21.3.2010, 18:08) *
Трассировать можно с помощью gdb.
подскажи как?
Мне надо не в рукопашную, т.е. я прогу консольную запускаю, она, что-то делает и завершается сама. И вот по завершению мне и нужно посмотреть где она блудила.
Перейти в начало страницы
 
Быстрая цитата+Цитировать сообщение
Tonal
  опции профиля:
сообщение 22.3.2010, 9:28
Сообщение #4


Активный участник
***

Группа: Участник
Сообщений: 452
Регистрация: 6.12.2007
Из: Новосибирск
Пользователь №: 34

Спасибо сказали: 69 раз(а)




Репутация:   17  


В gdb есть макросы, так что, мне кажется, можно и накодить такое. :)

Если бы не винда, я бы посоветовал покопаться в инструментарии valgrind-а, например посмотреть на callgrind.

Но может проще отладочную печать организовать?
Особенно в консольной-то утилите... :)
Перейти в начало страницы
 
Быстрая цитата+Цитировать сообщение
Litkevich Yuriy
  опции профиля:
сообщение 22.3.2010, 10:31
Сообщение #5


разработчик РЭА
*******

Группа: Сомодератор
Сообщений: 9669
Регистрация: 9.1.2008
Из: Тюмень
Пользователь №: 64

Спасибо сказали: 807 раз(а)




Репутация:   94  


Цитата(Tonal @ 22.3.2010, 12:28) *
Но может проще отладочную печать организовать?
мне нужно в Qt пройти, в QIBASE драйвер я уже натолкал кучу всего. Но в QtSQL мне не хотелось бы лезть, потом всё пересобирать.
Перейти в начало страницы
 
Быстрая цитата+Цитировать сообщение

Быстрый ответОтветить в данную темуНачать новую тему
Теги
Нет тегов для показа


1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0




RSS Текстовая версия Сейчас: 29.3.2024, 10:52