diff --git a/share/qtcreator/gdbmacros/dumper.py b/share/qtcreator/gdbmacros/dumper.py
index fae39edb0dfa07b6fc06f24cef83bd5735e0a2a8..062af0de6914f0b18085d4167971534d9e4e2213 100644
--- a/share/qtcreator/gdbmacros/dumper.py
+++ b/share/qtcreator/gdbmacros/dumper.py
@@ -8,6 +8,8 @@ import gdb
 import base64
 import __builtin__
 import os
+import cProfile
+
 
 # Fails on Windows.
 try:
@@ -776,228 +778,235 @@ class FrameCommand(gdb.Command):
         super(FrameCommand, self).__init__("bb", gdb.COMMAND_OBSCURE)
 
     def invoke(self, args, from_tty):
-        options = []
-        varList = []
-        typeformats = {}
-        formats = {}
-        watchers = ""
-        expandedINames = ""
-        resultVarName = ""
-        for arg in args.split(' '):
-            pos = arg.find(":") + 1
-            if arg.startswith("options:"):
-                options = arg[pos:].split(",")
-            elif arg.startswith("vars:"):
-                if len(arg[pos:]) > 0:
-                    varList = arg[pos:].split(",")
-            elif arg.startswith("resultvarname:"):
-                resultVarName = arg[pos:]
-            elif arg.startswith("expanded:"):
-                expandedINames = set(arg[pos:].split(","))
-            elif arg.startswith("typeformats:"):
-                for f in arg[pos:].split(","):
-                    pos = f.find("=")
-                    if pos != -1:
-                        type = base64.b16decode(f[0:pos], True)
-                        typeformats[type] = int(f[pos+1:])
-            elif arg.startswith("formats:"):
-                for f in arg[pos:].split(","):
-                    pos = f.find("=")
-                    if pos != -1:
-                        formats[f[0:pos]] = int(f[pos+1:])
-            elif arg.startswith("watchers:"):
-                watchers = base64.b16decode(arg[pos:], True)
-
-        useFancy = "fancy" in options
-
-        #warn("VARIABLES: %s" % varList)
-        #warn("EXPANDED INAMES: %s" % expandedINames)
-        module = sys.modules[__name__]
-        self.dumpers = {}
-
-        if False:
-            dumpers = ""
-            typeformats = ""
-            for key, value in module.__dict__.items():
-                if key.startswith("qdump__"):
-                    dumpers += '"' + key[7:] + '",'
-            output = "dumpers=[%s]," % dumpers
-            #output += "qtversion=[%d,%d,%d]"
-            #output += "qtversion=[4,6,0],"
-            output += "namespace=\"%s\"," % qtNamespace()
-            output += "dumperversion=\"2.0\","
-            output += "sizes=[],"
-            output += "expressions=[]"
-            output += "]"
-            print output
-            return
+        #if args.startswith('options:pp'):
+        #    cProfile.run('bb("%s")' % args, '/tmp/fooprof')
+        #else:
+        bb(args)
 
+FrameCommand()
 
-        if useFancy:
-            for key, value in module.__dict__.items():
-                if key.startswith("qdump__"):
-                    self.dumpers[key[7:]] = value
-
-        d = Dumper()
-        d.dumpers = self.dumpers
-        d.typeformats = typeformats
-        d.formats = formats
-        d.useFancy = useFancy
-        d.passExceptions = "pe" in options
-        d.autoDerefPointers = "autoderef" in options
-        d.ns = qtNamespace()
-        d.expandedINames = expandedINames
-        #warn(" NAMESPACE IS: '%s'" % d.ns)
-
-        #
-        # Locals
-        #
-        locals = listOfLocals(varList);
-
-        # Take care of the return value of the last function call.
-        if len(resultVarName) > 0:
-            try:
-                value = parseAndEvaluate(resultVarName)
-                locals.append(Item(value, "return", resultVarName, "return"))
-            except:
-                # Don't bother. It's only supplementary information anyway.
-                pass
 
-        for item in locals:
-          with OutputSafer(d, "", ""):
-            d.anonNumber = -1
-            #warn("ITEM NAME %s: " % item.name)
-            try:
-                #warn("ITEM VALUE %s: " % item.value)
-                # Throw on funny stuff, catch below.
-                # Unfortunately, this fails also with a "Unicode encoding error"
-                # in testArray().
-                #dummy = str(item.value)
-                pass
-            except:
-                # Locals with failing memory access.
-                with SubItem(d):
-                    d.put('iname="%s",' % item.iname)
-                    d.put('name="%s",' % item.name)
-                    d.put('addr="<not accessible>",')
-                    d.put('value="<not accessible>",')
-                    d.put('type="%s",' % item.value.type)
-                    d.put('numchild="0"');
-                continue
+def bb(args):
+    options = []
+    varList = []
+    typeformats = {}
+    formats = {}
+    watchers = ""
+    expandedINames = ""
+    resultVarName = ""
+    for arg in args.split(' '):
+        pos = arg.find(":") + 1
+        if arg.startswith("options:"):
+            options = arg[pos:].split(",")
+        elif arg.startswith("vars:"):
+            if len(arg[pos:]) > 0:
+                varList = arg[pos:].split(",")
+        elif arg.startswith("resultvarname:"):
+            resultVarName = arg[pos:]
+        elif arg.startswith("expanded:"):
+            expandedINames = set(arg[pos:].split(","))
+        elif arg.startswith("typeformats:"):
+            for f in arg[pos:].split(","):
+                pos = f.find("=")
+                if pos != -1:
+                    type = base64.b16decode(f[0:pos], True)
+                    typeformats[type] = int(f[pos+1:])
+        elif arg.startswith("formats:"):
+            for f in arg[pos:].split(","):
+                pos = f.find("=")
+                if pos != -1:
+                    formats[f[0:pos]] = int(f[pos+1:])
+        elif arg.startswith("watchers:"):
+            watchers = base64.b16decode(arg[pos:], True)
+
+    useFancy = "fancy" in options
+
+    #warn("VARIABLES: %s" % varList)
+    #warn("EXPANDED INAMES: %s" % expandedINames)
+    module = sys.modules[__name__]
+    dumpers = {}
+
+    if False:
+        dumpers = ""
+        typeformats = ""
+        for key, value in module.__dict__.items():
+            if key.startswith("qdump__"):
+                dumpers += '"' + key[7:] + '",'
+        output = "dumpers=[%s]," % dumpers
+        #output += "qtversion=[%d,%d,%d]"
+        #output += "qtversion=[4,6,0],"
+        output += "namespace=\"%s\"," % qtNamespace()
+        output += "dumperversion=\"2.0\","
+        output += "sizes=[],"
+        output += "expressions=[]"
+        output += "]"
+        print output
+        return
+
+
+    if useFancy:
+        for key, value in module.__dict__.items():
+            if key.startswith("qdump__"):
+                dumpers[key[7:]] = value
+
+    d = Dumper()
+    d.dumpers = dumpers
+    d.typeformats = typeformats
+    d.formats = formats
+    d.useFancy = useFancy
+    d.passExceptions = "pe" in options
+    d.autoDerefPointers = "autoderef" in options
+    d.ns = qtNamespace()
+    d.expandedINames = expandedINames
+    #warn(" NAMESPACE IS: '%s'" % d.ns)
+
+    #
+    # Locals
+    #
+    locals = listOfLocals(varList);
+
+    # Take care of the return value of the last function call.
+    if len(resultVarName) > 0:
+        try:
+            value = parseAndEvaluate(resultVarName)
+            locals.append(Item(value, "return", resultVarName, "return"))
+        except:
+            # Don't bother. It's only supplementary information anyway.
+            pass
 
-            type = item.value.type
-            if type.code == gdb.TYPE_CODE_PTR \
-                    and item.name == "argv" and str(type) == "char **":
-                # Special handling for char** argv.
-                n = 0
-                p = item.value
-                # p is 0 for "optimized out" cases.
-                if not isNull(p):
-                    while not isNull(p.dereference()) and n <= 100:
-                        p += 1
-                        n += 1
+    for item in locals:
+      with OutputSafer(d, "", ""):
+        d.anonNumber = -1
+        #warn("ITEM NAME %s: " % item.name)
+        try:
+            #warn("ITEM VALUE %s: " % item.value)
+            # Throw on funny stuff, catch below.
+            # Unfortunately, this fails also with a "Unicode encoding error"
+            # in testArray().
+            #dummy = str(item.value)
+            pass
+        except:
+            # Locals with failing memory access.
+            with SubItem(d):
+                d.put('iname="%s",' % item.iname)
+                d.put('name="%s",' % item.name)
+                d.put('addr="<not accessible>",')
+                d.put('value="<not accessible>",')
+                d.put('type="%s",' % item.value.type)
+                d.put('numchild="0"');
+            continue
 
-                with SubItem(d):
-                    d.put('iname="%s",' % item.iname)
-                    d.putName(item.name)
-                    d.putItemCount(select(n <= 100, n, "> 100"))
-                    d.putType(type)
-                    d.putNumChild(n)
-                    if d.isExpanded(item):
-                        p = item.value
-                        with Children(d, n):
-                            for i in xrange(n):
-                                value = p.dereference()
-                                d.putItem(Item(value, item.iname, i, None))
-                                p += 1
-                            if n > 100:
-                                d.putEllipsis()
+        type = item.value.type
+        if type.code == gdb.TYPE_CODE_PTR \
+                and item.name == "argv" and str(type) == "char **":
+            # Special handling for char** argv.
+            n = 0
+            p = item.value
+            # p is 0 for "optimized out" cases.
+            if not isNull(p):
+                while not isNull(p.dereference()) and n <= 100:
+                    p += 1
+                    n += 1
 
-            else:
-                # A "normal" local variable or parameter.
-                try:
-                   addr = cleanAddress(item.value.address)
-                   with SubItem(d):
-                       d.put('iname="%s",' % item.iname)
-                       d.put('addr="%s",' % addr)
-                       d.putItemHelper(item)
-                except AttributeError:
-                    # Thrown by cleanAddress with message "'NoneType' object
-                    # has no attribute 'cast'" for optimized-out values.
-                    with SubItem(d):
-                        d.put('iname="%s",' % item.iname)
-                        d.put('name="%s",' % item.name)
-                        d.put('addr="<optimized out>",')
-                        d.put('value="<optimized out>",')
-                        d.put('type="%s"' % item.value.type)
-
-        #
-        # Watchers
-        #
-        with OutputSafer(d, ",", ""):
-            if len(watchers) > 0:
-                for watcher in watchers.split("##"):
-                    (exp, iname) = watcher.split("#")
-                    self.handleWatch(d, exp, iname)
-
-        #
-        # Breakpoints
-        #
-        #listOfBreakpoints(d)
-
-        #print('data=[' + locals + sep + watchers + '],bkpts=[' + breakpoints + ']\n')
-        print('data=[' + d.output + ']')
-
-
-    def handleWatch(self, d, exp, iname):
-        exp = str(exp)
-        escapedExp = exp.replace('"', '\\"');
-        #warn("HANDLING WATCH %s, INAME: '%s'" % (exp, iname))
-        if exp.startswith("[") and exp.endswith("]"):
-            #warn("EVAL: EXP: %s" % exp)
             with SubItem(d):
