Commit Graph

293 Commits

Author SHA1 Message Date
David Schulz
44db8e2eab Dumper: replace import * with explicit imports
Using imports like

 from foo import *

is considered as bad habit and it reduces
static code analysis usability.

Change-Id: I56a175f4c7b231e2b8e486bd9d1c65543720f56a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-25 13:22:50 +00:00
David Schulz
e17c96cf11 Dumper: move global enums and functions to utils
Change-Id: I11f5f0d970cd23a5fd907d33daa3cb8a441d0c58
Reviewed-by: hjk <hjk@qt.io>
2020-02-24 07:47:40 +00:00
hjk
dff4469baf Debugger: Use a more convenient way to create timing samples
Change-Id: I4ca983957c81a1f5f963a85b16a2d1b255b2cd2d
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2020-01-07 12:14:27 +00:00
Eike Ziller
fcb12a275f Merge remote-tracking branch 'origin/4.10' into 4.11
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp
	src/plugins/projectexplorer/deploymentdata.cpp
	src/plugins/projectexplorer/msvctoolchain.cpp

Change-Id: I64c304fc71435629a6a0060a9df71e8952699508
2019-10-16 15:27:22 +02:00
Michael Weghorn
e2e96cab52 GDB: Handle 'pretty_printer.to_string()' returning None
The documentation for the GDB pretty printer function
'pretty_printer.to_string' says [1]:

> [...]
> Finally, if this method returns None then no further
> operations are peformed in this method and nothing is printed.
> [...]

Therefore, skip this part if the printer's 'to_string' method returns
'None' and only fall back to assuming LazyString otherwise.

This e.g. fixes the std::pair pretty printer (for gcc-9 libstdc++6) for
which "<not accessible>" was shown previously in the debugger's
locals/expression view. Now it shows the object's address and allows
expansion to see the values for the 'first' and 'second' members.

[1] https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing-API.html

Change-Id: I33b1af82f731c347314af76c533b096b8a5afe21
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2019-10-16 08:23:30 +00:00
hjk
3e2e0c6edc Debugger: Use GDB's own pretty printers more cautiously
Looks like there is no attempt made on the GDB/libstdc++ side
to recognize uninitialized objects, so we cannot convert
"all 932 million children, I swear" to a list.

Task-number: QTCREATORBUG-22887
Change-Id: I3bf7e53c8b11ece3e1182d8446e959a66a41665a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-09-30 06:27:24 +00:00
Michael Weghorn
0313cdbd87 gdbbridge: Convert children to gdb.Value
'Dumper::fromNativeValue' expects an object of type
'gdb.Value'. However, the 'pretty_printer.children()' iterator
may return values that first need to be converted to this,
as documented for function 'pretty_printer.children' at [1]:

> This method must return an object conforming to the Python iterator
> protocol. Each item returned by the iterator must be a tuple holding two
> elements. The first element is the “name” of the child; the second
> element is the child’s value. The value can be any Python object which
> is convertible to a GDB value.

Therefore, explicitly convert the value to a GDB value first.

This fixes the expansion of 'std::vector<bool>' when system
GDB pretty printers are enabled which previously led to
"<not accessible>" being shown e.g. for the following example
(expand 'v' in the local variable view at the breakpoint):

    #include <vector>

    int main()
    {
        std::vector<bool> v;
        v.push_back(true);
        return 0; // insert breakpoint here
    }