-                d.putField("iname", iname)
-                d.putField("name", escapedExp)
-                d.putField("exp", escapedExp)
-                try:
-                    list = eval(exp)
-                    d.putValue("")
-                    d.putType(" ")
-                    d.putNumChild(len(list))
-                    # This is a list of expressions to evaluate
-                    with Children(d, len(list)):
-                        itemNumber = 0
-                        for item in list:
-                            self.handleWatch(d, item, "%s.%d" % (iname, itemNumber))
-                            itemNumber += 1
-                except RuntimeError, error:
-                    warn("EVAL: ERROR CAUGHT %s" % error)
-                    d.putValue("<syntax error>")
-                    d.putType(" ")
-                    d.putNumChild(0)
-                    with Children(d, 0):
-                        pass
-            return
+                d.put('iname="%s",' % item.iname)
+                d.putName(item.name)
+                d.putItemCount(select(n <= 100, n, "> 100"))
+                d.putType(type)
+                d.putNumChild(n)
+                if d.isExpanded(item):
+                    p = item.value
+                    with Children(d, n):
+                        for i in xrange(n):
+                            value = p.dereference()
+                            d.putItem(Item(value, item.iname, i, None))
+                            p += 1
+                        if n > 100:
+                            d.putEllipsis()
 
+        else:
+            # A "normal" local variable or parameter.
+            try:
+               addr = cleanAddress(item.value.address)
+               with SubItem(d):
+                   d.put('iname="%s",' % item.iname)
+                   d.put('addr="%s",' % addr)
+                   d.putItemHelper(item)
+            except AttributeError:
+                # Thrown by cleanAddress with message "'NoneType' object
+                # has no attribute 'cast'" for optimized-out values.
+                with SubItem(d):
+                    d.put('iname="%s",' % item.iname)
+                    d.put('name="%s",' % item.name)
+                    d.put('addr="<optimized out>",')
+                    d.put('value="<optimized out>",')
+                    d.put('type="%s"' % item.value.type)
+
+    #
+    # Watchers
+    #
+    with OutputSafer(d, ",", ""):
+        if len(watchers) > 0:
+            for watcher in watchers.split("##"):
+                (exp, iname) = watcher.split("#")
+                handleWatch(d, exp, iname)
+
+    #
+    # Breakpoints
+    #
+    #listOfBreakpoints(d)
+
+    #print('data=[' + locals + sep + watchers + '],bkpts=[' + breakpoints + ']\n')
+    print('data=[' + d.output + ']')
+
+
+def handleWatch(d, exp, iname):
+    exp = str(exp)
+    escapedExp = exp.replace('"', '\\"');
+    #warn("HANDLING WATCH %s, INAME: '%s'" % (exp, iname))
+    if exp.startswith("[") and exp.endswith("]"):
+        #warn("EVAL: EXP: %s" % exp)
         with SubItem(d):
             d.putField("iname", iname)
             d.putField("name", escapedExp)
             d.putField("exp", escapedExp)
-            handled = False
-            if exp == "<Edit>" or len(exp) == 0:
-                d.put('value=" ",type=" ",numchild="0",')
-            else:
-                try:
-                    value = parseAndEvaluate(exp)
-                    item = Item(value, iname, None, None)
-                    if not value is None:
-                        d.putAddress(value.address)
-                    d.putItemHelper(item)
-                except RuntimeError:
-                    d.put('value="<invalid>",type="<unknown>",numchild="0",')
-
+            try:
+                list = eval(exp)
+                d.putValue("")
+                d.putType(" ")
+                d.putNumChild(len(list))
+                # This is a list of expressions to evaluate
+                with Children(d, len(list)):
+                    itemNumber = 0
+                    for item in list:
+                        handleWatch(d, item, "%s.%d" % (iname, itemNumber))
+                        itemNumber += 1
+            except RuntimeError, error:
+                warn("EVAL: ERROR CAUGHT %s" % error)
+                d.putValue("<syntax error>")
+                d.putType(" ")
+                d.putNumChild(0)
+                with Children(d, 0):
+                    pass
+        return
+
+    with SubItem(d):
+        d.putField("iname", iname)
+        d.putField("name", escapedExp)
+        d.putField("exp", escapedExp)
+        handled = False
+        if exp == "<Edit>" or len(exp) == 0:
+            d.put('value=" ",type=" ",numchild="0",')
+        else:
+            try:
+                value = parseAndEvaluate(exp)
+                item = Item(value, iname, None, None)
+                if not value is None:
+                    d.putAddress(value.address)
+                d.putItemHelper(item)
+            except RuntimeError:
+                d.put('value="<invalid>",type="<unknown>",numchild="0",')
 
-FrameCommand()
 
 
 #######################################################################
diff --git a/share/qtcreator/gdbmacros/gdbmacros.cpp b/share/qtcreator/gdbmacros/gdbmacros.cpp
index 3135dacadc4c214c3ddb4ddd50d06c7d665e80e7..ce620d955d94d3f8f97eab106c39e7cd36ce6b8f 100644
--- a/share/qtcreator/gdbmacros/gdbmacros.cpp
+++ b/share/qtcreator/gdbmacros/gdbmacros.cpp
@@ -195,13 +195,13 @@ QT_END_NAMESPACE
 #ifdef MACROSDEBUG
     Q_DECL_EXPORT char xDumpInBuffer[10000];
     Q_DECL_EXPORT char xDumpOutBuffer[1000000];
-    #define inBuffer xDumpInBuffer
-    #define outBuffer xDumpOutBuffer
+#    define inBuffer xDumpInBuffer
+#    define outBuffer xDumpOutBuffer
 #else
     Q_DECL_EXPORT char qDumpInBuffer[10000];
     Q_DECL_EXPORT char qDumpOutBuffer[1000000];
-    #define inBuffer qDumpInBuffer
-    #define outBuffer qDumpOutBuffer
+#    define inBuffer qDumpInBuffer
+#    define outBuffer qDumpOutBuffer
 #endif
 
 namespace {
@@ -994,7 +994,7 @@ void qDumpInnerValueHelper(QDumper &d, const char *type, const void *addr,
             }
             break;
         case 'O':
-            #ifndef QT_BOOTSTRAPPED
+#            ifndef QT_BOOTSTRAPPED
             if (isEqual(type, "QObject *")) {
                 if (addr) {
                     const QObject *ob = reinterpret_cast<const QObject *>(addr);
@@ -1010,7 +1010,7 @@ void qDumpInnerValueHelper(QDumper &d, const char *type, const void *addr,
                     d.putItem("numchild", 0);
                 }
             }
-            #endif
+#            endif
             break;
         case 'S':
             if (isEqual(type, "QString")) {
@@ -1246,13 +1246,13 @@ static void qDumpQDateTime(QDumper &d)
         d.putHash("isNull", date.isNull());
         d.putHash("toTime_t", (long)date.toTime_t());
         d.putHash("toString", date.toString());
-        #if QT_VERSION >= 0x040500
+#        if QT_VERSION >= 0x040500
         d.putHash("toString_(ISO)", date.toString(Qt::ISODate));
         d.putHash("toString_(SystemLocale)", date.toString(Qt::SystemLocaleDate));
         d.putHash("toString_(Locale)", date.toString(Qt::LocaleDate));
-        #endif
+#        endif
 
-        #if 0
+#        if 0
         d.beginHash();
         d.putItem("name", "toUTC");
         d.putItem("exp", "(("NSX"QDateTime"NSY"*)").put(d.data).put(")"
@@ -1260,9 +1260,9 @@ static void qDumpQDateTime(QDumper &d)
         d.putItem("type", NS"QDateTime");
         d.putItem("numchild", "1");
         d.endHash();
-        #endif
+#        endif
 
-        #if 0
+#        if 0
         d.beginHash();
         d.putItem("name", "toLocalTime");
         d.putItem("exp", "(("NSX"QDateTime"NSY"*)").put(d.data).put(")"
@@ -1270,7 +1270,7 @@ static void qDumpQDateTime(QDumper &d)
         d.putItem("type", NS"QDateTime");
         d.putItem("numchild", "1");
         d.endHash();
-        #endif
+#        endif
 
         d.endChildren();
     }
@@ -2079,13 +2079,13 @@ static void qDumpQVariantHelper(const QVariant *v, QString *value,
         *value = QLatin1Char('"') + v->toString() + QLatin1Char('"');
         *numchild = 0;
         break;
-    #if QT_VERSION >= 0x040500
+#    if QT_VERSION >= 0x040500
     case QVariant::StringList:
         *exp = QString(QLatin1String("(*('"NS"QStringList'*)%1)"))
                     .arg((quintptr)v);
         *numchild = v->toStringList().size();
         break;
-    #endif
+#    endif
     case QVariant::Int:
         *value = QString::number(v->toInt());
         *numchild= 0;
@@ -2094,7 +2094,7 @@ static void qDumpQVariantHelper(const QVariant *v, QString *value,
         *value = QString::number(v->toDouble());
         *numchild = 0;
         break;
-    #ifndef QT_BOOTSTRAPPED
+#    ifndef QT_BOOTSTRAPPED
     case QVariant::Point: {
             const QPoint p = v->toPoint();
             *value = QString::fromLatin1("%1, %2").arg(p.x()).arg(p.y());
@@ -2138,8 +2138,8 @@ static void qDumpQVariantHelper(const QVariant *v, QString *value,
         }
         *numchild = 0;
         break;
-    #endif // QT_BOOTSTRAPPED
-    #if USE_QT_GUI
+#    endif // QT_BOOTSTRAPPED
+#    if USE_QT_GUI
     case QVariant::Font:
         *value = qvariant_cast<QFont>(*v).toString();
         break;
@@ -2147,16 +2147,16 @@ static void qDumpQVariantHelper(const QVariant *v, QString *value,
         *value = qvariant_cast<QColor>(*v).name();
         break;
     case QVariant::KeySequence:
-        #ifndef QT_NO_SHORTCUT
+#        ifndef QT_NO_SHORTCUT
         *value = qvariant_cast<QKeySequence>(*v).toString();
-        #else
+#        else
         *value = QString::fromLatin1("Disabled by QT_NO_SHORTCUT");
-        #endif
+#        endif
         break;
     case QVariant::SizePolicy:
         *value = sizePolicyValue(qvariant_cast<QSizePolicy>(*v));
         break;
-    #endif
+#    endif
     default: {
         static const char *qTypeFormat = sizeof(void *) == sizeof(long)
             ? "'"NS"%s "NS"qVariantValue<"NS"%s >'(*('"NS"QVariant'*)0x%lx)"
@@ -3476,12 +3476,12 @@ static void handleProtocolVersion2and3(QDumper &d)
                 qDumpStdMap(d);
             break;
         case 'A':
-            #ifndef QT_BOOTSTRAPPED
+#            ifndef QT_BOOTSTRAPPED
             if (isEqual(type, "QAbstractItemModel"))
                 qDumpQAbstractItemModel(d);
             else if (isEqual(type, "QAbstractItem"))
                 qDumpQAbstractItem(d);
-            #endif
+#            endif
             break;
         case 'B':
             if (isEqual(type, "QByteArray"))
@@ -3504,12 +3504,12 @@ static void handleProtocolVersion2and3(QDumper &d)
                 qDumpStdSet(d);
             break;
         case 'F':
-            #ifndef QT_BOOTSTRAPPED
+#            ifndef QT_BOOTSTRAPPED
             if (isEqual(type, "QFile"))
                 qDumpQFile(d);
             else if (isEqual(type, "QFileInfo"))
                 qDumpQFileInfo(d);
-            #endif
+#            endif
             break;
         case 'H':
             if (isEqual(type, "QHash"))
@@ -3522,25 +3522,25 @@ static void handleProtocolVersion2and3(QDumper &d)
                 qDumpStdList(d);
             break;
         case 'I':
-            #if USE_QT_GUI
+#            if USE_QT_GUI
             if (isEqual(type, "QImage"))
                 qDumpQImage(d);
             else if (isEqual(type, "QImageData"))
                 qDumpQImageData(d);
-            #endif
+#            endif
             break;
         case 'L':
-            #ifndef QT_BOOTSTRAPPED
+#            ifndef QT_BOOTSTRAPPED
             if (isEqual(type, "QList"))
                 qDumpQList(d);
             else if (isEqual(type, "QLinkedList"))
                 qDumpQLinkedList(d);
             else if (isEqual(type, "QLocale"))
                 qDumpQLocale(d);
-            #endif
+#            endif
             break;
         case 'M':
-            #ifndef QT_BOOTSTRAPPED
+#            ifndef QT_BOOTSTRAPPED
             if (isEqual(type, "QMap"))
                 qDumpQMap(d);
             else if (isEqual(type, "QMapNode"))
@@ -3549,10 +3549,10 @@ static void handleProtocolVersion2and3(QDumper &d)
                 qDumpQModelIndex(d);
             else if (isEqual(type, "QMultiMap"))
                 qDumpQMultiMap(d);
-            #endif
+#            endif
             break;
         case 'O':
-            #ifndef QT_BOOTSTRAPPED
+#            ifndef QT_BOOTSTRAPPED
             if (isEqual(type, "QObject"))
                 qDumpQObject(d);
             else if (isEqual(type, "QObjectPropertyList"))
@@ -3571,43 +3571,43 @@ static void handleProtocolVersion2and3(QDumper &d)
                 qDumpQObjectSlotList(d);
             else if (isEqual(type, "QObjectChildList"))
                 qDumpQObjectChildList(d);
-            #endif
+#            endif
             break;
         case 'P':
-            #if USE_QT_GUI
+#            if USE_QT_GUI
             if (isEqual(type, "QPixmap"))
                 qDumpQPixmap(d);
-            #endif
-            #ifndef QT_BOOTSTRAPPED
+#            endif
+#            ifndef QT_BOOTSTRAPPED
             if (isEqual(type, "QPoint"))
                 qDumpQPoint(d);
             else if (isEqual(type, "QPointF"))
                 qDumpQPointF(d);
-            #endif
+#            endif
             break;
         case 'R':
-            #ifndef QT_BOOTSTRAPPED
+#            ifndef QT_BOOTSTRAPPED
             if (isEqual(type, "QRect"))
                 qDumpQRect(d);
             else if (isEqual(type, "QRectF"))
                 qDumpQRectF(d);
-            #endif
+#            endif
             break;
         case 'S':
             if (isEqual(type, "QString"))
                 qDumpQString(d);
             else if (isEqual(type, "QStringList"))
                 qDumpQStringList(d);
-            #ifndef QT_BOOTSTRAPPED
+#            ifndef QT_BOOTSTRAPPED
             else if (isEqual(type, "QSet"))
                 qDumpQSet(d);
             else if (isEqual(type, "QStack"))
                 qDumpQVector(d);
-            #if QT_VERSION >= 0x040500
+#            if QT_VERSION >= 0x040500
             else if (isEqual(type, "QSharedPointer"))
                 qDumpQSharedPointer(d);
-            #endif
-            #endif // QT_BOOTSTRAPPED
+#            endif
+#            endif // QT_BOOTSTRAPPED
             else if (isEqual(type, "QSize"))
                 qDumpQSize(d);
             else if (isEqual(type, "QSizeF"))
@@ -3634,13 +3634,13 @@ static void handleProtocolVersion2and3(QDumper &d)
                 qDumpStdWString(d);
             break;
         case 'T':
-            #ifndef QT_BOOTSTRAPPED
+#            ifndef QT_BOOTSTRAPPED
             if (isEqual(type, "QTextCodec"))
                 qDumpQTextCodec(d);
-            #endif
+#            endif
             break;
         case 'V':
-            #ifndef QT_BOOTSTRAPPED
+#            ifndef QT_BOOTSTRAPPED
             if (isEqual(type, "QVariantList")) { // resolve typedef
                 d.outerType = "QList";
                 d.innerType = "QVariant";
@@ -3651,15 +3651,15 @@ static void handleProtocolVersion2and3(QDumper &d)
             } else if (isEqual(type, "QVector")) {
                 qDumpQVector(d);
             }
-            #endif
+#            endif
             break;
         case 'W':
-            #ifndef QT_BOOTSTRAPPED
-            #if QT_VERSION >= 0x040500
+#            ifndef QT_BOOTSTRAPPED
+#            if QT_VERSION >= 0x040500
             if (isEqual(type, "QWeakPointer"))
                 qDumpQWeakPointer(d);
-            #endif
-            #endif
+#            endif
+#            endif
             break;
     }
 
@@ -3954,9 +3954,9 @@ void *qDumpObjectData440(
     }
 
     else {
-        #ifndef QT_BOOTSTRAPPED
+#        ifndef QT_BOOTSTRAPPED
         qDebug() << "Unsupported protocol version" << protocolVersion;
-        #endif
+#        endif
     }
     return outBuffer;
 }
diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro
index 57b53ead9e8185e024ec77cce0d19cd4a5d1e839..528495e55d94125fb288a398967608c3d89d4ffd 100644
--- a/src/plugins/debugger/debugger.pro
+++ b/src/plugins/debugger/debugger.pro
@@ -109,6 +109,7 @@ include(cdb/cdb.pri)
 include(gdb/gdb.pri)
 include(script/script.pri)
 include(pdb/pdb.pri)
+include(qml/qml.pri)
 include(tcf/tcf.pri)
 include(shared/shared.pri)
 
diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp
index 357de3495b67a5ac97fa0e27bab24e000c3fde92..b4e91393de0f3c8eb88b47619e750e7e51968a1c 100644
--- a/src/plugins/debugger/debuggermanager.cpp
+++ b/src/plugins/debugger/debuggermanager.cpp
@@ -160,6 +160,7 @@ IDebuggerEngine *createGdbEngine(DebuggerManager *parent);
 IDebuggerEngine *createScriptEngine(DebuggerManager *parent);
 IDebuggerEngine *createPdbEngine(DebuggerManager *parent);
 IDebuggerEngine *createTcfEngine(DebuggerManager *parent);
+IDebuggerEngine *createQmlEngine(DebuggerManager *parent);
 
 // The createCdbEngine function takes a list of options pages it can add to.
 // This allows for having a "enabled" toggle on the page independently
@@ -198,7 +199,7 @@ using namespace TextEditor;
 
 const char *DebuggerManager::stateName(int s)
 {
-    #define SN(x) case x: return #x;
+#    define SN(x) case x: return #x;
     switch (s) {
         SN(DebuggerNotReady)
         SN(EngineStarting)
@@ -221,7 +222,7 @@ const char *DebuggerManager::stateName(int s)
         SN(EngineShuttingDown)
     }
     return "<unknown>";
-    #undef SN
+#    undef SN
 }
 
 
@@ -254,6 +255,7 @@ static Debugger::Internal::IDebuggerEngine *gdbEngine = 0;
 static Debugger::Internal::IDebuggerEngine *scriptEngine = 0;
 static Debugger::Internal::IDebuggerEngine *cdbEngine = 0;
 static Debugger::Internal::IDebuggerEngine *pdbEngine = 0;
+static Debugger::Internal::IDebuggerEngine *qmlEngine = 0;
 static Debugger::Internal::IDebuggerEngine *tcfEngine = 0;
 
 struct DebuggerManagerPrivate
@@ -345,12 +347,13 @@ DebuggerManager::DebuggerManager(DebuggerPlugin *plugin)
 
 DebuggerManager::~DebuggerManager()
 {
-    #define doDelete(ptr) delete ptr; ptr = 0
+#    define doDelete(ptr) delete ptr; ptr = 0
     doDelete(scriptEngine);
     doDelete(pdbEngine);
     doDelete(gdbEngine);
     doDelete(cdbEngine);
     doDelete(tcfEngine);
+    doDelete(qmlEngine);
 
     doDelete(d->m_breakHandler);
     doDelete(d->m_threadsHandler);
@@ -359,12 +362,7 @@ DebuggerManager::~DebuggerManager()
     doDelete(d->m_snapshotHandler);
     doDelete(d->m_stackHandler);
     doDelete(d->m_watchHandler);
-
-    doDelete(gdbEngine);
-    doDelete(scriptEngine);
-    doDelete(cdbEngine);
-    doDelete(tcfEngine);
-    #undef doDelete
+#    undef doDelete
     DebuggerManagerPrivate::instance = 0;
     delete d;
 }
@@ -692,6 +690,11 @@ QList<Core::IOptionsPage*> DebuggerManager::initializeEngines(unsigned enabledTy
         tcfEngine->addOptionPages(&rc);
     }
 
+    if (enabledTypeFlags & QmlEngineType) {
+        qmlEngine = createQmlEngine(this);
+        //qmlEngine->addOptionPages(&rc);
+    }
+
     d->m_engine = 0;
     STATE_DEBUG(gdbEngine << cdbEngine << scriptEngine
         << pdbEngine << rc.size());
@@ -976,6 +979,15 @@ static IDebuggerEngine *debuggerEngineForExecutable(const QString &executable,
                                                     QString *errorMessage,
                                                     QString *settingsIdHint)
 {
+    if (executable.endsWith(_("qmlviewer"))) {
+        qDebug() << "HERE";
+        if (!qmlEngine) {
+            *errorMessage = msgEngineNotAvailable("Qml Engine");
+            return 0;
+        }
+        return qmlEngine;
+    }
+
     if (executable.endsWith(_(".js"))) {
         if (!scriptEngine) {
             *errorMessage = msgEngineNotAvailable("Script Engine");
@@ -1016,7 +1028,8 @@ static IDebuggerEngine *debuggerEngineForExecutable(const QString &executable,
 
     // We need the CDB debugger in order to be able to debug VS
     // executables
-    if (!DebuggerManager::instance()->checkDebugConfiguration(ProjectExplorer::ToolChain::MSVC, errorMessage, 0 , settingsIdHint))
+    if (!DebuggerManager::instance()->checkDebugConfiguration(
+            ProjectExplorer::ToolChain::MSVC, errorMessage, 0, settingsIdHint))
         return 0;
     return cdbEngine;
 #endif
@@ -1049,6 +1062,7 @@ static IDebuggerEngine *debuggerEngineForMode(DebuggerStartMode startMode, QStri
 
 void DebuggerManager::startNewDebugger(const DebuggerStartParametersPtr &sp)
 {
+    qDebug() << "TARGET: " << sp->executable;
     if (d->m_state != DebuggerNotReady)
         return;
     d->m_startParameters = sp;
@@ -1067,7 +1081,9 @@ void DebuggerManager::startNewDebugger(const DebuggerStartParametersPtr &sp)
     // Figure out engine: toolchain, executable, attach or default
     const DebuggerStartMode startMode = sp->startMode;
 
-    if (sp->executable.endsWith(_(".js")))
+    if (sp->executable.endsWith(_("qmlviewer")))
+        d->m_engine = qmlEngine;
+    else if (sp->executable.endsWith(_(".js")))
         d->m_engine = scriptEngine;
     else if (sp->executable.endsWith(_(".py")))
         d->m_engine = pdbEngine;
diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h
index 0210b706c53237d050963f69628a7e70bfc5c69a..74be97a9c65bcfa37713dc39fce94fb5787a213b 100644
--- a/src/plugins/debugger/debuggermanager.h
+++ b/src/plugins/debugger/debuggermanager.h
@@ -95,6 +95,7 @@ class CdbDumperInitThread;
 class CdbExceptionLoggerEventCallback;
 class GdbEngine;
 class TcfEngine;
+class QmlEngine;
 class CdbDebugEngine;
 class CdbDebugEnginePrivate;
 class TrkGdbAdapter;
@@ -145,11 +146,13 @@ enum DebuggerEngineTypeFlags
     CdbEngineType     = 0x04,
     PdbEngineType     = 0x08,
     TcfEngineType     = 0x10,
+    QmlEngineType     = 0x20,
     AllEngineTypes = GdbEngineType
         | ScriptEngineType
         | CdbEngineType
         | PdbEngineType
         | TcfEngineType
+        | QmlEngineType
 };
 
 QDebug operator<<(QDebug d, DebuggerState state);
@@ -178,6 +181,7 @@ public:
     friend class Internal::ScriptEngine;
     friend class Internal::PdbEngine;
     friend class Internal::TcfEngine;
+    friend class Internal::QmlEngine;
     friend class Internal::CdbDebugEngine;
     friend class Internal::CdbDebugEnginePrivate;
     friend class Internal::TrkGdbAdapter;
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index 7a625b45bbaa14e0239a437aeee88603cc2e2695..45ee41015ae36c2625615a06585b70e0920bdd2f 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -637,11 +637,15 @@ static bool parseArgument(QStringList::const_iterator &it,
         *enabledEngines &= ~Debugger::GdbEngineType;
         return true;
     }
+    if (option == _("-disable-qmldb")) {
+        *enabledEngines &= ~Debugger::QmlEngineType;
+        return true;
+    }
     if (option == _("-disable-sdb")) {
         *enabledEngines &= ~Debugger::ScriptEngineType;
         return true;
     }
-    if (option == QLatin1String("-disable-tcf")) {
+    if (option == _("-disable-tcf")) {
         *enabledEngines &= ~TcfEngineType;
         return true;
     }
@@ -1358,7 +1362,6 @@ void DebuggerPlugin::languageChanged(const QString &language)
     m_attachCoreAction->setVisible(debuggerIsCPP);
     m_startRemoteAction->setVisible(debuggerIsCPP);
     m_detachAction->setVisible(debuggerIsCPP);
-
 }
 
 void DebuggerPlugin::writeSettings() const
@@ -1398,12 +1401,9 @@ void DebuggerPlugin::onModeChanged(IMode *mode)
 
         if (isCurrentProjectCppBased())
             m_uiSwitcher->setActiveLanguage(LANG_CPP);
-
     }
 }
 
-
-
 void DebuggerPlugin::showSettingsDialog()
 {
     Core::ICore::instance()->showOptionsDialog(
diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp
index 9ee192f6a31bb91b24e08a63993f1a8c2ae5316d..d7c606dc2e0367ebdc0f07443e656e02276587f4 100644
--- a/src/plugins/debugger/debuggerrunner.cpp
+++ b/src/plugins/debugger/debuggerrunner.cpp
@@ -48,6 +48,7 @@
 namespace Debugger {
 namespace Internal {
 
+using ProjectExplorer::BuildConfiguration;
 using ProjectExplorer::RunConfiguration;
 using ProjectExplorer::RunControl;
 using ProjectExplorer::LocalApplicationRunConfiguration;
@@ -65,6 +66,7 @@ DebuggerRunControlFactory::DebuggerRunControlFactory(DebuggerManager *manager)
 
 bool DebuggerRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const
 {
+//    return mode == ProjectExplorer::Constants::DEBUGMODE;
     return mode == ProjectExplorer::Constants::DEBUGMODE
             && qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
 }
@@ -130,8 +132,9 @@ DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
         break;
     }
     if (runConfiguration->target()->project()) {
-        m_startParameters->buildDirectory =
-            runConfiguration->target()->activeBuildConfiguration()->buildDirectory();
+        BuildConfiguration *bc = runConfiguration->target()->activeBuildConfiguration();
+        if (bc)
+            m_startParameters->buildDirectory = bc->buildDirectory();
     }
     m_startParameters->useTerminal =
         runConfiguration->runMode() == LocalApplicationRunConfiguration::Console;
diff --git a/src/plugins/debugger/gdb/classicgdbengine.cpp b/src/plugins/debugger/gdb/classicgdbengine.cpp
index 3c5ddcbec4ea7b9c37ad9c2acd7c8c198e441929..e59c0cfa2f6d7f475a1df3918e9a14656df61718 100644
--- a/src/plugins/debugger/gdb/classicgdbengine.cpp
+++ b/src/plugins/debugger/gdb/classicgdbengine.cpp
@@ -224,9 +224,9 @@ void GdbEngine::updateSubItemClassic(const WatchData &data0)
 {
     PRECONDITION;
     WatchData data = data0;
-    #if DEBUG_SUBITEM
+#    if DEBUG_SUBITEM
     qDebug() << "UPDATE SUBITEM:" << data.toString();
-    #endif
+#    endif
     QTC_ASSERT(data.isValid(), return);
 
     // in any case we need the type first
@@ -235,16 +235,16 @@ void GdbEngine::updateSubItemClassic(const WatchData &data0)
         // Let's play safe, though.
         if (!data.variable.isEmpty()) {
             // Update: It does so for out-of-scope watchers.
-            #if 1
+#            if 1
             qDebug() << "FIXME: GdbEngine::updateSubItem:"
                  << data.toString() << "should not happen";
-            #else
+#            else
             data.setType(WatchData::msgNotInScope());
             data.setValue(WatchData::msgNotInScope());
             data.setHasChildren(false);
             insertData(data);
             return;
-            #endif
+#            endif
         }
         // The WatchVarCreate handler will receive type information
         // and re-insert a WatchData item with correct type, so
@@ -261,9 +261,9 @@ void GdbEngine::updateSubItemClassic(const WatchData &data0)
     if (data.isChildrenNeeded() && isPointerType(data.type)
         && !hasDebuggingHelperForType(data.type)) {
         // We sometimes know what kind of children pointers have
-        #if DEBUG_SUBITEM
+#        if DEBUG_SUBITEM
         qDebug() << "IT'S A POINTER";
-        #endif
+#        endif
 
         if (theDebuggerBoolSetting(AutoDerefPointers)) {
             // Try automatic dereferentiation
@@ -286,9 +286,9 @@ void GdbEngine::updateSubItemClassic(const WatchData &data0)
     }
 
     if (data.isValueNeeded() && hasDebuggingHelperForType(data.type)) {
-        #if DEBUG_SUBITEM
+#        if DEBUG_SUBITEM
         qDebug() << "UPDATE SUBITEM: CUSTOMVALUE";
-        #endif
+#        endif
         runDebuggingHelperClassic(data,
             manager()->watchHandler()->isExpandedIName(data.iname));
         return;
@@ -296,9 +296,9 @@ void GdbEngine::updateSubItemClassic(const WatchData &data0)
 
 /*
     if (data.isValueNeeded() && data.exp.isEmpty()) {
-        #if DEBUG_SUBITEM
+#        if DEBUG_SUBITEM
         qDebug() << "UPDATE SUBITEM: NO EXPRESSION?";
-        #endif
+#        endif
         data.setError("<no expression given>");
         insertData(data);
         return;
@@ -306,9 +306,9 @@ void GdbEngine::updateSubItemClassic(const WatchData &data0)
 */
 
     if (data.isValueNeeded() && data.variable.isEmpty()) {
-        #if DEBUG_SUBITEM
+#        if DEBUG_SUBITEM
         qDebug() << "UPDATE SUBITEM: VARIABLE NEEDED FOR VALUE";
-        #endif
+#        endif
         createGdbVariableClassic(data);
         // the WatchVarCreate handler will re-insert a WatchData
         // item, with valueNeeded() set.
@@ -317,9 +317,9 @@ void GdbEngine::updateSubItemClassic(const WatchData &data0)
 
     if (data.isValueNeeded()) {
         QTC_ASSERT(!data.variable.isEmpty(), return); // tested above
-        #if DEBUG_SUBITEM
+#        if DEBUG_SUBITEM
         qDebug() << "UPDATE SUBITEM: VALUE";
-        #endif
+#        endif
         QByteArray cmd = "-var-evaluate-expression \"" + data.iname + '"';
         postCommand(cmd, WatchUpdate,
             CB(handleEvaluateExpressionClassic), QVariant::fromValue(data));
@@ -327,17 +327,17 @@ void GdbEngine::updateSubItemClassic(const WatchData &data0)
     }
 
     if (data.isChildrenNeeded() && hasDebuggingHelperForType(data.type)) {
-        #if DEBUG_SUBITEM
+#        if DEBUG_SUBITEM
         qDebug() << "UPDATE SUBITEM: CUSTOMVALUE WITH CHILDREN";
-        #endif
+#        endif
         runDebuggingHelperClassic(data, true);
         return;
     }
 
     if (data.isChildrenNeeded() && data.variable.isEmpty()) {
-        #if DEBUG_SUBITEM
+#        if DEBUG_SUBITEM
         qDebug() << "UPDATE SUBITEM: VARIABLE NEEDED FOR CHILDREN";
-        #endif
+#        endif
         createGdbVariableClassic(data);
         // the WatchVarCreate handler will re-insert a WatchData
         // item, with childrenNeeded() set.
@@ -353,9 +353,9 @@ void GdbEngine::updateSubItemClassic(const WatchData &data0)
     }
 
     if (data.isHasChildrenNeeded() && hasDebuggingHelperForType(data.type)) {
-        #if DEBUG_SUBITEM
+#        if DEBUG_SUBITEM
         qDebug() << "UPDATE SUBITEM: CUSTOMVALUE WITH CHILDREN";
-        #endif
+#        endif
         runDebuggingHelperClassic(data,
             manager()->watchHandler()->isExpandedIName(data.iname));
         return;
@@ -363,9 +363,9 @@ void GdbEngine::updateSubItemClassic(const WatchData &data0)
 
 //#if !X
     if (data.isHasChildrenNeeded() && data.variable.isEmpty()) {
-        #if DEBUG_SUBITEM
+#        if DEBUG_SUBITEM
         qDebug() << "UPDATE SUBITEM: VARIABLE NEEDED FOR CHILDCOUNT";
-        #endif
+#        endif
         createGdbVariableClassic(data);
         // the WatchVarCreate handler will re-insert a WatchData
         // item, with childrenNeeded() set.
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index c5fb4b3c76cbe3c673632fa528e2015deecc2c7f..f3c60768200744a8a71248a066b36459b1a1602d 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -657,13 +657,13 @@ void GdbEngine::readGdbStandardOutput()
         scan = newstart;
         if (end == start)
             continue;
-        #if defined(Q_OS_WIN)
+#        if defined(Q_OS_WIN)
         if (m_inbuffer.at(end - 1) == '\r') {
             --end;
             if (end == start)
                 continue;
         }
-        #endif
+#        endif
         m_busy = true;
         handleResponse(QByteArray::fromRawData(m_inbuffer.constData() + start, end - start));
         m_busy = false;
@@ -1149,7 +1149,7 @@ void GdbEngine::handleAqcuiredInferior()
 
     tryLoadDebuggingHelpers();
 
-    #ifndef Q_OS_MAC
+#    ifndef Q_OS_MAC
     // intentionally after tryLoadDebuggingHelpers(),
     // otherwise we'd interrupt solib loading.
     if (theDebuggerBoolSetting(AllPluginBreakpoints)) {
@@ -1166,7 +1166,7 @@ void GdbEngine::handleAqcuiredInferior()
         postCommand("set auto-solib-add off");
         postCommand("set stop-on-solib-events 0");
     }
-    #endif
+#    endif
 
     // It's nicer to see a bit of the world we live in.
     reloadModulesInternal();
@@ -2847,7 +2847,7 @@ void GdbEngine::handleStackListFrames(const GdbResponse &response)
         stackFrames.append(parseStackFrame(stack.childAt(i), i));
         const StackFrame &frame = stackFrames.back();
 
-        #if defined(Q_OS_WIN)
+#        if defined(Q_OS_WIN)
         const bool isBogus =
             // Assume this is wrong and points to some strange stl_algobase
             // implementation. Happens on Karsten's XP system with Gdb 5.50
@@ -2863,7 +2863,7 @@ void GdbEngine::handleStackListFrames(const GdbResponse &response)
             showStatusMessage(tr("Jumping out of bogus frame..."), 1000);
             return;
         }
-        #endif
+#        endif
 
         // Initialize top frame to the first valid frame.
         const bool isValid = frame.isUsable() && !frame.function.isEmpty();
@@ -3401,11 +3401,11 @@ void GdbEngine::updateWatchDataHelper(const WatchData &data)
 {
     //m_pendingRequests = 0;
     PENDING_DEBUG("UPDATE WATCH DATA");
-    #if DEBUG_PENDING
+#    if DEBUG_PENDING
     //qDebug() << "##############################################";
     qDebug() << "UPDATE MODEL, FOUND INCOMPLETE:";
     //qDebug() << data.toString();
-    #endif
+#    endif
 
     updateSubItemClassic(data);
     //PENDING_DEBUG("INTERNAL TRIGGERING UPDATE WATCH MODEL");
diff --git a/src/plugins/debugger/gdb/trkgdbadapter.cpp b/src/plugins/debugger/gdb/trkgdbadapter.cpp
index f64fbdf6ee58c51a34eb76e0b1e1b55060bd2955..20912fd32d47f050c6b42764e06f2f2d8c20cef2 100644
--- a/src/plugins/debugger/gdb/trkgdbadapter.cpp
+++ b/src/plugins/debugger/gdb/trkgdbadapter.cpp
@@ -1151,26 +1151,26 @@ void TrkGdbAdapter::handleTrkResult(const TrkResult &result)
                 logMessage(QLatin1String("Ignoring stop at 0"));
             }
 
-            #if 1
+#            if 1
             // We almost always need register values, so get them
             // now before informing gdb about the stop.s
             //qDebug() << "Auto-fetching registers";
             sendTrkMessage(0x12,
                 TrkCB(handleAndReportReadRegistersAfterStop),
                 trkReadRegistersMessage());
-            #else
+#            else
             // As a source-line step typically consists of
             // several instruction steps, better avoid the multiple
             // roundtrips through TRK in favour of an additional
             // roundtrip through gdb. But gdb will ask for all registers.
-                #if 1
+#                if 1
                 sendGdbServerMessage("S05", "Target stopped");
-                #else
+#                else
                 QByteArray ba = "T05";
                 appendRegister(&ba, RegisterPSGdb, addr);
                 sendGdbServerMessage(ba, "Registers");
-                #endif
-            #endif
+#                endif
+#            endif
             break;
         }
         case TrkNotifyException: { // 0x91 Notify Exception (obsolete)
@@ -1522,14 +1522,14 @@ void TrkGdbAdapter::tryAnswerGdbMemoryRequest(bool buffered)
         // Happens when chunks are not combined
         QTC_ASSERT(false, /**/);
         debugMessage("CHUNKS NOT COMBINED");
-        #ifdef MEMORY_DEBUG
+#        ifdef MEMORY_DEBUG
         qDebug() << "CHUNKS NOT COMBINED";
         it = m_snapshot.memory.begin();
         et = m_snapshot.memory.end();
         for ( ; it != et; ++it)
             qDebug() << hexNumber(it.key().from) << hexNumber(it.key().to);
         qDebug() << "WANTED" << wanted.from << wanted.to;
-        #endif
+#        endif
         sendGdbServerMessage("E22", "");
         return;
     }
diff --git a/src/plugins/debugger/qml/qml.pri b/src/plugins/debugger/qml/qml.pri
new file mode 100644
index 0000000000000000000000000000000000000000..dc9d548c57b0ad72d46ddfbe9cbefbb21e13f9b8
--- /dev/null
+++ b/src/plugins/debugger/qml/qml.pri
@@ -0,0 +1,9 @@
+HEADERS += \
+    $$PWD/qmlengine.h \
+
+SOURCES += \
+    $$PWD/qmlengine.cpp \
+
+FORMS +=
+
+RESOURCES +=
diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3ff65a1dfe523d970af7e196a358422840a36b25
--- /dev/null
+++ b/src/plugins/debugger/qml/qmlengine.cpp
@@ -0,0 +1,544 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#include "qmlengine.h"
+
+#include "debuggerstringutils.h"
+#include "debuggerdialogs.h"
+#include "breakhandler.h"
+#include "debuggerconstants.h"
+#include "debuggermanager.h"
+#include "moduleshandler.h"
+#include "registerhandler.h"
+#include "stackhandler.h"
+#include "watchhandler.h"
+#include "watchutils.h"
+#include "moduleshandler.h"
+
+#include <utils/qtcassert.h>
+
+#include <QtCore/QDateTime>
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
+#include <QtCore/QTimer>
+
+#include <QtGui/QAction>
+#include <QtGui/QApplication>
+#include <QtGui/QMainWindow>
+#include <QtGui/QMessageBox>
+#include <QtGui/QToolTip>
+
+#include <QtNetwork/QTcpSocket>
+
+#define DEBUG_QML 1
+#if DEBUG_QML
+#   define SDEBUG(s) qDebug() << s
+#else
+#   define SDEBUG(s)
+#endif
+# define XSDEBUG(s) qDebug() << s
+
+#define CB(callback) &QmlEngine::callback, STRINGIFY(callback)
+
+//#define USE_CONGESTION_CONTROL
+
+
+namespace Debugger {
+namespace Internal {
+
+
+class QmlResponse
+{
+public:
+    QmlResponse() {}
+    QmlResponse(const QByteArray &data_) : data(data_) {}
+
+    QString toString() const { return data; }
+
+    QByteArray data;
+};
+
+///////////////////////////////////////////////////////////////////////
+//
+// QmlCommand
+//
+///////////////////////////////////////////////////////////////////////
+
+
+QString QmlEngine::QmlCommand::toString() const
+{
+    return quoteUnprintableLatin1(command);
+}
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// QmlEngine
+//
+///////////////////////////////////////////////////////////////////////
+
+QmlEngine::QmlEngine(DebuggerManager *manager)
+    : IDebuggerEngine(manager)
+{
+    m_congestion = 0;
+    m_inAir = 0;
+
+    m_sendTimer.setSingleShot(true);
+    m_sendTimer.setInterval(100); // ms
+    connect(&m_sendTimer, SIGNAL(timeout()), this, SLOT(handleSendTimer()));
+
+    m_socket = new QTcpSocket(this);
+    connect(m_socket, SIGNAL(connected()), this, SLOT(socketConnected()));
+    connect(m_socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
+    connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)),
+        this, SLOT(socketError(QAbstractSocket::SocketError)));
+
+    //void aboutToClose ()
+    //void bytesWritten ( qint64 bytes )
+    //void readChannelFinished ()
+    connect(m_socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead()));
+
+    //connect(m_socket, SIGNAL(hostFound())
+    //connect(m_socket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy, QAuthenticator *)))
+    //connect(m_socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
+    //    thism SLOT(socketStateChanged(QAbstractSocket::SocketState)));
+}
+
+QmlEngine::~QmlEngine()
+{
+}
+
+void QmlEngine::socketReadyRead()
+{
+    //XSDEBUG("QmlEngine::socketReadyRead()");
+    m_inbuffer.append(m_socket->readAll());
+    int pos = 0;
+    while (1) {
+        // the  "\3" is followed by either "\1" or "\2"
+        int next = m_inbuffer.indexOf("\3", pos);
+        //qDebug() << "pos: " << pos << "next: " << next;
+        if (next == -1)
+            break;
+        handleResponse(m_inbuffer.mid(pos, next - pos));
+        pos = next + 2;
+    }
+    m_inbuffer.clear();
+}
+
+void QmlEngine::socketConnected()
+{
+    showStatusMessage("Socket connected.");
+    m_socket->waitForConnected(2000);
+    //sendCommand("Locator", "redirect", "ID");
+}
+
+void QmlEngine::socketDisconnected()
+{
+    XSDEBUG("FIXME:  QmlEngine::socketDisconnected()");
+}
+
+void QmlEngine::socketError(QAbstractSocket::SocketError)
+{
+    QString msg = tr("%1.").arg(m_socket->errorString());
+    //QMessageBox::critical(q->mainWindow(), tr("Error"), msg);
+    showStatusMessage(msg);
+    manager()->notifyInferiorExited();
+}
+
+void QmlEngine::executeDebuggerCommand(const QString &command)
+{
+    QByteArray cmd = command.toUtf8();
+    cmd = cmd.mid(cmd.indexOf(' ') + 1);
+    QByteArray null;
+    null.append('\0');
+    // FIXME: works for single-digit escapes only
+    cmd.replace("\\0", null);
+    cmd.replace("\\1", "\1");
+    cmd.replace("\\3", "\3");
+    QmlCommand tcf;
+    tcf.command = cmd;
+    enqueueCommand(tcf);
+}
+
+void QmlEngine::shutdown()
+{
+    m_congestion = 0;
+    m_inAir = 0;
+    m_services.clear();
+    exitDebugger();
+}
+
+void QmlEngine::exitDebugger()
+{
+    SDEBUG("QmlEngine::exitDebugger()");
+    manager()->notifyInferiorExited();
+}
+
+void QmlEngine::startDebugger(const DebuggerStartParametersPtr &sp)
+{
+    qDebug() << "STARTING QML ENGINE";
+    setState(InferiorRunningRequested);
+    showStatusMessage(tr("Running requested..."), 5000);
+    const int pos = sp->remoteChannel.indexOf(QLatin1Char(':'));
+    const QString host = sp->remoteChannel.left(pos);
+    const quint16 port = sp->remoteChannel.mid(pos + 1).toInt();
+    //QTimer::singleShot(0, this, SLOT(runInferior()));
+    m_socket->connectToHost(host, port);
+    emit startSuccessful();
+}
+
+void QmlEngine::continueInferior()
+{
+    SDEBUG("QmlEngine::continueInferior()");
+}
+
+void QmlEngine::runInferior()
+{
+}
+
+void QmlEngine::interruptInferior()
+{
+    XSDEBUG("QmlEngine::interruptInferior()");
+}
+
+void QmlEngine::executeStep()
+{
+    //SDEBUG("QmlEngine::executeStep()");
+}
+
+void QmlEngine::executeStepI()
+{
+    //SDEBUG("QmlEngine::executeStepI()");
+}
+
+void QmlEngine::executeStepOut()
+{
+    //SDEBUG("QmlEngine::executeStepOut()");
+}
+
+void QmlEngine::executeNext()
+{
+    //SDEBUG("QmlEngine::nextExec()");
+}
+
+void QmlEngine::executeNextI()
+{
+    //SDEBUG("QmlEngine::executeNextI()");
+}
+
+void QmlEngine::executeRunToLine(const QString &fileName, int lineNumber)
+{
+    Q_UNUSED(fileName)
+    Q_UNUSED(lineNumber)
+    SDEBUG("FIXME:  QmlEngine::executeRunToLine()");
+}
+
+void QmlEngine::executeRunToFunction(const QString &functionName)
+{
+    Q_UNUSED(functionName)
+    XSDEBUG("FIXME:  QmlEngine::executeRunToFunction()");
+}
+
+void QmlEngine::executeJumpToLine(const QString &fileName, int lineNumber)
+{
+    Q_UNUSED(fileName)
+    Q_UNUSED(lineNumber)
+    XSDEBUG("FIXME:  QmlEngine::executeJumpToLine()");
+}
+
+void QmlEngine::activateFrame(int index)
+{
+    Q_UNUSED(index)
+}
+
+void QmlEngine::selectThread(int index)
+{
+    Q_UNUSED(index)
+}
+
+void QmlEngine::attemptBreakpointSynchronization()
+{
+}
+
+void QmlEngine::loadSymbols(const QString &moduleName)
+{
+    Q_UNUSED(moduleName)
+}
+
+void QmlEngine::loadAllSymbols()
+{
+}
+
+void QmlEngine::reloadModules()
+{
+}
+
+void QmlEngine::requestModuleSymbols(const QString &moduleName)
+{
+    Q_UNUSED(moduleName)
+}
+
+
+void QmlEngine::handleResponse(const QByteArray &response)
+{
+    Q_UNUSED(response);
+/*
+    static QTime lastTime;
+
+    //debugMessage(_("            "), currentTime());
+    QList<QByteArray> parts = response.split('\0');
+    if (parts.size() < 2 || !parts.last().isEmpty()) {
+        SDEBUG("WRONG RESPONSE PACKET LAYOUT" << parts);
+        //if (response.isEmpty())
+            acknowledgeResult();
+        return;
+    }
+    parts.removeLast(); // always empty
+    QByteArray tag = parts.at(0);
+    int n = parts.size();
+    if (n == 2 && tag == "N") { // unidentified command
+        int token = parts.at(1).toInt();
+        QmlCommand tcf = m_cookieForToken[token];
+        SDEBUG("COMMAND NOT RECOGNIZED FOR TOKEN" << token << tcf.toString());
+        showDebuggerOutput(LogOutput, QString::number(token) + "^"
+               + "NOT RECOQNIZED: " + quoteUnprintableLatin1(response));
+        acknowledgeResult();
+    } else if (n == 2 && tag == "F") { // flow control
+        m_congestion = parts.at(1).toInt();
+        SDEBUG("CONGESTION: " << m_congestion);
+    } else if (n == 4 && tag == "R") { // result data
+        acknowledgeResult();
+        int token = parts.at(1).toInt();
+        QByteArray message = parts.at(2);
+        QmlResponse data(parts.at(3));
+        showDebuggerOutput(LogOutput, QString("%1^%2%3").arg(token)
+            .arg(quoteUnprintableLatin1(response))
+            .arg(QString::fromUtf8(data.toString())));
+        QmlCommand tcf = m_cookieForToken[token];
+        QmlResponse result(data);
+        SDEBUG("GOOD RESPONSE: " << quoteUnprintableLatin1(response));
+        if (tcf.callback)
+            (this->*(tcf.callback))(result, tcf.cookie);
+    } else if (n == 3 && tag == "P") { // progress data (partial result)
+        //int token = parts.at(1).toInt();
+        QByteArray data = parts.at(2);
+        SDEBUG(_("\nTCF PARTIAL:") << quoteUnprintableLatin1(response));
+    } else if (n == 4 && tag == "E") { // an event
+        QByteArray service = parts.at(1);
+        QByteArray eventName = parts.at(2);
+        QmlResponse data(parts.at(3));
+        if (eventName != "peerHeartBeat")
+            SDEBUG(_("\nTCF EVENT:") << quoteUnprintableLatin1(response)
+                << data.toString());
+        if (service == "Locator" && eventName == "Hello") {
+            m_services.clear();
+            foreach (const QmlResponse &service, data.children())
+                m_services.append(service.data());
+            QTimer::singleShot(0, this, SLOT(startDebugging()));
+        }
+    } else {
+        SDEBUG("UNKNOWN RESPONSE PACKET:"
+            << quoteUnprintableLatin1(response) << parts);
+    }
+*/
+}
+
+void QmlEngine::startDebugging()
+{
+    qDebug() << "START";
+}
+
+void QmlEngine::postCommand(const QByteArray &cmd,
+    QmlCommandCallback callback, const char *callbackName)
+{
+/*
+    static int token = 20;
+    ++token;
+
+    //const char marker_eom = -1;
+    //const char marker_eos = -2;
+    //const char marker_null = -3;
+
+    QByteArray ba = "C";
+    ba.append('\0');
+    ba.append(QByteArray::number(token));
+    ba.append('\0');
+    ba.append(cmd);
+    ba.append('\0');
+    ba.append('\3');
+    ba.append('\1');
+
+    QmlCommand tcf;
+    tcf.command = ba;
+    tcf.callback = callback;
+    tcf.callbackName = callbackName;
+    tcf.token = token;
+
+    m_cookieForToken[token] = tcf;
+
+    enqueueCommand(tcf);
+*/
+}
+
+// Congestion control does not seem to work that way. Basically it's
+// already too late when we get a flow control packet
+void QmlEngine::enqueueCommand(const QmlCommand &cmd)
+{
+/*
+#ifdef USE_CONGESTION_CONTROL
+    // congestion controled
+    if (m_congestion <= 0 && m_sendQueue.isEmpty()) {
+        //SDEBUG("DIRECT SEND" << cmd.toString());
+        sendCommandNow(cmd);
+    } else {
+        SDEBUG("QUEUE " << cmd.toString());
+        m_sendQueue.enqueue(cmd);
+        m_sendTimer.start();
+    }
+#else
+    // synchrounously
+    if (m_inAir == 0)
+        sendCommandNow(cmd);
+    else
+        m_sendQueue.enqueue(cmd);
+#endif
+*/
+}
+
+void QmlEngine::handleSendTimer()
+{
+/*
+    QTC_ASSERT(!m_sendQueue.isEmpty(), return);
+
+    if (m_congestion > 0) {
+        // not ready...
+        SDEBUG("WAITING FOR CONGESTION TO GO DOWN...");
+        m_sendTimer.start();
+    } else {
+        // go!
+        sendCommandNow(m_sendQueue.dequeue());
+    }
+*/
+}
+
+void QmlEngine::sendCommandNow(const QmlCommand &cmd)
+{
+    ++m_inAir;
+    int result = m_socket->write(cmd.command);
+    Q_UNUSED(result)
+    m_socket->flush();
+    showDebuggerInput(LogInput, QString::number(cmd.token) + " " + cmd.toString());
+    SDEBUG("SEND " <<  cmd.toString()); //<< " " << QString::number(result));
+}
+
+void QmlEngine::acknowledgeResult()
+{
+#if !defined(USE_CONGESTION_CONTROL)
+    QTC_ASSERT(m_inAir == 1, /**/);
+    m_inAir = 0;
+    if (!m_sendQueue.isEmpty())
+        sendCommandNow(m_sendQueue.dequeue());
+#endif
+}
+
+void QmlEngine::handleRunControlSuspend(const QmlResponse &data, const QVariant &)
+{
+    SDEBUG("HANDLE RESULT" << data.toString());
+}
+
+void QmlEngine::handleRunControlGetChildren(const QmlResponse &data, const QVariant &)
+{
+    SDEBUG("HANDLE RUN CONTROL GET CHILDREN" << data.toString());
+}
+
+void QmlEngine::handleSysMonitorGetChildren(const QmlResponse &data, const QVariant &)
+{
+    SDEBUG("HANDLE RUN CONTROL GET CHILDREN" << data.toString());
+}
+
+
+//////////////////////////////////////////////////////////////////////
+//
+// Tooltip specific stuff
+//
+//////////////////////////////////////////////////////////////////////
+
+static WatchData m_toolTip;
+static QPoint m_toolTipPos;
+static QHash<QString, WatchData> m_toolTipCache;
+
+void QmlEngine::setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos)
+{
+    Q_UNUSED(mousePos)
+    Q_UNUSED(editor)
+    Q_UNUSED(cursorPos)
+}
+
+//////////////////////////////////////////////////////////////////////
+//
+// Watch specific stuff
+//
+//////////////////////////////////////////////////////////////////////
+
+void QmlEngine::assignValueInDebugger(const QString &expression,
+    const QString &value)
+{
+    XSDEBUG("ASSIGNING: " << expression + '=' + value);
+    updateLocals();
+}
+
+void QmlEngine::updateLocals()
+{
+}
+
+void QmlEngine::updateWatchData(const WatchData &)
+{
+    //qq->watchHandler()->rebuildModel();
+    showStatusMessage(tr("Stopped."), 5000);
+}
+
+void QmlEngine::updateSubItem(const WatchData &data0)
+{
+    Q_UNUSED(data0)
+    QTC_ASSERT(false, return);
+}
+
+void QmlEngine::debugMessage(const QString &msg)
+{
+    showDebuggerOutput(LogDebug, msg);
+}
+
+IDebuggerEngine *createQmlEngine(DebuggerManager *manager)
+{
+    return new QmlEngine(manager);
+}
+
+} // namespace Internal
+} // namespace Debugger
diff --git a/src/plugins/debugger/qml/qmlengine.h b/src/plugins/debugger/qml/qmlengine.h
new file mode 100644
index 0000000000000000000000000000000000000000..3b85c3c9dbc3d00c9108ca29c7495393b16f465e
--- /dev/null
+++ b/src/plugins/debugger/qml/qmlengine.h
@@ -0,0 +1,168 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+**
+**************************************************************************/
+
+#ifndef DEBUGGER_QMLENGINE_H
+#define DEBUGGER_QMLENGINE_H
+
+#include <QtCore/QByteArray>
+#include <QtCore/QHash>
+#include <QtCore/QMap>
+#include <QtCore/QObject>
+#include <QtCore/QPoint>
+#include <QtCore/QProcess>
+#include <QtCore/QQueue>
+#include <QtCore/QSet>
+#include <QtCore/QTimer>
+#include <QtCore/QVariant>
+
+#include <QtNetwork/QAbstractSocket>
+
+QT_BEGIN_NAMESPACE
+class QTcpSocket;
+QT_END_NAMESPACE
+
+#include "idebuggerengine.h"
+#include "debuggermanager.h"
+
+namespace Debugger {
+namespace Internal {
+
+class ScriptAgent;
+class WatchData;
+class QmlResponse;
+
+class QmlEngine : public IDebuggerEngine
+{
+    Q_OBJECT
+
+public:
+    explicit QmlEngine(DebuggerManager *parent);
+    ~QmlEngine();
+
+private:
+    // IDebuggerEngine implementation
+    void executeStep();
+    void executeStepOut();
+    void executeNext();
+    void executeStepI();
+    void executeNextI();
+
+    void shutdown();
+    void setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos);
+    void startDebugger(const DebuggerStartParametersPtr &sp);
+    void exitDebugger();
+
+    void continueInferior();
+    Q_SLOT void runInferior();
+    void interruptInferior();
+
+    void executeRunToLine(const QString &fileName, int lineNumber);
+    void executeRunToFunction(const QString &functionName);
+    void executeJumpToLine(const QString &fileName, int lineNumber);
+
+    void activateFrame(int index);
+    void selectThread(int index);
+
+    void attemptBreakpointSynchronization();
+
+    void assignValueInDebugger(const QString &expr, const QString &value);
+    void executeDebuggerCommand(const QString & command);
+
+    void loadSymbols(const QString &moduleName);
+    void loadAllSymbols();
+    void requestModuleSymbols(const QString &moduleName);
+    void reloadModules();
+    void reloadRegisters() {}
+    void reloadSourceFiles() {}
+    void reloadFullStack() {}
+
+    bool supportsThreads() const { return true; }
+    void maybeBreakNow(bool byFunction);
+    void updateWatchData(const WatchData &data);
+    void updateLocals();
+    void updateSubItem(const WatchData &data);
+
+    Q_SLOT void socketConnected();
+    Q_SLOT void socketDisconnected();
+    Q_SLOT void socketError(QAbstractSocket::SocketError);
+    Q_SLOT void socketReadyRead();
+
+    void handleResponse(const QByteArray &ba);
+    void handleRunControlSuspend(const QmlResponse &response, const QVariant &);
+    void handleRunControlGetChildren(const QmlResponse &response, const QVariant &);
+    void handleSysMonitorGetChildren(const QmlResponse &response, const QVariant &);
+
+private:
+    Q_SLOT void startDebugging();
+
+    typedef void (QmlEngine::*QmlCommandCallback)
+        (const QmlResponse &record, const QVariant &cookie);
+
+    struct QmlCommand
+    {
+        QmlCommand() : flags(0), token(-1), callback(0), callbackName(0) {}
+
+        QString toString() const;
+
+        int flags;
+        int token;
+        QmlCommandCallback callback;
+        const char *callbackName;
+        QByteArray command;
+        QVariant cookie;
+    };
+
+    void postCommand(const QByteArray &cmd,
+        QmlCommandCallback callback = 0, const char *callbackName = 0);
+    void sendCommandNow(const QmlCommand &command);
+    void debugMessage(const QString &msg);
+
+    QHash<int, QmlCommand> m_cookieForToken;
+
+    QQueue<QmlCommand> m_sendQueue;
+    
+    // timer based congestion control. does not seem to work well.
+    void enqueueCommand(const QmlCommand &command);
+    Q_SLOT void handleSendTimer();
+    int m_congestion;
+    QTimer m_sendTimer;
+
+    // synchrounous communication
+    void acknowledgeResult();
+    int m_inAir;
+
+    QTcpSocket *m_socket;
+    QByteArray m_inbuffer;
+    QList<QByteArray> m_services;
+};
+
+} // namespace Internal
+} // namespace Debugger
+
+#endif // DEBUGGER_QMLENGINE_H
diff --git a/src/plugins/debugger/stackwindow.cpp b/src/plugins/debugger/stackwindow.cpp
index 74f37ad5069cee2a29d0b9f1b85a9349b70a35e2..92791ffddf23b574613aabd959939913c3497520 100644
--- a/src/plugins/debugger/stackwindow.cpp
+++ b/src/plugins/debugger/stackwindow.cpp
@@ -172,9 +172,9 @@ void StackWindow::copyContentsToClipboard()
         str += '\n';
     }
     QClipboard *clipboard = QApplication::clipboard();
-    #ifdef Q_WS_X11
+#    ifdef Q_WS_X11
     clipboard->setText(str, QClipboard::Selection);
-    #endif
+#    endif
     clipboard->setText(str, QClipboard::Clipboard);
 }
 
diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp
index 35d87ae71e8f6a591b9aea75739a0fd1a900311e..f080c15f161bb725117ca69d84dc8b95552b4fc3 100644
--- a/src/plugins/fakevim/fakevimplugin.cpp
+++ b/src/plugins/fakevim/fakevimplugin.cpp
@@ -733,7 +733,7 @@ void FakeVimPluginPrivate::setActionChecked(const QString &code, bool check)
 
 void FakeVimPluginPrivate::windowCommand(int key)
 {
-    #define control(n) (256 + n)
+#    define control(n) (256 + n)
     QString code;
     switch (key) {
         case 'c': case 'C': case control('c'):
@@ -756,7 +756,7 @@ void FakeVimPluginPrivate::windowCommand(int key)
             code = Core::Constants::GOTO_OTHER_SPLIT;
             break;
     }
-    #undef control
+#    undef control
     //qDebug() << "RUNNING WINDOW COMMAND: " << key << code;
     if (code.isEmpty()) {
         //qDebug() << "UNKNOWN WINDOWS COMMAND: " << key;
diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
index ad6a973f3868234775c3ede3748f12bf127c7856..6e27c7b8502beeb334d7fbaec2a62c4cba207f68 100644
--- a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
+++ b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
@@ -45,11 +45,11 @@ NavigatorTreeModel::NavigatorTreeModel(QObject *parent)
 {
     invisibleRootItem()->setFlags(Qt::ItemIsDropEnabled);
 
-    #ifdef _LOCK_ITEMS_
+#    ifdef _LOCK_ITEMS_
     setColumnCount(3);
-    #else
+#    else
     setColumnCount(2);
-    #endif
+#    endif
 
     setSupportedDragActions(Qt::LinkAction);
 
@@ -194,14 +194,14 @@ NavigatorTreeModel::ItemRow NavigatorTreeModel::createItemRow(const ModelNode &n
     idItem->setEditable(true);
     idItem->setData(hash, Qt::UserRole);
 
-    #ifdef _LOCK_ITEMS_
+#    ifdef _LOCK_ITEMS_
     QStandardItem *lockItem = new QStandardItem;
     lockItem->setDragEnabled(true);
     lockItem->setDropEnabled(dropEnabled);
     lockItem->setEditable(false);
     lockItem->setCheckable(true);
     lockItem->setData(hash, Qt::UserRole);
-    #endif
+#    endif
 
     QStandardItem *visibilityItem = new QStandardItem;
     visibilityItem->setDropEnabled(dropEnabled);
@@ -212,11 +212,11 @@ NavigatorTreeModel::ItemRow NavigatorTreeModel::createItemRow(const ModelNode &n
         visibilityItem->setCheckable(false);
     }
 
-    #ifdef _LOCK_ITEMS_
+#    ifdef _LOCK_ITEMS_
     return ItemRow(idItem, lockItem, visibilityItem);
-    #else
+#    else
     return ItemRow(idItem, visibilityItem);
-    #endif
+#    endif
 }
 
 void NavigatorTreeModel::updateItemRow(const ModelNode &node, ItemRow items)
diff --git a/src/plugins/qmldesigner/designercore/model/propertyparser.h b/src/plugins/qmldesigner/designercore/model/propertyparser.h
index e8c86a8457697f800e5d23a9ada884bd71bd4a4a..0bff861b3925a786d81009cf1084ef774d0b7329 100644
--- a/src/plugins/qmldesigner/designercore/model/propertyparser.h
+++ b/src/plugins/qmldesigner/designercore/model/propertyparser.h
@@ -27,7 +27,7 @@
 **
 **************************************************************************/
 
-    #ifndef PROPERTYPARSER_H
+#ifndef PROPERTYPARSER_H
 #define PROPERTYPARSER_H
 
 #include <QtCore/QVariant>
diff --git a/src/plugins/qmlprojectmanager/qmlprojectmanagerconstants.h b/src/plugins/qmlprojectmanager/qmlprojectmanagerconstants.h
index bcd4c4856c942dbd8a7a8cd31b3277922cf831ad..7042a06b6886bfedbdd67783c2b0ef24f12cc7bf 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectmanagerconstants.h
+++ b/src/plugins/qmlprojectmanager/qmlprojectmanagerconstants.h
@@ -32,17 +32,17 @@
 namespace QmlProjectManager {
 namespace Constants {
 
-const char * const QML_RC_ID("QmlProjectManager.QmlRunConfiguration");
-const char * const QML_RC_DISPLAY_NAME(QT_TRANSLATE_NOOP("QmlProjectManager::Internal::QmlRunConfiguration", "QML Viewer"));
-const char * const QML_VIEWER_KEY("QmlProjectManager.QmlRunConfiguration.QDeclarativeViewer");
-const char * const QML_VIEWER_ARGUMENTS_KEY("QmlProjectManager.QmlRunConfiguration.QDeclarativeViewerArguments");
-const char * const QML_VIEWER_TARGET_ID("QmlProjectManager.QmlTarget");
-const char * const QML_VIEWER_TARGET_DISPLAY_NAME("QML Viewer");
-const char * const QML_MAINSCRIPT_KEY("QmlProjectManager.QmlRunConfiguration.MainScript");
-const char * const QML_DEBUG_SERVER_ADDRESS_KEY("QmlProjectManager.QmlRunConfiguration.DebugServerAddress");
-const char * const QML_DEBUG_SERVER_PORT_KEY("QmlProjectManager.QmlRunConfiguration.DebugServerPort");
+const char * const QML_RC_ID = "QmlProjectManager.QmlRunConfiguration";
+const char * const QML_RC_DISPLAY_NAME = QT_TRANSLATE_NOOP("QmlProjectManager::Internal::QmlRunConfiguration", "QML Viewer");
+const char * const QML_VIEWER_KEY = "QmlProjectManager.QmlRunConfiguration.QDeclarativeViewer";
+const char * const QML_VIEWER_ARGUMENTS_KEY = "QmlProjectManager.QmlRunConfiguration.QDeclarativeViewerArguments";
+const char * const QML_VIEWER_TARGET_ID = "QmlProjectManager.QmlTarget";
+const char * const QML_VIEWER_TARGET_DISPLAY_NAME = "QML Viewer";
+const char * const QML_MAINSCRIPT_KEY = "QmlProjectManager.QmlRunConfiguration.MainScript";
+const char * const QML_DEBUG_SERVER_ADDRESS_KEY = "QmlProjectManager.QmlRunConfiguration.DebugServerAddress";
+const char * const QML_DEBUG_SERVER_PORT_KEY = "QmlProjectManager.QmlRunConfiguration.DebugServerPort";
 
-const int QML_DEFAULT_DEBUG_SERVER_PORT(3768);
+const int QML_DEFAULT_DEBUG_SERVER_PORT = 3768;
 
 } // namespace Constants
 } // namespace QmlProjectManager
diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationfactory.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationfactory.cpp
index 640a96a85ea4236204958985581bd024e455735f..47ab035817456992728ce8fdce50b253c9a666a8 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationfactory.cpp
+++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfigurationfactory.cpp
@@ -72,13 +72,13 @@ ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::create(Pro
 {
     if (!canCreate(parent, id))
         return 0;
-    QmlProjectTarget *qmlparent(static_cast<QmlProjectTarget *>(parent));
+    QmlProjectTarget *qmlparent = static_cast<QmlProjectTarget *>(parent);
     return new QmlProjectRunConfiguration(qmlparent);
 }
 
 bool QmlProjectRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const
 {
-    QString id(ProjectExplorer::idFromMap(map));
+    QString id = ProjectExplorer::idFromMap(map);
     return canCreate(parent, id);
 }
 
@@ -86,8 +86,8 @@ ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::restore(Pr
 {
     if (!canRestore(parent, map))
         return 0;
-    QmlProjectTarget *qmlparent(static_cast<QmlProjectTarget *>(parent));
-    QmlProjectRunConfiguration *rc(new QmlProjectRunConfiguration(qmlparent));
+    QmlProjectTarget *qmlparent = static_cast<QmlProjectTarget *>(parent);
+    QmlProjectRunConfiguration *rc = new QmlProjectRunConfiguration(qmlparent);
     if (rc->fromMap(map))
         return rc;
     delete rc;
@@ -104,7 +104,7 @@ ProjectExplorer::RunConfiguration *QmlProjectRunConfigurationFactory::clone(Proj
 {
     if (!canClone(parent, source))
         return 0;
-    QmlProjectTarget *qmlparent(static_cast<QmlProjectTarget *>(parent));
+    QmlProjectTarget *qmlparent = static_cast<QmlProjectTarget *>(parent);
     return new QmlProjectRunConfiguration(qmlparent, qobject_cast<QmlProjectRunConfiguration *>(source));
 }
 
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp
index 1e6a9ea4d05fef30e35efa6a3cd5eea8130dde2a..b4ee8bd1312e50635a182ea7ccfccd3827bdf7a8 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/s60devicerunconfiguration.cpp
@@ -791,7 +791,10 @@ QMessageBox *S60DeviceRunControlBase::createTrkWaitingMessageBox(const QString &
     const QString title  = QCoreApplication::translate("Qt4ProjectManager::Internal::S60DeviceRunControlBase",
                                                        "Waiting for App TRK");
     const QString text = QCoreApplication::translate("Qt4ProjectManager::Internal::S60DeviceRunControlBase",
-                                                     "Please start App TRK on %1.").arg(port);
+                                                     "Qt creator waiting for the TRK application.<br>"
+                                                     "Please make sure the application is running on "
+                                                     "your mobile phone and the right port is "
+                                                     "configured in the project settings.").arg(port);
     QMessageBox *rc = new QMessageBox(QMessageBox::Information, title, text,
                                       QMessageBox::Cancel, parent);
     return rc;
diff --git a/src/shared/symbianutils/trkdevice.cpp b/src/shared/symbianutils/trkdevice.cpp
index 35ec22790afaccb3909c4278eaafc17bc0e31448..e0f29531a44e64624f37fee850d5f95720abada7 100644
--- a/src/shared/symbianutils/trkdevice.cpp
+++ b/src/shared/symbianutils/trkdevice.cpp
@@ -58,9 +58,9 @@
 /* Required headers for select() according to POSIX.1-2001 */
 #  include <sys/select.h>
 /* Required headers for select() according to earlier standards:
-       #include <sys/time.h>
-       #include <sys/types.h>
-       #include <unistd.h>
+#  include <sys/time.h>
+#  include <sys/types.h>
+#  include <unistd.h>
 */
 #endif
 
diff --git a/src/tools/qtlibspatcher/qtlibspatchermain.cpp b/src/tools/qtlibspatcher/qtlibspatchermain.cpp
index 07d60e07aad5078e8c87a4b134a19885c2b82ac2..d332bae55db54244e81dcda9903d90c5a98a0002 100644
--- a/src/tools/qtlibspatcher/qtlibspatchermain.cpp
+++ b/src/tools/qtlibspatcher/qtlibspatchermain.cpp
@@ -101,15 +101,15 @@ bool patchBinariesWithQtPathes(const char *baseQtPath)
     bool result = true;
 
     static const char *filesToPatch[] = {
-    #ifdef Q_OS_WIN
+#    ifdef Q_OS_WIN
         "/bin/qmake.exe",
         "/bin/QtCore4.dll",
         "/bin/QtCored4.dll",
         "/lib/QtCored4.dll"
-    #else
+#    else
         "/bin/qmake",
         "/lib/libQtCore.so",
-    #endif
+#    endif
     };
 
     for (int i = 0; i < (int)(sizeof(filesToPatch) / sizeof(filesToPatch[0])); i++) {
diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp
index b00388315ad0812ed48af2067da775061b42027c..167ce3190fcdf7b5b03e1fb9f90b1c486f1ece67 100644
--- a/tests/auto/debugger/tst_dumpers.cpp
+++ b/tests/auto/debugger/tst_dumpers.cpp
@@ -1323,7 +1323,7 @@ void tst_Debugger::dumpQLinkedList()
     dumpQLinkedListHelper(l3);
 }
 
-    #if 0
+#    if 0
     void tst_Debugger::dumpQLinkedList()
     {
         // Case 1: Simple element type.
@@ -1402,7 +1402,7 @@ void tst_Debugger::dumpQLinkedList()
         //dumpQLinkedListHelper(l3);
         testDumper("", &l, NS"QLinkedList", true, NS"QString");
     }
-    #endif
+#    endif
 
 void tst_Debugger::dumpQList_int()
 {
diff --git a/tests/auto/debugger/tst_gdb.cpp b/tests/auto/debugger/tst_gdb.cpp
index d4c374a545b417b67bb559e50d6ed227b2de646d..0533d94e3ed2b2d59e80e1f6524925ce60687960 100644
--- a/tests/auto/debugger/tst_gdb.cpp
+++ b/tests/auto/debugger/tst_gdb.cpp
@@ -768,11 +768,11 @@ void dump_misc()
     vec.push_back("Hallo2");
     std::set<std::string> stdSet;
     stdSet.insert("s1");
-    #ifdef QT_GUI_LIB
+#    ifdef QT_GUI_LIB
     QWidget *ww = 0; //this;
     QWidget &wwr = *ww;
     Q_UNUSED(wwr);
-    #endif
+#    endif
 
     QSharedPointer<QString> sps(new QString("hallo"));
     QList<QSharedPointer<QString> > spsl;
@@ -790,10 +790,10 @@ void dump_misc()
 
     QLinkedList<QString> lls;
     lls << "link1" << "link2";
-    #ifdef QT_GUI_LIB
+#    ifdef QT_GUI_LIB
     QStandardItemModel *model = new QStandardItemModel;
     model->appendRow(new QStandardItem("i1"));
-    #endif
+#    endif
 
     QList <QList<int> > nestedIntList;
     nestedIntList << QList<int>();
@@ -1055,7 +1055,7 @@ QByteArray dump_QAbstractItemModelHelper(QAbstractItemModel &m)
 
 void dump_QAbstractItemModel()
 {
-    #ifdef QT_GUI_LIB
+#    ifdef QT_GUI_LIB
     /* A */ QStringList strList;
             strList << "String 1";
             QStringListModel model1(strList);
@@ -1066,12 +1066,12 @@ void dump_QAbstractItemModel()
     /* E */ model2.appendRow(QList<QStandardItem *>() << (new QStandardItem("Item (0,0)")) << (new QStandardItem("Item (0,1)")));
     /* F */ model2.appendRow(QList<QStandardItem *>() << (new QStandardItem("Item (1,0)")) << (new QStandardItem("Item (1,1)")));
     /* G */ (void) (model1.rowCount() + model2.rowCount() + strList.size());
-    #endif
+#    endif
 }
 
 void tst_Gdb::dump_QAbstractItemModel()
 {
-    #ifdef QT_GUI_LIB
+#    ifdef QT_GUI_LIB
     /* A */ QStringList strList;
     QString template_ =
         "{iname='local.strList',name='strList',type='"NS"QStringList',"
@@ -1086,7 +1086,7 @@ void tst_Gdb::dump_QAbstractItemModel()
         check("A", template_.arg("1").toAscii());
     next(4);
     check("B", template_.arg("1").toAscii());
-    #endif
+#    endif
 }
 
 
@@ -1184,16 +1184,16 @@ void tst_Gdb::dump_QChar()
 
 void dump_QDateTime()
 {
-    #ifndef QT_NO_DATESTRING
+#    ifndef QT_NO_DATESTRING
     /* A */ QDateTime d;
     /* B */ d = QDateTime::fromString("M5d21y7110:31:02", "'M'M'd'd'y'yyhh:mm:ss");
     /* C */ (void) d.isNull();
-    #endif
+#    endif
 }
 
 void tst_Gdb::dump_QDateTime()
 {
-    #ifndef QT_NO_DATESTRING
+#    ifndef QT_NO_DATESTRING
     prepare("dump_QDateTime");
     if (checkUninitialized)
         check("A","{iname='local.d',name='d',"
@@ -1238,7 +1238,7 @@ void tst_Gdb::dump_QDateTime()
                 "value='-',numchild='3'}"
             "]}",
           "local.d");
-    #endif
+#    endif
 }
 
 
@@ -1387,18 +1387,18 @@ void tst_Gdb::dump_QImageDataHelper(QImage &img)
 
 void dump_QImage()
 {
-    #ifdef QT_GUI_LIB
+#    ifdef QT_GUI_LIB
     /* A */ QImage image; // Null image.
     /* B */ image = QImage(30, 700, QImage::Format_RGB555); // Normal image.
     /* C */ image = QImage(100, 0, QImage::Format_Invalid); // Invalid image.
     /* D */ (void) image.size();
     /* E */ (void) image.size();
-    #endif
+#    endif
 }
 
 void tst_Gdb::dump_QImage()
 {
-    #ifdef QT_GUI_LIB
+#    ifdef QT_GUI_LIB
     prepare("dump_QImage");
     next();
     check("B", "{iname='local.image',name='image',type='"NS"QImage',"
@@ -1410,7 +1410,7 @@ void tst_Gdb::dump_QImage()
     // FIXME:
     //check("E", "{iname='local.image',name='image',type='"NS"QImage',"
     //    "value='(100x0)',numchild='0'}");
-    #endif
+#    endif
 }
 
 #if 0
@@ -2411,17 +2411,17 @@ const char * const pixmap[] = {
 
 void dump_QPixmap()
 {
-    #ifdef QT_GUI_LIB
+#    ifdef QT_GUI_LIB
     /* A */ QPixmap p; // Case 1: Null Pixmap.
     /* B */ p = QPixmap(20, 100); // Case 2: Uninitialized non-null pixmap.
     /* C */ p = QPixmap(pixmap); // Case 3: Initialized non-null pixmap.
     /* D */ (void) p.size();
-    #endif
+#    endif
 }
 
 void tst_Gdb::dump_QPixmap()
 {
-    #ifdef QT_GUI_LIB
+#    ifdef QT_GUI_LIB
     prepare("dump_QPixmap");
     next();
     check("B", "{iname='local.p',name='p',type='"NS"QPixmap',"
@@ -2432,7 +2432,7 @@ void tst_Gdb::dump_QPixmap()
     next();
     check("D", "{iname='local.p',name='p',type='"NS"QPixmap',"
         "value='(2x24)',numchild='0'}");
-    #endif
+#    endif
 }
 
 
@@ -2915,7 +2915,7 @@ void dump_QVariant()
 
 void tst_Gdb::dump_QVariant()
 {
-    #define PRE "iname='local.v',name='v',type='"NS"QVariant',"
+#    define PRE "iname='local.v',name='v',type='"NS"QVariant',"
     prepare("dump_QVariant");
     if (checkUninitialized) /*<invalid>*/
         check("A","{"PRE"'value=<invalid>',numchild='0'}");
@@ -3257,15 +3257,15 @@ void tst_Gdb::dump_QWeakPointer_2() {}
 
 void dump_QWidget()
 {
-    #ifdef QT_GUI_LIB
+#    ifdef QT_GUI_LIB
     /* A */ QWidget w;
     /* B */ (void) w.size();
-    #endif
+#    endif
 }
 
 void tst_Gdb::dump_QWidget()
 {
-    #ifdef QT_GUI_LIB
+#    ifdef QT_GUI_LIB
     prepare("dump_QWidget");
     if (checkUninitialized)
         check("A","{iname='local.w',name='w',"
@@ -3290,7 +3290,7 @@ void tst_Gdb::dump_QWidget()
       "{name='data',type='"NS"QWidgetData *',"
         "value='-',numchild='1'}]}",
       "local.w,local.w."NS"QObject");
-    #endif
+#    endif
 }
 
 
@@ -3620,11 +3620,11 @@ void breaker() {}
 
 int main(int argc, char *argv[])
 {
-    #ifdef QT_GUI_LIB
+#    ifdef QT_GUI_LIB
     QApplication app(argc, argv);
-    #else
+#    else
     QCoreApplication app(argc, argv);
-    #endif
+#    endif
     breaker();
 
     if (argc == 2 && QByteArray(argv[1]) == "run") {
diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp
index 501b144721a9c601002fb5f2a123a7edc2af7b48..34825e61748786535a8cceda4faedc6cba983cd4 100644
--- a/tests/manual/gdbdebugger/simple/app.cpp
+++ b/tests/manual/gdbdebugger/simple/app.cpp
@@ -1797,9 +1797,9 @@ int main(int argc, char *argv[])
     testQMultiMap();
     testQString();
     testQSet();
-    #if QT_VERSION >= 0x040500
+#    if QT_VERSION >= 0x040500
     testQSharedPointer();
-    #endif
+#    endif
     testQStringList();
     testStruct();
     testQThread();