Side note: GCC's pretty printer for 'std::vector<bool>' previously
returned either '0' or '1' for the element values, thus leading to the
problem described above. With this patch in place, the elements are
shown when the vector is expanded, but the shown type is 'long long'
(since that's the type that GDB seems to automatically assign when
constructing a 'gdb.Value' from these integers, at least with
GDB 8.2.1 on amd64). This will work as expected ('bool' shown as
type) from GCC commit [2] on ("Have std::vector printer's iterator
return bool for vector<bool>").

[1] https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing-API.html
[2] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=6c7d761a3f5fd7d19795d1d4b9b027a04b3fe88b

Change-Id: I9047affa5b4369befd2e2386c8a6b04c66c4b632
Reviewed-by: hjk <hjk@qt.io>
2019-06-26 07:16:42 +00:00
hjk
7418c4f1ee Debugger: Adapt to new qt_v4StackTraceFromEngine helper function
Change-Id: I3d3dbd837e1b73117524e286ae4ea09e652e4a5c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-05-24 06:45:08 +00:00
Eike Ziller
b5e7522237 Merge remote-tracking branch 'origin/4.9'
Conflicts:
	qbs/modules/qtc/qtc.qbs
	qtcreator.pri
	src/plugins/pythoneditor/pythoneditorplugin.cpp

Change-Id: I9a95df5e16b34538539ced7dfc5d326b700794e6
2019-04-02 12:22:48 +02:00
hjk
94d79ba3b5 Debugger: Fix "Break on Abort" with GDB > 8.1
GDB 8.1 changed behavior when specifying breakpoints, it now tries
to pattern-match function names, hitting e.g. 'Foo::abort()' for
'b ::abort'.

While the API exposes a way to opt-out of the new behavior there's
no way to tell when to do that other than trial-and-error.

Task-number: QTBUG-73993
Change-Id: Ied2e640e65e40df6eac50117db890bd4b51d36ab
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-04-01 09:28:04 +00:00
hjk
a89a885b2c Debugger: Fix "Load QML Stack"
There have been apparently changes on the Qt Declarative side.

Task-number: QTCREATORBUG-22209
Change-Id: Ia9e387aa92465556b5b8aee3661e2fc063478f3d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-03-29 15:04:35 +00:00
Joerg Bornemann
3fbd95cee4 Debugger: Fix typos in gdbbridge
Change-Id: I33f35353b08fdb26a5b78231dff5bfeb80325d14
Reviewed-by: hjk <hjk@qt.io>
2019-03-25 08:53:03 +00:00
Eike Ziller
b3baed58c6 Merge remote-tracking branch 'origin/4.9'
Change-Id: If36258b8e572b5c7875433a31a836e4f06e27286
2019-03-21 11:28:21 +01:00
hjk
cc25120377 Debugger: Fix gdb command line usage of dumpers
Change-Id: I9d5924b6cac707372a95b2b31e270722a6202fc0
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2019-03-19 14:16:49 +00:00
Michael Weghorn
b29296e9e0 Escape GDB pretty printer output
Hexencode the output from GDB pretty printer, since
Double quotes ('"') and potentially more characters
need to be escaped in order for the variable values
to be properly displayed in the variable pane while
debugging.

The 'utf8:1:0' parameter to 'putValue' (as compared
to just 'utf8') makes sure that no extra quotes are
displayed at the beginning and end of the value.

Fixes: QTCREATORBUG-22135
Change-Id: I4ad9fdc75d8f389cc4cdd18d5da1eec242f8a329
Reviewed-by: hjk <hjk@qt.io>
2019-03-15 13:48:21 +00:00
hjk
1327d9efc9 Debugger: Handle gdb builds without TYPE_CODE_RVALUE_REF again
Amends f75a7fa036: Not every gdb knows TYPE_CODE_RVALUE_REF, in that
case we ended up with no locals displayed.

Change-Id: I4dab1b18cdd46abf1a3a54a237f1cd314ac50feb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-01-21 11:17:59 +00:00
hjk
f75a7fa036 Debugger: Support rvalue references in functions args with gdb
Change-Id: I5383ffa38f07e3f191619555a9e735c211b3dd8b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-01-10 11:33:46 +00:00
hjk
2a67a86c2f Debugger: Add fallback when gdb.Value.cast() fails for typedefs
Fixes: QTCREATORBUG-18450
Change-Id: I9239beb7e1879a284e28a30579129fe487eb2dd2
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-12-17 13:21:02 +00:00
Orgad Shaneh
4cb4b7ba99 GDB: Fix address resolving for typedefed types
Reported upstream: https://sourceware.org/bugzilla/show_bug.cgi?id=23936

Fixes: QTCREATORBUG-21602
Change-Id: I0592679a6b5c4821175ef8e97e2206e0ac0be44d
Reviewed-by: hjk <hjk@qt.io>
2018-12-10 13:40:41 +00:00
Christian Stenger
84576d3098 Dumper: Fix displaying enums with LLDB
Prioritize displaying as enum if a type is known
to be an enum. Otherwise this would just end up
get displayed as string representation of its value.
Enable respective dumper tests.

Change-Id: I3e5406e14a68f02741b6144bb54528b72cc8192d
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: hjk <hjk@qt.io>
2018-11-19 14:22:45 +00:00
Alexandru Croitor
89fe2681f7 [Debugger] Add dumpers for Python "PyObject"s
The dumper calls PyObject_Repr and shows the result of that as the
value of a PyObject.

It also adds three new sub fields to show the object class (type),
super class (base class), and the meta type (the type of the class
object).

Change-Id: I0612833321f6d2b50826588e775cfa12e1db28e4
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-10-19 11:17:36 +00:00
hjk
ada0e43c93 Debugger: Fix use of external debug info for installer-based Qt
On Linux. Required installs are the gcc-built Qt libraries themselves,
the "Sources" and "Qt Debug Information Files" components.

Fixes: QTCREATORBUG-20693
Change-Id: I920efd641ce3ee4583741ea1db0bea18031adc51
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-09-24 13:37:24 +00:00
hjk
4cb0b3fa73 Debugger: Make enum class dumper test pass again for gdb
Change-Id: Iaded82ab13f30e7222eb14f548ac72d1c6502b7d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-09-06 13:41:51 +00:00
Michael Weghorn
1ae96a9090 Debugger: Fix display of children in GDB's PlainDumper
The 'putSubItem' method expects an object of the
Value class as defined in 'dumper.py'.
Therefore, create such an object for the gdb.Value
when passing it into the method.

Task-number: QTCREATORBUG-21000
Change-Id: I5277f832ee2aae808824f3dcf728fdaa0e2a3c78
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2018-09-05 05:41:55 +00:00
Michael Weghorn
34840e8088 Improve displayed type for GDB's PlainDumper
Use the name attribute of the gdb.Type rather
than that of the pretty printer.

This e.g. displays 'std::vector<int>' rather than
just 'std::vector' for an int vector.

Change-Id: I53da01bb5ba67bcd8d7113beda6ff03e708d60f9
Reviewed-by: hjk <hjk@qt.io>
2018-08-30 12:39:05 +00:00
Michael Weghorn
ec5e70eeda Make pretty-printing GDB's LazyString work
Qt Creator failed to properly display GDB's LazyString.

The problem was that GDB's 'PlainDumper::__call__' passed a 'gdb.Type',
while 'DumperBase::putCharArrayHelper' called methods that are only
defined for the custom and more abstract 'Type' type defined in 'dumper.py'.

As described at [1], GDB's 'LazyString.type' "holds the type that is
represented by the lazy string’s type. For a lazy string this is a pointer
or array type. To resolve this to the lazy string’s character type,
use the type’s target method."

In addition, 'gdb.Type' does not have a 'size()' method, just a 'sizeof'
member, s. [2].

Since all other uses of 'DumperBase::putCharArrayHelper' are passed
a "proper" type, extract the code common to the GDB case and all others
into a separate method and directly call this one for the GDB LazyString
case.

[1] https://sourceware.org/gdb/onlinedocs/gdb/Lazy-Strings-In-Python.html#Lazy-Strings-In-Python
[2] https://sourceware.org/gdb/onlinedocs/gdb/Types-In-Python.html#Types-In-Python

Task-number: QTCREATORBUG-20939
Change-Id: I16608668c9403b6d8e509dab17eb1788586f453e
Reviewed-by: hjk <hjk@qt.io>
2018-08-15 19:23:52 +00:00
hjk
e2144db165 Debugger: Pass native gdb.Value to native gdb pretty printers
Task-number: QTCREATORBUG-20770
Change-Id: I6ea92faf0c9314c50da05356fa9004f87124111a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-07-17 09:10:03 +00:00
Christian Stenger
a7fba990f4 Debugger: Fix Qt namespace detection for gdb8
Task-number: QTCREATORBUG-19620
Change-Id: Ieb7a8bc8cfeb8ba4331436ef6652437c0971c356
Reviewed-by: hjk <hjk@qt.io>
2018-07-06 10:10:05 +00:00
Christian Stenger
65a4333f2c Dumper: Fix detection of Qt namespace
Task-number: QTCREATORBUG-19620
Change-Id: Icca654714b70c69522b51998be21cff80bc29fac
Reviewed-by: hjk <hjk@qt.io>
2018-07-02 10:17:48 +00:00
hjk
d66e8b6ea0 Debugger: Remove some spurious '.report' content from dumper output
No real damage, the parser on the Creator side is apparently robust
enough. Still no need to add this.

Change-Id: I8329a55c44f866070fb3df48c3a22000ee33e848
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-03-23 13:03:35 +00:00
hjk
a8a23110bf Debugger: Fix enum dumper
Make the hex display work with LLDB, fix GDB and LLDB test.

Change-Id: I529b5cdc908dbcba7270bc4574fa59a012fcacad
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-03-22 08:45:57 +00:00
hjk
58f457f405 Debugger: Also extract Qt namespaces for libinfixed Qt build
GDB-only for now.

Task-number: QTCREATORBUG-19620
Change-Id: I2ca3a927623ec0df742fed65048e8a3bcfa5cee2
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-01-22 13:59:42 +00:00
Christian Stenger
1d2049bffc Dumper: Fix typo
Change-Id: I2d7bbe88c4d1552dba505003020c86a406821f72
Reviewed-by: hjk <hjk@qt.io>
2017-12-13 05:43:35 +00:00
hjk
58c329cd03 Debugger: Re-introduce namespace detection for Qt 4
It's apparently still in use.

Change-Id: I89d04c6b3afff8014334e3543c3f3b77bf52d130
Task-number: QTCREATORBUG-19135
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-10-23 09:51:45 +00:00
hjk
5b2a46e3a0 Debugger: Fix typo in namespace extraction debugging code
Change-Id: I24e70a25105b9fbef625ca633ebdf715749f10f3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-10-23 07:23:51 +00:00
Eike Ziller
3d9cf954e2 Merge remote-tracking branch 'origin/4.4'
Conflicts:
	src/plugins/debugger/debuggerdialogs.cpp
	src/plugins/debugger/gdb/remotegdbserveradapter.cpp

Change-Id: I1ae77869887a8d9ef2a33439f2733315db9e0cf0
2017-09-19 12:10:26 +02:00
hjk
360609eb7a Debugger: Add to solib-search-path, don't replace it
Task-number: QTCREATORBUG-18812
Change-Id: I0fb8d81d55e9928bd3825c510a11ab426ec082c6
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2017-09-13 10:09:28 +00:00
Eike Ziller
d8fd5292f1 Merge remote-tracking branch 'origin/4.4'
Conflicts:
	src/tools/clangbackend/ipcsource/clangiasyncjob.cpp
	src/tools/clangbackend/ipcsource/clangjobrequest.cpp
	src/tools/clangbackend/ipcsource/clangjobrequest.h

Change-Id: Ib8602530663813ade418f995dfd2a736908cfe75
2017-08-15 10:07:51 +02:00
hjk
6ae77f7daa Debugger: Fix editing of std::{w,}string, QString, QByteArray
... as well as std::vector and QVector

Change-Id: I7fd33be9917a17414149813c28316166b8de9be7
Task-number: QTCREATORBUG-18681
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-08-09 05:34:11 +00:00
Thiago Macieira
d6b6a88753 Debugger: print QFlags and bitfields as hex
It's a lot more useful to see in Qt Creator:
  QAbstractFileEngine::FlagsMask (0xff00000)

Than
  QAbstractFileEngine::FlagsMask (267386880)

Change-Id: I8d96dea9955d4c749b99fffd14cd690574b433e5
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2017-07-11 23:57:19 +00:00
hjk
1a16caf221 Debugger: Don't list static members of items in arrays
To properly access a static member we need a nativeValue which we
don't have in the expansion of an array.

Not showing static members in that case is a compromise between
LLDB behavior (never show statics) and showing something wrong
(see the linked bug report)

Task-number: QTCREATORBUG-18366
Change-Id: I688779224a89d4ecbc47dd5623922efb32be9c4c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2017-07-05 08:17:42 +00:00
Orgad Shaneh
a9145e67ba Debugger: Prettify values for enum bitfields
Change-Id: I55329bba1864c9ebbbcb3b3bf1b940346507f8cd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-06-12 10:40:46 +00:00
Orgad Shaneh
d7d415491a Dumper: Fix type of lvalue for bitfields on GDB
Change-Id: Ic0e82fc012eb1277a74ff2e63fdc0a13caaf5f1c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-06-07 07:37:47 +00:00
Orgad Shaneh
e9491870bd Dumper: Do not use None for bitpos
It causes an exception when being divided

Noticed with boost::icl::interval_set.

Change-Id: I5629436c3c1ba10e7b67bb05d720329f4c61eafe
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-06-06 07:13:05 +00:00
Orgad Shaneh
8204014007 Debugger: Fix unnamed typedef resolution
typedef enum { Value } Unnamed;
struct Foo { Unnamed u; };

int main()
{
    Foo foo;
    return 0; // Expand foo -> not accessible
}

Change-Id: I4231314ef92bb1896d287ae5eb3200d4d53cf4db
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-05-30 05:48:48 +00:00
hjk
1e9cc97220 Debugger: Improve handling of static members in shared objects
Change-Id: I4978094dc5dcd0e57bb6790cfc8476a9db77724d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-05-02 10:22:14 +00:00
hjk
81d9315587 Debugger: Add a boost::variant dumper
This requires making template argument extraction a bit more robust

GCC 5.4.1 created debug info only reports the first argument for
boost::variant<int, bool>:

    #include <boost/variant/variant.hpp
    int main() { boost::variant<int, float> v = 1; return 0; }

    py print(gdb.parse_and_eval('v').type)

      -> boost::variant<int, float>

    py print(gdb.parse_and_eval('v').type.template_argument(0))

      -> int

    py print(gdb.parse_and_eval('v').type.template_argument(1))

       -> Traceback (most recent call last):
          File \"<string>\", line 1, in <module>
          RuntimeError: No argument 1 in template.
          Error while executing Python code.

Change-Id: Iedca8b073078c93449ab61bb2cab05d6cd9803ba
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-04-26 09:23:18 +00:00
hjk
758e50fa45 Debugger: Catch some exceptions related to optimized out values
These could be triggered by declared but undefined and unused
static data members.

Task-number: QTCREATORBUG-18030
Change-Id: I941e8cbe8ce18dca737e59472ed0ee19ace44072
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-04-25 07:58:13 +00:00
hjk
53ff0e1ca1 Debugger: Add a workaround for bad gcc debug info generation
Gcc does not write out full type names with 'using template ...', see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80466

This is in most cases harmless for Creator as dumpers are triggered
independently of template arguments. However, if the dumper takes
different code path based on the template argument type, as is
e.g. needed for std::vector<bool>, wrong results are produced,
as the type cache only used the template base name as type id.

Work around by mangling the id of the un-typedef-ed type into
the type id of a typedef, which, in case of templates contain
the full parameter list.

Change-Id: I63c59cccdc186b09ff780e9dfd57b0ad668ae98f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-04-20 09:15:59 +00:00
David Schulz
86edeb9722 Debugger: Use native value for pointer dereference
Change-Id: Ibde6ff382e7adc0c196837c9eba04391c0a2c3a0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-03-28 09:22:28 +00:00