[Lldb-commits] [PATCH] D52139: [lldb-mi] Fix hanging of target-select-so-path.test
apolyakov added a comment. Do you mean `ConnectToRemote` method from `lldb/tools/lldb-server/lldb-gdbserver.cpp`? https://reviews.llvm.org/D52139 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52139: [lldb-mi] Fix hanging of target-select-so-path.test
apolyakov added a comment. AFAIR, adding an `exit(...)` to `ConnectToRemote` won't solve this problem. The test will still be failing on Arch. https://reviews.llvm.org/D52139 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52139: [lldb-mi] Fix hanging of target-select-so-path.test
apolyakov added a comment. If so, we can try to run the script with python2.x. @teemperor can you try to modify `target-select-so-path.test` this way: change `# RUN: python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s` to `# RUN: python2 %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s` If this works for you on Arch, I'll update the revision. https://reviews.llvm.org/D52139 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52139: [lldb-mi] Fix hanging of target-select-so-path.test
apolyakov updated this revision to Diff 166714. apolyakov added a comment. Reduced timer from 120 to 30 seconds. https://reviews.llvm.org/D52139 Files: lit/tools/lldb-mi/target/inputs/target-select-so-path.py Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py === --- lit/tools/lldb-mi/target/inputs/target-select-so-path.py +++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py @@ -3,6 +3,7 @@ import os import sys import subprocess +from threading import Timer hostname = 'localhost' @@ -19,21 +20,28 @@ debugserver_proc = subprocess.Popen(debugserver.split()) lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) -filecheck_proc = subprocess.Popen(filecheck, stdin=lldbmi_proc.stdout, +filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE, shell=True) -# Get a tcp port chosen by debugserver. -# The number quite big to get lldb-server's output and to not hang. -bytes_to_read = 10 -port_bytes = os.read(r, bytes_to_read) -port = str(port_bytes.decode('utf-8').strip('\x00')) - -with open(test_file, 'r') as f: -# Replace '$PORT' with a free port number and pass -# test's content to lldb-mi. -lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) -lldbmi_proc.wait() -filecheck_proc.wait() +timeout_sec = 30 +timer = Timer(timeout_sec, lldbmi_proc.kill) +try: +timer.start() + +# Get a tcp port chosen by debugserver. +# The number quite big to get lldb-server's output and to not hang. +bytes_to_read = 10 +port_bytes = os.read(r, bytes_to_read) +port = str(port_bytes.decode('utf-8').strip('\x00')) + +with open(test_file, 'r') as f: +# Replace '$PORT' with a free port number and pass +# test's content to lldb-mi. +lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) +out, err = lldbmi_proc.communicate() +filecheck_proc.stdin.write(out) +finally: +timer.cancel() debugserver_proc.kill() exit(filecheck_proc.returncode) Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py === --- lit/tools/lldb-mi/target/inputs/target-select-so-path.py +++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py @@ -3,6 +3,7 @@ import os import sys import subprocess +from threading import Timer hostname = 'localhost' @@ -19,21 +20,28 @@ debugserver_proc = subprocess.Popen(debugserver.split()) lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) -filecheck_proc = subprocess.Popen(filecheck, stdin=lldbmi_proc.stdout, +filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE, shell=True) -# Get a tcp port chosen by debugserver. -# The number quite big to get lldb-server's output and to not hang. -bytes_to_read = 10 -port_bytes = os.read(r, bytes_to_read) -port = str(port_bytes.decode('utf-8').strip('\x00')) - -with open(test_file, 'r') as f: -# Replace '$PORT' with a free port number and pass -# test's content to lldb-mi. -lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) -lldbmi_proc.wait() -filecheck_proc.wait() +timeout_sec = 30 +timer = Timer(timeout_sec, lldbmi_proc.kill) +try: +timer.start() + +# Get a tcp port chosen by debugserver. +# The number quite big to get lldb-server's output and to not hang. +bytes_to_read = 10 +port_bytes = os.read(r, bytes_to_read) +port = str(port_bytes.decode('utf-8').strip('\x00')) + +with open(test_file, 'r') as f: +# Replace '$PORT' with a free port number and pass +# test's content to lldb-mi. +lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) +out, err = lldbmi_proc.communicate() +filecheck_proc.stdin.write(out) +finally: +timer.cancel() debugserver_proc.kill() exit(filecheck_proc.returncode) ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52139: [lldb-mi] Fix hanging of target-select-so-path.test
This revision was automatically updated to reflect the committed changes. Closed by commit rL342915: [lldb-mi] Fix hanging of target-select-so-path.test (authored by apolyakov, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D52139?vs=166714&id=166731#toc Repository: rL LLVM https://reviews.llvm.org/D52139 Files: lldb/trunk/lit/tools/lldb-mi/target/inputs/target-select-so-path.py Index: lldb/trunk/lit/tools/lldb-mi/target/inputs/target-select-so-path.py === --- lldb/trunk/lit/tools/lldb-mi/target/inputs/target-select-so-path.py +++ lldb/trunk/lit/tools/lldb-mi/target/inputs/target-select-so-path.py @@ -3,6 +3,7 @@ import os import sys import subprocess +from threading import Timer hostname = 'localhost' @@ -19,21 +20,28 @@ debugserver_proc = subprocess.Popen(debugserver.split()) lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) -filecheck_proc = subprocess.Popen(filecheck, stdin=lldbmi_proc.stdout, +filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE, shell=True) -# Get a tcp port chosen by debugserver. -# The number quite big to get lldb-server's output and to not hang. -bytes_to_read = 10 -port_bytes = os.read(r, bytes_to_read) -port = str(port_bytes.decode('utf-8').strip('\x00')) - -with open(test_file, 'r') as f: -# Replace '$PORT' with a free port number and pass -# test's content to lldb-mi. -lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) -lldbmi_proc.wait() -filecheck_proc.wait() +timeout_sec = 30 +timer = Timer(timeout_sec, lldbmi_proc.kill) +try: +timer.start() + +# Get a tcp port chosen by debugserver. +# The number quite big to get lldb-server's output and to not hang. +bytes_to_read = 10 +port_bytes = os.read(r, bytes_to_read) +port = str(port_bytes.decode('utf-8').strip('\x00')) + +with open(test_file, 'r') as f: +# Replace '$PORT' with a free port number and pass +# test's content to lldb-mi. +lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) +out, err = lldbmi_proc.communicate() +filecheck_proc.stdin.write(out) +finally: +timer.cancel() debugserver_proc.kill() exit(filecheck_proc.returncode) Index: lldb/trunk/lit/tools/lldb-mi/target/inputs/target-select-so-path.py === --- lldb/trunk/lit/tools/lldb-mi/target/inputs/target-select-so-path.py +++ lldb/trunk/lit/tools/lldb-mi/target/inputs/target-select-so-path.py @@ -3,6 +3,7 @@ import os import sys import subprocess +from threading import Timer hostname = 'localhost' @@ -19,21 +20,28 @@ debugserver_proc = subprocess.Popen(debugserver.split()) lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) -filecheck_proc = subprocess.Popen(filecheck, stdin=lldbmi_proc.stdout, +filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE, shell=True) -# Get a tcp port chosen by debugserver. -# The number quite big to get lldb-server's output and to not hang. -bytes_to_read = 10 -port_bytes = os.read(r, bytes_to_read) -port = str(port_bytes.decode('utf-8').strip('\x00')) - -with open(test_file, 'r') as f: -# Replace '$PORT' with a free port number and pass -# test's content to lldb-mi. -lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) -lldbmi_proc.wait() -filecheck_proc.wait() +timeout_sec = 30 +timer = Timer(timeout_sec, lldbmi_proc.kill) +try: +timer.start() + +# Get a tcp port chosen by debugserver. +# The number quite big to get lldb-server's output and to not hang. +bytes_to_read = 10 +port_bytes = os.read(r, bytes_to_read) +port = str(port_bytes.decode('utf-8').strip('\x00')) + +with open(test_file, 'r') as f: +# Replace '$PORT' with a free port number and pass +# test's content to lldb-mi. +lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) +out, err = lldbmi_proc.communicate() +filecheck_proc.stdin.write(out) +finally: +timer.cancel() debugserver_proc.kill() exit(filecheck_proc.returncode) ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test
apolyakov created this revision. apolyakov added reviewers: teemperor, labath, tatyana-krasnukha, aprantl. Herald added a subscriber: ki.stfu. This patch fixes hanging of the test in case of using python3, changes callback function that will be called if the timer ends; Also, the test didn't work properly since it didn't contain a call of filecheck_proc.communicate(), that means that filecheck didn't run and its return code was equal to 0 in all cases. Repository: rLLDB LLDB https://reviews.llvm.org/D52498 Files: lit/tools/lldb-mi/target/inputs/target-select-so-path.py Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py === --- lit/tools/lldb-mi/target/inputs/target-select-so-path.py +++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py @@ -9,22 +9,26 @@ hostname = 'localhost' (r, w) = os.pipe() +kwargs = {} +if sys.version_info >= (3,0): +kwargs['pass_fds'] = [w] + args = sys.argv # Get debugserver, lldb-mi and FileCheck executables' paths with arguments. debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0']) lldbmi = args[2] test_file = args[3] filecheck = 'FileCheck ' + test_file # Run debugserver, lldb-mi and FileCheck. -debugserver_proc = subprocess.Popen(debugserver.split()) +debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs) lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE, shell=True) timeout_sec = 30 -timer = Timer(timeout_sec, lldbmi_proc.kill) +timer = Timer(timeout_sec, exit, [filecheck_proc.returncode]) try: timer.start() @@ -37,9 +41,10 @@ with open(test_file, 'r') as f: # Replace '$PORT' with a free port number and pass # test's content to lldb-mi. -lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) +lldbmi_proc.stdin.write(f.read().replace('$PORT', port).encode('utf-8')) out, err = lldbmi_proc.communicate() filecheck_proc.stdin.write(out) +filecheck_proc.communicate() finally: timer.cancel() Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py === --- lit/tools/lldb-mi/target/inputs/target-select-so-path.py +++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py @@ -9,22 +9,26 @@ hostname = 'localhost' (r, w) = os.pipe() +kwargs = {} +if sys.version_info >= (3,0): +kwargs['pass_fds'] = [w] + args = sys.argv # Get debugserver, lldb-mi and FileCheck executables' paths with arguments. debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0']) lldbmi = args[2] test_file = args[3] filecheck = 'FileCheck ' + test_file # Run debugserver, lldb-mi and FileCheck. -debugserver_proc = subprocess.Popen(debugserver.split()) +debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs) lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE, shell=True) timeout_sec = 30 -timer = Timer(timeout_sec, lldbmi_proc.kill) +timer = Timer(timeout_sec, exit, [filecheck_proc.returncode]) try: timer.start() @@ -37,9 +41,10 @@ with open(test_file, 'r') as f: # Replace '$PORT' with a free port number and pass # test's content to lldb-mi. -lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) +lldbmi_proc.stdin.write(f.read().replace('$PORT', port).encode('utf-8')) out, err = lldbmi_proc.communicate() filecheck_proc.stdin.write(out) +filecheck_proc.communicate() finally: timer.cancel() ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52139: [lldb-mi] Fix hanging of target-select-so-path.test
apolyakov added a comment. Thanks Pavel, I fixed it here https://reviews.llvm.org/D52498. Repository: rL LLVM https://reviews.llvm.org/D52139 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test
apolyakov updated this revision to Diff 166919. apolyakov added a comment. Removed the shebang line since we call the script via `python ...` so that line doesn't matter. https://reviews.llvm.org/D52498 Files: lit/tools/lldb-mi/target/inputs/target-select-so-path.py Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py === --- lit/tools/lldb-mi/target/inputs/target-select-so-path.py +++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python2 - import os import sys import subprocess @@ -9,22 +7,26 @@ hostname = 'localhost' (r, w) = os.pipe() +kwargs = {} +if sys.version_info >= (3,0): +kwargs['pass_fds'] = [w] + args = sys.argv # Get debugserver, lldb-mi and FileCheck executables' paths with arguments. debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0']) lldbmi = args[2] test_file = args[3] filecheck = 'FileCheck ' + test_file # Run debugserver, lldb-mi and FileCheck. -debugserver_proc = subprocess.Popen(debugserver.split()) +debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs) lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE, shell=True) timeout_sec = 30 -timer = Timer(timeout_sec, lldbmi_proc.kill) +timer = Timer(timeout_sec, exit, [filecheck_proc.returncode]) try: timer.start() @@ -37,9 +39,10 @@ with open(test_file, 'r') as f: # Replace '$PORT' with a free port number and pass # test's content to lldb-mi. -lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) +lldbmi_proc.stdin.write(f.read().replace('$PORT', port).encode('utf-8')) out, err = lldbmi_proc.communicate() filecheck_proc.stdin.write(out) +filecheck_proc.communicate() finally: timer.cancel() Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py === --- lit/tools/lldb-mi/target/inputs/target-select-so-path.py +++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python2 - import os import sys import subprocess @@ -9,22 +7,26 @@ hostname = 'localhost' (r, w) = os.pipe() +kwargs = {} +if sys.version_info >= (3,0): +kwargs['pass_fds'] = [w] + args = sys.argv # Get debugserver, lldb-mi and FileCheck executables' paths with arguments. debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0']) lldbmi = args[2] test_file = args[3] filecheck = 'FileCheck ' + test_file # Run debugserver, lldb-mi and FileCheck. -debugserver_proc = subprocess.Popen(debugserver.split()) +debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs) lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE, shell=True) timeout_sec = 30 -timer = Timer(timeout_sec, lldbmi_proc.kill) +timer = Timer(timeout_sec, exit, [filecheck_proc.returncode]) try: timer.start() @@ -37,9 +39,10 @@ with open(test_file, 'r') as f: # Replace '$PORT' with a free port number and pass # test's content to lldb-mi. -lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) +lldbmi_proc.stdin.write(f.read().replace('$PORT', port).encode('utf-8')) out, err = lldbmi_proc.communicate() filecheck_proc.stdin.write(out) +filecheck_proc.communicate() finally: timer.cancel() ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test
apolyakov updated this revision to Diff 166936. apolyakov added a comment. Changed python version required to use 'pass_fds' argument to 3.2. I tested this patch with python 2.7 and 3.5. https://reviews.llvm.org/D52498 Files: lit/tools/lldb-mi/target/inputs/target-select-so-path.py Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py === --- lit/tools/lldb-mi/target/inputs/target-select-so-path.py +++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python2 - import os import sys import subprocess @@ -9,22 +7,26 @@ hostname = 'localhost' (r, w) = os.pipe() +kwargs = {} +if sys.version_info >= (3,2): +kwargs['pass_fds'] = [w] + args = sys.argv # Get debugserver, lldb-mi and FileCheck executables' paths with arguments. debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0']) lldbmi = args[2] test_file = args[3] filecheck = 'FileCheck ' + test_file # Run debugserver, lldb-mi and FileCheck. -debugserver_proc = subprocess.Popen(debugserver.split()) +debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs) lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE, shell=True) timeout_sec = 30 -timer = Timer(timeout_sec, lldbmi_proc.kill) +timer = Timer(timeout_sec, exit, [filecheck_proc.returncode]) try: timer.start() @@ -37,9 +39,10 @@ with open(test_file, 'r') as f: # Replace '$PORT' with a free port number and pass # test's content to lldb-mi. -lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) +lldbmi_proc.stdin.write(f.read().replace('$PORT', port).encode('utf-8')) out, err = lldbmi_proc.communicate() filecheck_proc.stdin.write(out) +filecheck_proc.communicate() finally: timer.cancel() Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py === --- lit/tools/lldb-mi/target/inputs/target-select-so-path.py +++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python2 - import os import sys import subprocess @@ -9,22 +7,26 @@ hostname = 'localhost' (r, w) = os.pipe() +kwargs = {} +if sys.version_info >= (3,2): +kwargs['pass_fds'] = [w] + args = sys.argv # Get debugserver, lldb-mi and FileCheck executables' paths with arguments. debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0']) lldbmi = args[2] test_file = args[3] filecheck = 'FileCheck ' + test_file # Run debugserver, lldb-mi and FileCheck. -debugserver_proc = subprocess.Popen(debugserver.split()) +debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs) lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE, shell=True) timeout_sec = 30 -timer = Timer(timeout_sec, lldbmi_proc.kill) +timer = Timer(timeout_sec, exit, [filecheck_proc.returncode]) try: timer.start() @@ -37,9 +39,10 @@ with open(test_file, 'r') as f: # Replace '$PORT' with a free port number and pass # test's content to lldb-mi. -lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) +lldbmi_proc.stdin.write(f.read().replace('$PORT', port).encode('utf-8')) out, err = lldbmi_proc.communicate() filecheck_proc.stdin.write(out) +filecheck_proc.communicate() finally: timer.cancel() ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test
apolyakov updated this revision to Diff 166953. apolyakov edited the summary of this revision. apolyakov added a comment. Changed the test to use `%python` variable instead of `python` https://reviews.llvm.org/D52498 Files: lit/tools/lldb-mi/target/inputs/target-select-so-path.py lit/tools/lldb-mi/target/target-select-so-path.test Index: lit/tools/lldb-mi/target/target-select-so-path.test === --- lit/tools/lldb-mi/target/target-select-so-path.test +++ lit/tools/lldb-mi/target/target-select-so-path.test @@ -1,7 +1,7 @@ # UNSUPPORTED: windows, darwin # # RUN: %cc -o %t %p/inputs/main.c -g -# RUN: python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s +# RUN: %python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s # Test that -target-select command can hook up a path # added by gdb-set solib-search-path. Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py === --- lit/tools/lldb-mi/target/inputs/target-select-so-path.py +++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python2 - import os import sys import subprocess @@ -9,22 +7,26 @@ hostname = 'localhost' (r, w) = os.pipe() +kwargs = {} +if sys.version_info >= (3,2): +kwargs['pass_fds'] = [w] + args = sys.argv # Get debugserver, lldb-mi and FileCheck executables' paths with arguments. debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0']) lldbmi = args[2] test_file = args[3] filecheck = 'FileCheck ' + test_file # Run debugserver, lldb-mi and FileCheck. -debugserver_proc = subprocess.Popen(debugserver.split()) +debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs) lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE, shell=True) timeout_sec = 30 -timer = Timer(timeout_sec, lldbmi_proc.kill) +timer = Timer(timeout_sec, exit, [filecheck_proc.returncode]) try: timer.start() @@ -37,9 +39,10 @@ with open(test_file, 'r') as f: # Replace '$PORT' with a free port number and pass # test's content to lldb-mi. -lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) +lldbmi_proc.stdin.write(f.read().replace('$PORT', port).encode('utf-8')) out, err = lldbmi_proc.communicate() filecheck_proc.stdin.write(out) +filecheck_proc.communicate() finally: timer.cancel() Index: lit/tools/lldb-mi/target/target-select-so-path.test === --- lit/tools/lldb-mi/target/target-select-so-path.test +++ lit/tools/lldb-mi/target/target-select-so-path.test @@ -1,7 +1,7 @@ # UNSUPPORTED: windows, darwin # # RUN: %cc -o %t %p/inputs/main.c -g -# RUN: python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s +# RUN: %python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s # Test that -target-select command can hook up a path # added by gdb-set solib-search-path. Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py === --- lit/tools/lldb-mi/target/inputs/target-select-so-path.py +++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python2 - import os import sys import subprocess @@ -9,22 +7,26 @@ hostname = 'localhost' (r, w) = os.pipe() +kwargs = {} +if sys.version_info >= (3,2): +kwargs['pass_fds'] = [w] + args = sys.argv # Get debugserver, lldb-mi and FileCheck executables' paths with arguments. debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0']) lldbmi = args[2] test_file = args[3] filecheck = 'FileCheck ' + test_file # Run debugserver, lldb-mi and FileCheck. -debugserver_proc = subprocess.Popen(debugserver.split()) +debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs) lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE, shell=True) timeout_sec = 30 -timer = Timer(timeout_sec, lldbmi_proc.kill) +timer = Timer(timeout_sec, exit, [filecheck_proc.returncode]) try: timer.start() @@ -37,9 +39,10 @@ with open(test_file, 'r') as f: # Replace '$PORT' with a free port number and pass # test's content to lldb-mi. -lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) +lldbmi_proc.stdin.write(f.read().replace('$PORT', port).encode('utf-8')) out, err = lldbmi_proc.communicate() filecheck_proc.stdin.write(out) +filecheck_proc.communicate() final
[Lldb-commits] [PATCH] D49739: Add new API to SBTarget class
apolyakov marked an inline comment as done. apolyakov added inline comments. Comment at: lit/tools/lldb-mi/target/target-select-so-path.test:4 +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s + tatyana-krasnukha wrote: > Could you run the same python that is used for all python tests? (%python) Done in https://reviews.llvm.org/D52498 Repository: rL LLVM https://reviews.llvm.org/D49739 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52498: [lldb-mi] Fix bugs in target-select-so-path.test
This revision was automatically updated to reflect the committed changes. Closed by commit rLLDB343033: [lldb-mi] Fix bugs in target-select-so-path.test (authored by apolyakov, committed by ). Repository: rLLDB LLDB https://reviews.llvm.org/D52498 Files: lit/tools/lldb-mi/target/inputs/target-select-so-path.py lit/tools/lldb-mi/target/target-select-so-path.test Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py === --- lit/tools/lldb-mi/target/inputs/target-select-so-path.py +++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python2 - import os import sys import subprocess @@ -9,22 +7,26 @@ hostname = 'localhost' (r, w) = os.pipe() +kwargs = {} +if sys.version_info >= (3,2): +kwargs['pass_fds'] = [w] + args = sys.argv # Get debugserver, lldb-mi and FileCheck executables' paths with arguments. debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0']) lldbmi = args[2] test_file = args[3] filecheck = 'FileCheck ' + test_file # Run debugserver, lldb-mi and FileCheck. -debugserver_proc = subprocess.Popen(debugserver.split()) +debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs) lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE, shell=True) timeout_sec = 30 -timer = Timer(timeout_sec, lldbmi_proc.kill) +timer = Timer(timeout_sec, exit, [filecheck_proc.returncode]) try: timer.start() @@ -37,9 +39,10 @@ with open(test_file, 'r') as f: # Replace '$PORT' with a free port number and pass # test's content to lldb-mi. -lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) +lldbmi_proc.stdin.write(f.read().replace('$PORT', port).encode('utf-8')) out, err = lldbmi_proc.communicate() filecheck_proc.stdin.write(out) +filecheck_proc.communicate() finally: timer.cancel() Index: lit/tools/lldb-mi/target/target-select-so-path.test === --- lit/tools/lldb-mi/target/target-select-so-path.test +++ lit/tools/lldb-mi/target/target-select-so-path.test @@ -1,7 +1,7 @@ # UNSUPPORTED: windows, darwin # # RUN: %cc -o %t %p/inputs/main.c -g -# RUN: python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s +# RUN: %python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s # Test that -target-select command can hook up a path # added by gdb-set solib-search-path. Index: lit/tools/lldb-mi/target/inputs/target-select-so-path.py === --- lit/tools/lldb-mi/target/inputs/target-select-so-path.py +++ lit/tools/lldb-mi/target/inputs/target-select-so-path.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python2 - import os import sys import subprocess @@ -9,22 +7,26 @@ hostname = 'localhost' (r, w) = os.pipe() +kwargs = {} +if sys.version_info >= (3,2): +kwargs['pass_fds'] = [w] + args = sys.argv # Get debugserver, lldb-mi and FileCheck executables' paths with arguments. debugserver = ' '.join([args[1], '--pipe', str(w), hostname + ':0']) lldbmi = args[2] test_file = args[3] filecheck = 'FileCheck ' + test_file # Run debugserver, lldb-mi and FileCheck. -debugserver_proc = subprocess.Popen(debugserver.split()) +debugserver_proc = subprocess.Popen(debugserver.split(), **kwargs) lldbmi_proc = subprocess.Popen(lldbmi, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True) filecheck_proc = subprocess.Popen(filecheck, stdin=subprocess.PIPE, shell=True) timeout_sec = 30 -timer = Timer(timeout_sec, lldbmi_proc.kill) +timer = Timer(timeout_sec, exit, [filecheck_proc.returncode]) try: timer.start() @@ -37,9 +39,10 @@ with open(test_file, 'r') as f: # Replace '$PORT' with a free port number and pass # test's content to lldb-mi. -lldbmi_proc.stdin.write(f.read().replace('$PORT', port)) +lldbmi_proc.stdin.write(f.read().replace('$PORT', port).encode('utf-8')) out, err = lldbmi_proc.communicate() filecheck_proc.stdin.write(out) +filecheck_proc.communicate() finally: timer.cancel() Index: lit/tools/lldb-mi/target/target-select-so-path.test === --- lit/tools/lldb-mi/target/target-select-so-path.test +++ lit/tools/lldb-mi/target/target-select-so-path.test @@ -1,7 +1,7 @@ # UNSUPPORTED: windows, darwin # # RUN: %cc -o %t %p/inputs/main.c -g -# RUN: python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s +# RUN: %python %p/inputs/target-select-so-path.py "%debugserver" "%lldbmi %t" %s # Test that -target-select command
[Lldb-commits] [PATCH] D52953: [lldb-mi] Implement -gdb-set breakpoint pending on/off
apolyakov added a comment. I think that it's worth it to rewrite the test with LIT and FileCheck because the python approach has some limitations, e.g. timeouts. You can find examples in `lldb/lit/tools/lldb-mi/`. Comment at: tools/lldb-mi/MICmdCmdGdbShow.cpp:369 +const CMIUtilString strOption(vrWords[0]); +if (CMIUtilString::Compare(strOption, "pending")) { +if (!m_rLLDBDebugSessionInfo.SharedDataRetrieve("breakpoint.pending", m_strValue)) { Following LLVM coding standarts, we should use early exits. In this case it might be like: ``` if (!CMIUtilString::Compare(strOption, "pending")) { // process error here } // success case here ... ``` https://reviews.llvm.org/D52953 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52953: [lldb-mi] Implement -gdb-set breakpoint pending on/off
apolyakov added inline comments. Comment at: lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test:4 +# +# RUN: %cc -o b.exe %p/inputs/break-insert-pending.c -g +# RUN: %lldbmi < %s | FileCheck %s As far as your first command is `file-exec-and-symbols`, the best way is to use a generic executable's name. Here it should be: ``` # RUN: %cc -o %t %p/inputs/break-insert-pending.c -g # RUN: %lldbmi %t < %s | FileCheck %s ``` Comment at: lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test:9 + +-file-exec-and-symbols b.exe +# CHECK: ^done It might be removed then. Comment at: lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test:20 +-break-insert printf +#CHECK "^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x",func="\?\?",file="\?\?",fullname="\?\?/\?\?",line="0",pending=\["printf"\],times="0",original-location="printf"} +#CHECK "=breakpoint-modified,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x",func="\?\?",file="\?\?",fullname="\?\?/\?\?",line="0",pending=\["printf"\],times="0",original-location="printf"} It should be `# CHECK:`, it will not work otherwise. The same comment for other places. https://reviews.llvm.org/D52953 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52953: [lldb-mi] Implement -gdb-set breakpoint pending on/off
apolyakov added a comment. I ran the test and got a fail: build/bin/llvm-lit -avv llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test -- Testing: 1 tests, 1 threads -- FAIL: lldb :: tools/lldb-mi/breakpoint/break-insert-enable-pending.test (1 of 1) TEST 'lldb :: tools/lldb-mi/breakpoint/break-insert-enable-pending.test' FAILED Script: -- : 'RUN: at line 4'; /home/alexander/workspace/gsoc/build/./bin/clang -o b.exe /home/alexander/workspace/gsoc/llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/inputs/break-insert-pending.c -g : 'RUN: at line 5'; /home/alexander/workspace/gsoc/build/bin/lldb-mi --synchronous < /home/alexander/workspace/gsoc/llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test | /home/alexander/workspace/gsoc/build/bin/FileCheck /home/alexander/workspace/gsoc/llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test -- Exit Code: 1 Command Output (stderr): -- /home/alexander/workspace/gsoc/llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test:25:10: error: CHECK: expected string not found in input # CHECK: =breakpoint-modified,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="{{0x[0-9a-f]*[^f][0-9a-f]*}}",func="??",file="??",fullname="??/??",line="0",pending=["printf"],times="{{0|1}}",original-location="printf"} ^ :40:1: note: scanning from here =thread-group-started,id="i1",pid="11020" ^ -- Testing Time: 0.72s Failing Tests (1): lldb :: tools/lldb-mi/breakpoint/break-insert-enable-pending.test Unexpected Failures: 1 Comment at: lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test:4 +# +# RUN: %cc -o b.exe %p/inputs/break-insert-pending.c -g +# RUN: %lldbmi < %s | FileCheck %s malaperle wrote: > apolyakov wrote: > > As far as your first command is `file-exec-and-symbols`, the best way is to > > use a generic executable's name. Here it should be: > > ``` > > # RUN: %cc -o %t %p/inputs/break-insert-pending.c -g > > # RUN: %lldbmi %t < %s | FileCheck %s > > ``` > How can I use %t for the second file-exec-and-symbols? It doesn't seem to work Should you use `file-exec-and-symbols` two times? AFAIK, after exiting a program, your target remains the same, so you don't need to load it again. https://reviews.llvm.org/D52953 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52953: [lldb-mi] Implement -gdb-set breakpoint pending on/off
apolyakov added a comment. I only have these options: build/bin/llvm-lit -avv --dump-input-on-failure llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test usage: llvm-lit [-h] [--version] [-j N] [--config-prefix NAME] [-D NAME=VAL] [-q] [-s] [-v] [-vv] [-a] [-o PATH] [--no-progress-bar] [--show-unsupported] [--show-xfail] [--path PATH] [--vg] [--vg-leak] [--vg-arg ARG] [--time-tests] [--no-execute] [--xunit-xml-output XUNIT_OUTPUT_FILE] [--timeout MAXINDIVIDUALTESTTIME] [--max-failures MAXFAILURES] [--max-tests N] [--max-time N] [--shuffle] [-i] [--filter REGEX] [--num-shards M] [--run-shard N] [--debug] [--show-suites] [--show-tests] [--single-process] [test_paths [test_paths ...]] llvm-lit: error: unrecognized arguments: --dump-input-on-failure https://reviews.llvm.org/D52953 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D52953: [lldb-mi] Implement -gdb-set breakpoint pending on/off
apolyakov added a comment. Here it is: build/bin/llvm-lit -avv llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test -- Testing: 1 tests, 1 threads -- FAIL: lldb :: tools/lldb-mi/breakpoint/break-insert-enable-pending.test (1 of 1) TEST 'lldb :: tools/lldb-mi/breakpoint/break-insert-enable-pending.test' FAILED Script: -- : 'RUN: at line 4'; /home/alexander/workspace/gsoc/build/./bin/clang -o /home/alexander/workspace/gsoc/build/tools/lldb/lit/tools/lldb-mi/breakpoint/Output/break-insert-enable-pending.test.tmp /home/alexander/workspace/gsoc/llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/inputs/break-insert-pending.c -g : 'RUN: at line 5'; /home/alexander/workspace/gsoc/build/bin/lldb-mi --synchronous /home/alexander/workspace/gsoc/build/tools/lldb/lit/tools/lldb-mi/breakpoint/Output/break-insert-enable-pending.test.tmp < /home/alexander/workspace/gsoc/llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test | /home/alexander/workspace/gsoc/build/bin/FileCheck /home/alexander/workspace/gsoc/llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test --dump-input-on-failure -- Exit Code: 1 Command Output (stderr): -- /home/alexander/workspace/gsoc/llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test:22:10: error: CHECK: expected string not found in input # CHECK: =breakpoint-modified,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="{{0x[0-9a-f]*[^f][0-9a-f]*}}",func="??",file="??",fullname="??/??",line="0",pending=["printf"],times="{{0|1}}",original-location="printf"} ^ :39:1: note: scanning from here =thread-group-started,id="i1",pid="5022" ^ Full input was: << (gdb) -file-exec-and-symbols "/home/alexander/workspace/gsoc/build/tools/lldb/lit/tools/lldb-mi/breakpoint/Output/break-insert-enable-pending.test.tmp" ^done (gdb) ^done (gdb) =library-loaded,id="/home/alexander/workspace/gsoc/build/tools/lldb/lit/tools/lldb-mi/breakpoint/Output/break-insert-enable-pending.test.tmp",target-name="/home/alexander/workspace/gsoc/build/tools/lldb/lit/tools/lldb-mi/breakpoint/Output/break-insert-enable-pending.test.tmp",host-name="/home/alexander/workspace/gsoc/build/tools/lldb/lit/tools/lldb-mi/breakpoint/Output/break-insert-enable-pending.test.tmp",symbols-loaded="0",loaded_addr="-",size="0" ^done (gdb) ^done (gdb) ^done (gdb) ^done (gdb) ^done (gdb) ^error,msg="Command 'break-insert'. Breakpoint location 'printf' not found" (gdb) ^done (gdb) ^done (gdb) ^done (gdb) ^done,value="on" (gdb) ^done (gdb) ^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x",func="??",file="??",fullname="??/??",line="0",pending=["printf"],times="0",original-location="printf"} (gdb) =breakpoint-modified,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x",func="??",file="??",fullname="??/??",line="0",pending=["printf"],times="0",original-location="printf"} (gdb) ^done (gdb) ^done (gdb) ^running =thread-group-started,id="i1",pid="5022" (gdb) =thread-created,id="1",group-id="i1" =thread-selected,id="1" (gdb) =library-loaded,id="/lib/x86_64-linux-gnu/ld-2.23.so",target-name="/lib/x86_64-linux-gnu/ld-2.23.so",host-name="/lib/x86_64-linux-gnu/ld-2.23.so",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so",loaded_addr="-",size="0" (gdb) =library-loaded,id="[vdso]",target-name="[vdso]",host-name="[vdso]",symbols-loaded="1",symbols-path="",loaded_addr="0x77ffa000",size="0" (gdb) =library-loaded,id="/home/alexander/workspace/gsoc/build/tools/lldb/lit/tools/lldb-mi/breakpoint/Output/break-insert-enable-pending.test.tmp",target-name="/home/alexander/workspace/gsoc/build/tools/lldb/lit/tools/lldb-mi/breakpoint/Output/break-insert-enable-pending.test.tmp",host-name="/home/alexander/workspace/gsoc/build/tools/lldb/lit/tools/lldb-mi/breakpoint/Output/break-insert-enable-pending.test.tmp",symbols-loaded="0",loaded_addr="-",size="0" 1 location added to breakpoint 2 (gdb) =library-loaded,id="/lib/x86_64-linux-gnu/libc.so.6",target-name="/lib/x86_64-linux-gnu/libc.so.6",host-name="/lib/x86_64-linux-gnu/libc.so.6",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so",loaded_addr="-",size="0" =breakpoint-modified,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x77a6285b",func="__printf",file="printf.c",fullname="/build/glibc-bfm8X4/glibc-2.23/stdio-common/printf.c",line="32",pending=["printf"],times="1",original-location="printf"} (gdb) (gdb) =library-loaded,id="/lib/x86_64-linux-gnu/libc.so.6",target-name="/lib/x86_64-linux-gnu/libc.so.6",host-name="/lib/x86_64-linux-gnu/libc.so.6",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so",load
[Lldb-commits] [PATCH] D52953: [lldb-mi] Implement -gdb-set breakpoint pending on/off
apolyakov accepted this revision. apolyakov added a comment. This revision is now accepted and ready to land. LGTM. https://reviews.llvm.org/D52953 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex added a comment. So, what do you think about the patch? There is no any decision about lldb-mi tests and I do not know what to do with this. Repository: rL LLVM https://reviews.llvm.org/D46588 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex updated this revision to Diff 146487. polyakov.alex added a comment. Moved tests to lit. Repository: rL LLVM https://reviews.llvm.org/D46588 Files: lit/Breakpoint/Inputs/break-insert.c lit/Breakpoint/Inputs/break-insert.input lit/Breakpoint/break-insert.test lit/lit.cfg tools/lldb-mi/MICmdCmdBreak.cpp tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp Index: tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp === --- tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp +++ tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp @@ -871,7 +871,10 @@ // Throws: None. //-- lldb::SBTarget CMICmnLLDBDebugSessionInfo::GetTarget() const { - return GetDebugger().GetSelectedTarget(); + auto target = GetDebugger().GetSelectedTarget(); + if (target.IsValid()) +return target; + return GetDebugger().GetDummyTarget(); } //++ Index: tools/lldb-mi/MICmdCmdBreak.cpp === --- tools/lldb-mi/MICmdCmdBreak.cpp +++ tools/lldb-mi/MICmdCmdBreak.cpp @@ -148,6 +148,11 @@ CMICMDBASE_GETOPTION(pArgRestrictBrkPtToThreadId, OptionShort, m_constStrArgNamedRestrictBrkPtToThreadId); + // Ask LLDB for the target to check if we have valid or dummy one. + CMICmnLLDBDebugSessionInfo &rSessionInfo( + CMICmnLLDBDebugSessionInfo::Instance()); + lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); + m_bBrkPtEnabled = !pArgDisableBrkPt->GetFound(); m_bBrkPtIsTemp = pArgTempBrkPt->GetFound(); m_bHaveArgOptionThreadGrp = pArgThreadGroup->GetFound(); @@ -157,7 +162,12 @@ nThreadGrp); m_strArgOptionThreadGrp = CMIUtilString::Format("i%d", nThreadGrp); } - m_bBrkPtIsPending = pArgPendingBrkPt->GetFound(); + + if (sbTarget == rSessionInfo.GetDebugger().GetDummyTarget()) +m_bBrkPtIsPending = true; + else +m_bBrkPtIsPending = pArgPendingBrkPt->GetFound(); + if (pArgLocation->GetFound()) m_brkName = pArgLocation->GetValue(); else if (m_bBrkPtIsPending) { @@ -225,9 +235,6 @@ // Ask LLDB to create a breakpoint bool bOk = MIstatus::success; - CMICmnLLDBDebugSessionInfo &rSessionInfo( - CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); switch (eBrkPtType) { case eBreakPoint_ByAddress: m_brkPt = sbTarget.BreakpointCreateByAddress(nAddress); Index: lit/lit.cfg === --- lit/lit.cfg +++ lit/lit.cfg @@ -58,6 +58,8 @@ lldb = "%s -S %s/lit-lldb-init" % (lit.util.which('lldb', lldb_tools_dir), config.test_source_root) +lldb_mi = lit.util.which('lldb-mi', lldb_tools_dir) + if not os.path.exists(config.cc): config.cc = lit.util.which(config.cc, config.environment['PATH']) @@ -79,6 +81,7 @@ config.substitutions.append(('%cc', config.cc)) config.substitutions.append(('%cxx', config.cxx)) +config.substitutions.append(('%lldb_mi', lldb_mi)) config.substitutions.append(('%lldb', lldb)) if debugserver is not None: Index: lit/Breakpoint/break-insert.test === --- /dev/null +++ lit/Breakpoint/break-insert.test @@ -0,0 +1,7 @@ +# RUN: %cc %p/Inputs/break-insert.c -g +# RUN: %lldb_mi < %p/Inputs/break-insert.input | FileCheck %s +# CHECK: ^done,bkpt={number="1" +# CHECK: ^done +# CHECK: ^running +# CHECK-AFTER: *stopped,reason="breakpoint-hit" + Index: lit/Breakpoint/Inputs/break-insert.input === --- /dev/null +++ lit/Breakpoint/Inputs/break-insert.input @@ -0,0 +1,3 @@ +-break-insert breakpoint +-file-exec-and-symbols a.out +-exec-run Index: lit/Breakpoint/Inputs/break-insert.c === --- /dev/null +++ lit/Breakpoint/Inputs/break-insert.c @@ -0,0 +1,7 @@ +int breakpoint() { // Breakpoint will be set here. + return 0; +} + +int main() { + return breakpoint(); +} ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex updated this revision to Diff 146489. polyakov.alex added a comment. Added comments describing which lldb-mi command's output is currently parsing. Repository: rL LLVM https://reviews.llvm.org/D46588 Files: lit/Breakpoint/Inputs/break-insert.c lit/Breakpoint/Inputs/break-insert.input lit/Breakpoint/break-insert.test lit/lit.cfg tools/lldb-mi/MICmdCmdBreak.cpp tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp Index: tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp === --- tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp +++ tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp @@ -871,7 +871,10 @@ // Throws: None. //-- lldb::SBTarget CMICmnLLDBDebugSessionInfo::GetTarget() const { - return GetDebugger().GetSelectedTarget(); + auto target = GetDebugger().GetSelectedTarget(); + if (target.IsValid()) +return target; + return GetDebugger().GetDummyTarget(); } //++ Index: tools/lldb-mi/MICmdCmdBreak.cpp === --- tools/lldb-mi/MICmdCmdBreak.cpp +++ tools/lldb-mi/MICmdCmdBreak.cpp @@ -148,6 +148,11 @@ CMICMDBASE_GETOPTION(pArgRestrictBrkPtToThreadId, OptionShort, m_constStrArgNamedRestrictBrkPtToThreadId); + // Ask LLDB for the target to check if we have valid or dummy one. + CMICmnLLDBDebugSessionInfo &rSessionInfo( + CMICmnLLDBDebugSessionInfo::Instance()); + lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); + m_bBrkPtEnabled = !pArgDisableBrkPt->GetFound(); m_bBrkPtIsTemp = pArgTempBrkPt->GetFound(); m_bHaveArgOptionThreadGrp = pArgThreadGroup->GetFound(); @@ -157,7 +162,12 @@ nThreadGrp); m_strArgOptionThreadGrp = CMIUtilString::Format("i%d", nThreadGrp); } - m_bBrkPtIsPending = pArgPendingBrkPt->GetFound(); + + if (sbTarget == rSessionInfo.GetDebugger().GetDummyTarget()) +m_bBrkPtIsPending = true; + else +m_bBrkPtIsPending = pArgPendingBrkPt->GetFound(); + if (pArgLocation->GetFound()) m_brkName = pArgLocation->GetValue(); else if (m_bBrkPtIsPending) { @@ -225,9 +235,6 @@ // Ask LLDB to create a breakpoint bool bOk = MIstatus::success; - CMICmnLLDBDebugSessionInfo &rSessionInfo( - CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); switch (eBrkPtType) { case eBreakPoint_ByAddress: m_brkPt = sbTarget.BreakpointCreateByAddress(nAddress); Index: lit/lit.cfg === --- lit/lit.cfg +++ lit/lit.cfg @@ -58,6 +58,8 @@ lldb = "%s -S %s/lit-lldb-init" % (lit.util.which('lldb', lldb_tools_dir), config.test_source_root) +lldb_mi = lit.util.which('lldb-mi', lldb_tools_dir) + if not os.path.exists(config.cc): config.cc = lit.util.which(config.cc, config.environment['PATH']) @@ -79,6 +81,7 @@ config.substitutions.append(('%cc', config.cc)) config.substitutions.append(('%cxx', config.cxx)) +config.substitutions.append(('%lldb_mi', lldb_mi)) config.substitutions.append(('%lldb', lldb)) if debugserver is not None: Index: lit/Breakpoint/break-insert.test === --- /dev/null +++ lit/Breakpoint/break-insert.test @@ -0,0 +1,13 @@ +# RUN: %cc %p/Inputs/break-insert.c -g +# RUN: %lldb_mi < %p/Inputs/break-insert.input | FileCheck %s + +# cmd: -break-insert breakpoint +# CHECK: ^done,bkpt={number="1" + +# cmd: -file-exec-and-symbols a.out +# CHECK: ^done + +# cmd: -exec-run +# CHECK: ^running +# CHECK-AFTER: *stopped,reason="breakpoint-hit" + Index: lit/Breakpoint/Inputs/break-insert.input === --- /dev/null +++ lit/Breakpoint/Inputs/break-insert.input @@ -0,0 +1,3 @@ +-break-insert breakpoint +-file-exec-and-symbols a.out +-exec-run Index: lit/Breakpoint/Inputs/break-insert.c === --- /dev/null +++ lit/Breakpoint/Inputs/break-insert.c @@ -0,0 +1,7 @@ +int breakpoint() { // Breakpoint will be set here. + return 0; +} + +int main() { + return breakpoint(); +} ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex updated this revision to Diff 146693. polyakov.alex added a comment. Added more comments about the test. Repository: rL LLVM https://reviews.llvm.org/D46588 Files: lit/Breakpoint/Inputs/break-insert.c lit/Breakpoint/Inputs/break-insert.input lit/Breakpoint/break-insert.test lit/lit.cfg tools/lldb-mi/MICmdCmdBreak.cpp tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp Index: tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp === --- tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp +++ tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp @@ -871,7 +871,10 @@ // Throws: None. //-- lldb::SBTarget CMICmnLLDBDebugSessionInfo::GetTarget() const { - return GetDebugger().GetSelectedTarget(); + auto target = GetDebugger().GetSelectedTarget(); + if (target.IsValid()) +return target; + return GetDebugger().GetDummyTarget(); } //++ Index: tools/lldb-mi/MICmdCmdBreak.cpp === --- tools/lldb-mi/MICmdCmdBreak.cpp +++ tools/lldb-mi/MICmdCmdBreak.cpp @@ -148,6 +148,11 @@ CMICMDBASE_GETOPTION(pArgRestrictBrkPtToThreadId, OptionShort, m_constStrArgNamedRestrictBrkPtToThreadId); + // Ask LLDB for the target to check if we have valid or dummy one. + CMICmnLLDBDebugSessionInfo &rSessionInfo( + CMICmnLLDBDebugSessionInfo::Instance()); + lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); + m_bBrkPtEnabled = !pArgDisableBrkPt->GetFound(); m_bBrkPtIsTemp = pArgTempBrkPt->GetFound(); m_bHaveArgOptionThreadGrp = pArgThreadGroup->GetFound(); @@ -157,7 +162,12 @@ nThreadGrp); m_strArgOptionThreadGrp = CMIUtilString::Format("i%d", nThreadGrp); } - m_bBrkPtIsPending = pArgPendingBrkPt->GetFound(); + + if (sbTarget == rSessionInfo.GetDebugger().GetDummyTarget()) +m_bBrkPtIsPending = true; + else +m_bBrkPtIsPending = pArgPendingBrkPt->GetFound(); + if (pArgLocation->GetFound()) m_brkName = pArgLocation->GetValue(); else if (m_bBrkPtIsPending) { @@ -225,9 +235,6 @@ // Ask LLDB to create a breakpoint bool bOk = MIstatus::success; - CMICmnLLDBDebugSessionInfo &rSessionInfo( - CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); switch (eBrkPtType) { case eBreakPoint_ByAddress: m_brkPt = sbTarget.BreakpointCreateByAddress(nAddress); Index: lit/lit.cfg === --- lit/lit.cfg +++ lit/lit.cfg @@ -58,6 +58,8 @@ lldb = "%s -S %s/lit-lldb-init" % (lit.util.which('lldb', lldb_tools_dir), config.test_source_root) +lldb_mi = lit.util.which('lldb-mi', lldb_tools_dir) + if not os.path.exists(config.cc): config.cc = lit.util.which(config.cc, config.environment['PATH']) @@ -79,6 +81,7 @@ config.substitutions.append(('%cc', config.cc)) config.substitutions.append(('%cxx', config.cxx)) +config.substitutions.append(('%lldb_mi', lldb_mi)) config.substitutions.append(('%lldb', lldb)) if debugserver is not None: Index: lit/Breakpoint/break-insert.test === --- /dev/null +++ lit/Breakpoint/break-insert.test @@ -0,0 +1,15 @@ +# RUN: %cc %p/Inputs/break-insert.c -g +# RUN: %lldb_mi < %p/Inputs/break-insert.input | FileCheck %s + +# Test that a breakpoint can be inserted before creating a target. +# +# cmd: -break-insert breakpoint +# CHECK: ^done,bkpt={number="1" +# +# cmd: -file-exec-and-symbols a.out +# CHECK: ^done +# +# cmd: -exec-run +# CHECK: ^running +# CHECK-AFTER: *stopped,reason="breakpoint-hit" + Index: lit/Breakpoint/Inputs/break-insert.input === --- /dev/null +++ lit/Breakpoint/Inputs/break-insert.input @@ -0,0 +1,3 @@ +-break-insert breakpoint +-file-exec-and-symbols a.out +-exec-run Index: lit/Breakpoint/Inputs/break-insert.c === --- /dev/null +++ lit/Breakpoint/Inputs/break-insert.c @@ -0,0 +1,7 @@ +int breakpoint() { // Breakpoint will be set here. + return 0; +} + +int main() { + return breakpoint(); +} ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex added inline comments. Comment at: lit/Breakpoint/break-insert.test:5 +# cmd: -break-insert breakpoint +# CHECK: ^done,bkpt={number="1" + aprantl wrote: > Very nice! > > What does the actual output format of lldb-mi look like? > If every reply is on a single line, we could make this test even stricter by > using `CHECK-NEXT` instead of `CHECK` to make sure that no other output > appears between two matches. Alternatively you could also insert a > `CHECK-NOT: ^done` line before every command to make the test even stricter. Unfortunately, lldb-mi output may look like: (gdb) -exec-run ^running =thread-group-started,id="i1",pid="4632" =thread-created,id="1",group-id="i1" =thread-selected,id="1" (gdb) =library-loaded,id="/lib/x86_64-linux-gnu/ld-2.23.so",target-name="/lib/x86_64-linux-gnu/ld-2.23.so",host-name="/lib/x86_64-linux-gnu/ld-2.23.so",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so",loaded_addr="-",size="0" (gdb) =library-loaded,id="[vdso]",target-name="[vdso]",host-name="[vdso]",symbols-loaded="1",symbols-path="",loaded_addr="0x77ffa000",size="0" =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0041eed0",func="??",file="??",fullname="??/??",line="0",pending=["main"],times="0",original-location="main"} (gdb) (gdb) (gdb) =library-loaded,id="/bin/bash",target-name="/bin/bash",host-name="/bin/bash",symbols-loaded="0",loaded_addr="-",size="0" (gdb) *running,thread-id="all" (gdb) (gdb) =library-loaded,id="/lib/x86_64-linux-gnu/libtinfo.so.5",target-name="/lib/x86_64-linux-gnu/libtinfo.so.5",host-name="/lib/x86_64-linux-gnu/libtinfo.so.5",symbols-loaded="0",loaded_addr="-",size="0" (gdb) =library-loaded,id="/lib/x86_64-linux-gnu/libdl.so.2",target-name="/lib/x86_64-linux-gnu/libdl.so.2",host-name="/lib/x86_64-linux-gnu/libdl.so.2",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/libdl-2.23.so",loaded_addr="-",size="0" (gdb) =library-loaded,id="/lib/x86_64-linux-gnu/libc.so.6",target-name="/lib/x86_64-linux-gnu/libc.so.6",host-name="/lib/x86_64-linux-gnu/libc.so.6",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so",loaded_addr="-",size="0" (gdb) =library-loaded,id="/lib/x86_64-linux-gnu/libtinfo.so.5",target-name="/lib/x86_64-linux-gnu/libtinfo.so.5",host-name="/lib/x86_64-linux-gnu/libtinfo.so.5",symbols-loaded="0",loaded_addr="-",size="0" =library-loaded,id="/lib/x86_64-linux-gnu/libdl.so.2",target-name="/lib/x86_64-linux-gnu/libdl.so.2",host-name="/lib/x86_64-linux-gnu/libdl.so.2",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/libdl-2.23.so",loaded_addr="-",size="0" =library-loaded,id="/lib/x86_64-linux-gnu/libc.so.6",target-name="/lib/x86_64-linux-gnu/libc.so.6",host-name="/lib/x86_64-linux-gnu/libc.so.6",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so",loaded_addr="-",size="0" (gdb) *stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={level="0",addr="0x0041eed0",func="main",args=[],file="??",fullname="??",line="-1"},thread-id="1",stopped-threads="all" (gdb) So, I think, it's not a best idea to write 'CHECK-NOT' for each line. Repository: rL LLVM https://reviews.llvm.org/D46588 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex added inline comments. Comment at: lit/Breakpoint/break-insert.test:5 +# cmd: -break-insert breakpoint +# CHECK: ^done,bkpt={number="1" + polyakov.alex wrote: > aprantl wrote: > > Very nice! > > > > What does the actual output format of lldb-mi look like? > > If every reply is on a single line, we could make this test even stricter > > by using `CHECK-NEXT` instead of `CHECK` to make sure that no other output > > appears between two matches. Alternatively you could also insert a > > `CHECK-NOT: ^done` line before every command to make the test even stricter. > Unfortunately, lldb-mi output may look like: > > (gdb) > -exec-run > ^running > =thread-group-started,id="i1",pid="4632" > =thread-created,id="1",group-id="i1" > =thread-selected,id="1" > (gdb) > =library-loaded,id="/lib/x86_64-linux-gnu/ld-2.23.so",target-name="/lib/x86_64-linux-gnu/ld-2.23.so",host-name="/lib/x86_64-linux-gnu/ld-2.23.so",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so",loaded_addr="-",size="0" > (gdb) > =library-loaded,id="[vdso]",target-name="[vdso]",host-name="[vdso]",symbols-loaded="1",symbols-path="",loaded_addr="0x77ffa000",size="0" > =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0041eed0",func="??",file="??",fullname="??/??",line="0",pending=["main"],times="0",original-location="main"} > (gdb) > (gdb) > (gdb) > =library-loaded,id="/bin/bash",target-name="/bin/bash",host-name="/bin/bash",symbols-loaded="0",loaded_addr="-",size="0" > (gdb) > *running,thread-id="all" > (gdb) > (gdb) > =library-loaded,id="/lib/x86_64-linux-gnu/libtinfo.so.5",target-name="/lib/x86_64-linux-gnu/libtinfo.so.5",host-name="/lib/x86_64-linux-gnu/libtinfo.so.5",symbols-loaded="0",loaded_addr="-",size="0" > (gdb) > =library-loaded,id="/lib/x86_64-linux-gnu/libdl.so.2",target-name="/lib/x86_64-linux-gnu/libdl.so.2",host-name="/lib/x86_64-linux-gnu/libdl.so.2",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/libdl-2.23.so",loaded_addr="-",size="0" > (gdb) > =library-loaded,id="/lib/x86_64-linux-gnu/libc.so.6",target-name="/lib/x86_64-linux-gnu/libc.so.6",host-name="/lib/x86_64-linux-gnu/libc.so.6",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so",loaded_addr="-",size="0" > (gdb) > =library-loaded,id="/lib/x86_64-linux-gnu/libtinfo.so.5",target-name="/lib/x86_64-linux-gnu/libtinfo.so.5",host-name="/lib/x86_64-linux-gnu/libtinfo.so.5",symbols-loaded="0",loaded_addr="-",size="0" > =library-loaded,id="/lib/x86_64-linux-gnu/libdl.so.2",target-name="/lib/x86_64-linux-gnu/libdl.so.2",host-name="/lib/x86_64-linux-gnu/libdl.so.2",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/libdl-2.23.so",loaded_addr="-",size="0" > =library-loaded,id="/lib/x86_64-linux-gnu/libc.so.6",target-name="/lib/x86_64-linux-gnu/libc.so.6",host-name="/lib/x86_64-linux-gnu/libc.so.6",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so",loaded_addr="-",size="0" > (gdb) > *stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={level="0",addr="0x0041eed0",func="main",args=[],file="??",fullname="??",line="-1"},thread-id="1",stopped-threads="all" > (gdb) > > So, I think, it's not a best idea to write 'CHECK-NOT' for each line. Ah, my fault, there will not be such amount of lines if we use test's binary. Repository: rL LLVM https://reviews.llvm.org/D46588 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex updated this revision to Diff 146777. polyakov.alex added a comment. Created separate directory for an lldb-mi tests. Repository: rL LLVM https://reviews.llvm.org/D46588 Files: lit/lit.cfg lit/tools/lldb-mi/breakpoint/break-insert.test lit/tools/lldb-mi/breakpoint/inputs/break-insert.c lit/tools/lldb-mi/breakpoint/lit.local.cfg tools/lldb-mi/MICmdCmdBreak.cpp tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp Index: tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp === --- tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp +++ tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp @@ -871,7 +871,10 @@ // Throws: None. //-- lldb::SBTarget CMICmnLLDBDebugSessionInfo::GetTarget() const { - return GetDebugger().GetSelectedTarget(); + auto target = GetDebugger().GetSelectedTarget(); + if (target.IsValid()) +return target; + return GetDebugger().GetDummyTarget(); } //++ Index: tools/lldb-mi/MICmdCmdBreak.cpp === --- tools/lldb-mi/MICmdCmdBreak.cpp +++ tools/lldb-mi/MICmdCmdBreak.cpp @@ -148,6 +148,11 @@ CMICMDBASE_GETOPTION(pArgRestrictBrkPtToThreadId, OptionShort, m_constStrArgNamedRestrictBrkPtToThreadId); + // Ask LLDB for the target to check if we have valid or dummy one. + CMICmnLLDBDebugSessionInfo &rSessionInfo( + CMICmnLLDBDebugSessionInfo::Instance()); + lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); + m_bBrkPtEnabled = !pArgDisableBrkPt->GetFound(); m_bBrkPtIsTemp = pArgTempBrkPt->GetFound(); m_bHaveArgOptionThreadGrp = pArgThreadGroup->GetFound(); @@ -157,7 +162,12 @@ nThreadGrp); m_strArgOptionThreadGrp = CMIUtilString::Format("i%d", nThreadGrp); } - m_bBrkPtIsPending = pArgPendingBrkPt->GetFound(); + + if (sbTarget == rSessionInfo.GetDebugger().GetDummyTarget()) +m_bBrkPtIsPending = true; + else +m_bBrkPtIsPending = pArgPendingBrkPt->GetFound(); + if (pArgLocation->GetFound()) m_brkName = pArgLocation->GetValue(); else if (m_bBrkPtIsPending) { @@ -225,9 +235,6 @@ // Ask LLDB to create a breakpoint bool bOk = MIstatus::success; - CMICmnLLDBDebugSessionInfo &rSessionInfo( - CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); switch (eBrkPtType) { case eBreakPoint_ByAddress: m_brkPt = sbTarget.BreakpointCreateByAddress(nAddress); Index: lit/tools/lldb-mi/breakpoint/lit.local.cfg === --- /dev/null +++ lit/tools/lldb-mi/breakpoint/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] Index: lit/tools/lldb-mi/breakpoint/inputs/break-insert.c === --- /dev/null +++ lit/tools/lldb-mi/breakpoint/inputs/break-insert.c @@ -0,0 +1,7 @@ +int breakpoint() { // Breakpoint will be set here. + return 0; +} + +int main() { + return breakpoint(); +} Index: lit/tools/lldb-mi/breakpoint/break-insert.test === --- /dev/null +++ lit/tools/lldb-mi/breakpoint/break-insert.test @@ -0,0 +1,15 @@ +# RUN: %cc %p/inputs/break-insert.c -g +# RUN: %lldb_mi < %s | FileCheck %s + +# Test that a breakpoint can be inserted before creating a target. + +-break-insert breakpoint +# CHECK: ^done,bkpt={number="1" + +-file-exec-and-symbols a.out +# CHECK-AFTER: ^done + +-exec-run +# CHECK-AFTER: ^running +# CHECK-AFTER: *stopped,reason="breakpoint-hit" + Index: lit/lit.cfg === --- lit/lit.cfg +++ lit/lit.cfg @@ -58,6 +58,8 @@ lldb = "%s -S %s/lit-lldb-init" % (lit.util.which('lldb', lldb_tools_dir), config.test_source_root) +lldb_mi = lit.util.which('lldb-mi', lldb_tools_dir) + if not os.path.exists(config.cc): config.cc = lit.util.which(config.cc, config.environment['PATH']) @@ -79,6 +81,7 @@ config.substitutions.append(('%cc', config.cc)) config.substitutions.append(('%cxx', config.cxx)) +config.substitutions.append(('%lldb_mi', lldb_mi)) config.substitutions.append(('%lldb', lldb)) if debugserver is not None: ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex added a comment. Also, I combined FileCheck commands and lldb-mi input in a single file. Repository: rL LLVM https://reviews.llvm.org/D46588 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex added inline comments. Comment at: lit/tools/lldb-mi/breakpoint/break-insert.test:10 +-file-exec-and-symbols a.out +# CHECK-AFTER: ^done + labath wrote: > I'm not familiar with this directive. Are you sure that this actually does > anything? I tried to use only CHECK directive, but got errors like pattern not found, so I decided that it may be caused due to CHECK search features, for example, as I know, it finds pattern from the start of the file. If we want to check lldb-mi output, we should follow a specific order. In our case, we should find "^done" string directly after -break-insert command's output. Repository: rL LLVM https://reviews.llvm.org/D46588 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex added inline comments. Comment at: lit/tools/lldb-mi/breakpoint/break-insert.test:10 +-file-exec-and-symbols a.out +# CHECK-AFTER: ^done + labath wrote: > polyakov.alex wrote: > > labath wrote: > > > I'm not familiar with this directive. Are you sure that this actually > > > does anything? > > I tried to use only CHECK directive, but got errors like pattern not found, > > so I decided that it may be caused due to CHECK search features, for > > example, as I know, it finds pattern from the start of the file. If we want > > to check lldb-mi output, we should follow a specific order. > > > > In our case, we should find "^done" string directly after -break-insert > > command's output. > I think you got the FileCheck operation wrong. > a `CHECK` should always start matching from the previous match. The reason > that this is passing for you now is that CHECK-AFTER is a non-existing > directive and FileCheck ignores it (try replacing it with a bogus string and > see if it still passes). if `CHECK` is not working for you here then you > probably have the pattern wrong. You are right about the CHECK-AFTER. I wrote the test using only check and found an issue: after executing of -exec-run command, we expect to see output like: *stopped,reason="breakpoint-hit" but, I think, that FileCheck check file for the pattern, while a -exec-run hasn't finished yet. It means that there will not be expected output and we'll get the error: no such pattern. Is there a mechanism to add some delay to FileCheck to wait until -exec-run finished? Repository: rL LLVM https://reviews.llvm.org/D46588 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex added inline comments. Comment at: lit/tools/lldb-mi/breakpoint/break-insert.test:10 +-file-exec-and-symbols a.out +# CHECK-AFTER: ^done + labath wrote: > polyakov.alex wrote: > > labath wrote: > > > polyakov.alex wrote: > > > > labath wrote: > > > > > I'm not familiar with this directive. Are you sure that this actually > > > > > does anything? > > > > I tried to use only CHECK directive, but got errors like pattern not > > > > found, so I decided that it may be caused due to CHECK search features, > > > > for example, as I know, it finds pattern from the start of the file. If > > > > we want to check lldb-mi output, we should follow a specific order. > > > > > > > > In our case, we should find "^done" string directly after -break-insert > > > > command's output. > > > I think you got the FileCheck operation wrong. > > > a `CHECK` should always start matching from the previous match. The > > > reason that this is passing for you now is that CHECK-AFTER is a > > > non-existing directive and FileCheck ignores it (try replacing it with a > > > bogus string and see if it still passes). if `CHECK` is not working for > > > you here then you probably have the pattern wrong. > > You are right about the CHECK-AFTER. I wrote the test using only check and > > found an issue: > > after executing of -exec-run command, we expect to see output like: > > *stopped,reason="breakpoint-hit" > > but, I think, that FileCheck check file for the pattern, while a -exec-run > > hasn't finished yet. It means that there will not be expected output and > > we'll get the error: no such pattern. > > > > Is there a mechanism to add some delay to FileCheck to wait until -exec-run > > finished? > > > There shouldn't be a need for anything like that. FileCheck will wait until > EOF before doing anything. In fact, if you try running the test script > manually (`lldb-mi does *not* print out the `*stopped` line. What I expect is happening here is > that lldb-mi reaches EOF, and then decides there is nothing left for it to do > and exits (a somewhat reasonable assumption given that it's expecting to be > talking via an interactive link). > > This sounds like a fairly fundamental problem with the lit+FileCheck testing > strategy. If we're not able to come up with a command to make lldb-mi wait > until the target stops (maybe there is one already? I know very little about > lldb-mi), we may have to revisit the whole testing strategy... I tried to run script manually (!!lldb-mi < break-insert.test!!) and got output which isn't useful for testing !!-break-insert!! command since there isn't any information about hitting breakpoint. ``` ~/workspace/gsoc/build/bin/lldb-mi < ../break-insert.test (gdb) ^done (gdb) ^done (gdb) ^done (gdb) ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x",func="??",file="??",fullname="??/??",line="0",pending=["breakpoint"],times="0",original-location="breakpoint"} (gdb) =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x",func="??",file="??",fullname="??/??",line="0",pending=["breakpoint"],times="0",original-location="breakpoint"} (gdb) ^done (gdb) ^done (gdb) =library-loaded,id="/home/alexander/workspace/gsoc/llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/inputs/a.out",target-name="/home/alexander/workspace/gsoc/llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/inputs/a.out",host-name="/home/alexander/workspace/gsoc/llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/inputs/a.out",symbols-loaded="0",loaded_addr="-",size="0" =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x004004c6",func="breakpoint",file="break-insert.c",fullname="/home/alexander/workspace/gsoc/llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/inputs/break-insert.c",line="2",pending=["breakpoint"],times="0",original-location="breakpoint"} (gdb) ^done (gdb) ^done (gdb) ^running =thread-group-started,id="i1",pid="13757" (gdb) =thread-created,id="1",group-id="i1" =thread-selected,id="1" (gdb) =library-loaded,id="/lib/x86_64-linux-gnu/ld-2.23.so",target-name="/lib/x86_64-linux-gnu/ld-2.23.so",host-name="/lib/x86_64-linux-gnu/ld-2.23.so",symbols-loaded="1",symbols-path="/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so",loaded_addr="-",size="0" (gdb) =library-loaded,id="[vdso]",target-name="[vdso]",host-name="[vdso]",symbols-loaded="1",symbols-path="",loaded_addr="0x77ffa000",size="0" =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x004004c6",func="breakpoint",file="break-insert.c",fullname="/home/alexander/workspace/gsoc/llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/inputs/break-insert.c",line="2",pending=["breakpoint"],times="0",original-location="breakpoint"} (gdb) (gdb) =library-loaded,id="/home/alexander/workspace/gsoc/llvm/tools/lldb/lit/tools/lldb-mi/breakpoint/inputs/a.out",target-name="/home/alexande
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex added inline comments. Comment at: lit/tools/lldb-mi/breakpoint/break-insert.test:14 +# CHECK-AFTER: ^running +# CHECK-AFTER: *stopped,reason="breakpoint-hit" + aprantl wrote: > CHECK-AFTER is not recognized by FileCheck: > > https://www.llvm.org/docs/CommandGuide/FileCheck.html > > You probably saw this in a testcase that ran FileCheck twice, one time with > the CHECK prefix and once with a custom `--check-prefix=CHECK-AFTER` which is > a common trick to have more than one set of FileCheck directives in a single > file. Yes. There is no problem to write test using only `CHECK` and `CHECK-NOT`, but as I said, in lldb-mi's output we can't find any info about hitting breakpoint, so the question is: is it enough to check that breakpoint was set to a selected target? Repository: rL LLVM https://reviews.llvm.org/D46588 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex updated this revision to Diff 147117. polyakov.alex added a comment. I have all the patches I was sending. I will follow this topic until you decide what to do with lldb-mi testing. Repository: rL LLVM https://reviews.llvm.org/D46588 Files: packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py tools/lldb-mi/MICmdCmdBreak.cpp tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp Index: tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp === --- tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp +++ tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp @@ -871,7 +871,10 @@ // Throws: None. //-- lldb::SBTarget CMICmnLLDBDebugSessionInfo::GetTarget() const { - return GetDebugger().GetSelectedTarget(); + auto target = GetDebugger().GetSelectedTarget(); + if (target.IsValid()) +return target; + return GetDebugger().GetDummyTarget(); } //++ Index: tools/lldb-mi/MICmdCmdBreak.cpp === --- tools/lldb-mi/MICmdCmdBreak.cpp +++ tools/lldb-mi/MICmdCmdBreak.cpp @@ -148,6 +148,11 @@ CMICMDBASE_GETOPTION(pArgRestrictBrkPtToThreadId, OptionShort, m_constStrArgNamedRestrictBrkPtToThreadId); + // Ask LLDB for the target to check if we have valid or dummy one. + CMICmnLLDBDebugSessionInfo &rSessionInfo( + CMICmnLLDBDebugSessionInfo::Instance()); + lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); + m_bBrkPtEnabled = !pArgDisableBrkPt->GetFound(); m_bBrkPtIsTemp = pArgTempBrkPt->GetFound(); m_bHaveArgOptionThreadGrp = pArgThreadGroup->GetFound(); @@ -157,7 +162,12 @@ nThreadGrp); m_strArgOptionThreadGrp = CMIUtilString::Format("i%d", nThreadGrp); } - m_bBrkPtIsPending = pArgPendingBrkPt->GetFound(); + + if (sbTarget == rSessionInfo.GetDebugger().GetDummyTarget()) +m_bBrkPtIsPending = true; + else +m_bBrkPtIsPending = pArgPendingBrkPt->GetFound(); + if (pArgLocation->GetFound()) m_brkName = pArgLocation->GetValue(); else if (m_bBrkPtIsPending) { @@ -225,9 +235,6 @@ // Ask LLDB to create a breakpoint bool bOk = MIstatus::success; - CMICmnLLDBDebugSessionInfo &rSessionInfo( - CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); switch (eBrkPtType) { case eBreakPoint_ByAddress: m_brkPt = sbTarget.BreakpointCreateByAddress(nAddress); Index: packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py === --- packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py +++ packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py @@ -143,6 +143,32 @@ self.expect("\^running") self.expect("\*stopped,reason=\"breakpoint-hit\"") +@skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows. +@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races. +@skipIfRemote # We do not currently support remote debugging via the MI. +def test_lldbmi_break_insert_without_target(self): +"""Test that 'lldb-mi --interpreter' can set breakpoints without +selecting a valid target.""" + +self.spawnLldbMi(args=None) + +# This command have to insert breakpoint to the dummy target. +self.runCmd("-break-insert main") +# FIXME function name is unknown on Darwin, fullname should be ??, line is -1 +self.expect( + "\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\"," + "addr=\"0x\",func=\"\?\?\",file=\"\?\?\",fullname=\"\?\?/\?\?\"," + "line=\"0\",pending=\[\"main\"\],times=\"0\",original-location=\"main\"}" +) + +# Add a valid target. +self.runCmd("-file-exec-and-symbols %s" % self.myexe) +self.expect("\^done") + +self.runCmd("-exec-run") +self.expect("\^running") +self.expect("\*stopped,reason=\"breakpoint-hit\"") + @skipIfWindows # llvm.org/pr24452: Get lldb-mi tests working on Windows @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races @skipIfRemote # We do not currently support remote debugging via the MI. Index: tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp === --- tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp +++ tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp @@ -871,7 +871,10 @@ // Throws: None. //-- lldb::SBTarget CMICmnLLDBDebugSessionInfo::GetTarget() const { - return GetDebugger().GetSelectedTarget(); + auto target = GetDebugger().GetSelectedTarget(); + if (target.IsValid()) +return target; + return GetDebugger().GetDummyTarget(); } //++ Index: tools/lldb-mi/MICmdCmdBreak.cpp === --- tools/lldb-mi/MICmdCmdBreak
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex added a comment. In https://reviews.llvm.org/D46588#1103180, @aprantl wrote: > My overall mental image of lldb-mi is very incomplete, but I'm imagining > lldb-mi as having one thread that wakes up every n milliseconds checks for > command input and then calls into the SBAPI to handle the commands. If that > is how it works, then one very simple thing we can try is to call > SBDebugger::SetAsync(false), thus forcing all the SBAPI calls to block until > completion. > > Alexander, can you see what happens to your lit test when you enable > synchronous mode in the SBAPI? Does it block now as expected, or does it > still finish early? If that experiment works, we could add a --async command > line option to lldb-mi to enable this behavior for running the test suite. Where is the right place to call SBDebugger::SetAsync(true) to enable asynchronous mode? Repository: rL LLVM https://reviews.llvm.org/D46588 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex added a comment. In https://reviews.llvm.org/D46588#1103237, @aprantl wrote: > For the experiment you can probably just stick it into > `CMICmnLLDBDebugger::InitSBDebugger()`. Yep, after that, test is passing with only `CHECK` directives. Repository: rL LLVM https://reviews.llvm.org/D46588 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47110: [LLDB, lldb-mi] Add option --synchronous.
polyakov.alex created this revision. polyakov.alex added reviewers: aprantl, clayborg, labath. Herald added subscribers: llvm-commits, ki.stfu. Option --synchronous disables asynchronous mode in the lldb-mi driver. Used for testing only. Repository: rL LLVM https://reviews.llvm.org/D47110 Files: tools/lldb-mi/MICmnResources.cpp tools/lldb-mi/MICmnResources.h tools/lldb-mi/MIDriver.cpp tools/lldb-mi/MIDriverMgr.cpp Index: tools/lldb-mi/MIDriverMgr.cpp === --- tools/lldb-mi/MIDriverMgr.cpp +++ tools/lldb-mi/MIDriverMgr.cpp @@ -640,6 +640,7 @@ MIRSRC(IDE_MI_APP_ARG_VERSION), MIRSRC(IDE_MI_APP_ARG_VERSION_LONG), MIRSRC(IDE_MI_APP_ARG_INTERPRETER), MIRSRC(IDE_MI_APP_ARG_SOURCE), MIRSRC(IDE_MI_APP_ARG_EXECUTEABLE), + MIRSRC(IDE_MI_APP_ARG_SYNCHRONOUS), CMIUtilString::Format( MIRSRC(IDE_MI_APP_ARG_APP_LOG), CMICmnLogMediumFile::Instance().GetFileName().c_str()), Index: tools/lldb-mi/MIDriver.cpp === --- tools/lldb-mi/MIDriver.cpp +++ tools/lldb-mi/MIDriver.cpp @@ -382,6 +382,7 @@ // that are only handled by *this driver: // --executable // --source or -s +// --synchronous // The application's options --interpreter and --executable in code act // very similar. // The --executable is necessary to differentiate whether the MI Driver @@ -397,6 +398,7 @@ // argument for a debug session. Using --interpreter on the command // line does not // issue additional commands to initialise a debug session. +// Option --synchronous disables an asynchronous mode in the lldb-mi driver. // Type:Overridden. // Args:argc- (R) An integer that contains the count of arguments // that follow in @@ -436,6 +438,10 @@ const CMIUtilString strArg(argv[i]); const CMICmdArgValFile argFile; + if (strArg.compare("--synchronous") == 0) { +CMICmnLLDBDebugSessionInfo::Instance().GetDebugger().SetAsync(false); + } + // Check for a filename if (argFile.IsFilePath(strArg) || CMICmdArgValString(true, false, true).IsStringArg(strArg)) { Index: tools/lldb-mi/MICmnResources.h === --- tools/lldb-mi/MICmnResources.h +++ tools/lldb-mi/MICmnResources.h @@ -77,6 +77,7 @@ IDE_MI_APP_ARG_APP_LOG_DIR, IDE_MI_APP_ARG_EXAMPLE, IDE_MI_APP_ARG_EXECUTABLE, + IDE_MI_APP_ARG_SYNCHRONOUS, IDS_STDIN_ERR_INVALID_PROMPT, IDS_STDIN_ERR_THREAD_CREATION_FAILED, Index: tools/lldb-mi/MICmnResources.cpp === --- tools/lldb-mi/MICmnResources.cpp +++ tools/lldb-mi/MICmnResources.cpp @@ -110,6 +110,8 @@ {IDE_MI_APP_ARG_EXECUTABLE, "executable (NOT IMPLEMENTED)\n\tThe file " "path to the executable i.e. '\"C:\\My " "Dev\\foo.exe\"'."}, +{IDE_MI_APP_ARG_SYNCHRONOUS, "--synchronous\n\tBlock until each command " + "has finished executing.\n\tUsed for testing only."}, {IDS_STDIN_ERR_INVALID_PROMPT, "Stdin. Invalid prompt description '%s'"}, {IDS_STDIN_ERR_THREAD_CREATION_FAILED, Index: tools/lldb-mi/MIDriverMgr.cpp === --- tools/lldb-mi/MIDriverMgr.cpp +++ tools/lldb-mi/MIDriverMgr.cpp @@ -640,6 +640,7 @@ MIRSRC(IDE_MI_APP_ARG_VERSION), MIRSRC(IDE_MI_APP_ARG_VERSION_LONG), MIRSRC(IDE_MI_APP_ARG_INTERPRETER), MIRSRC(IDE_MI_APP_ARG_SOURCE), MIRSRC(IDE_MI_APP_ARG_EXECUTEABLE), + MIRSRC(IDE_MI_APP_ARG_SYNCHRONOUS), CMIUtilString::Format( MIRSRC(IDE_MI_APP_ARG_APP_LOG), CMICmnLogMediumFile::Instance().GetFileName().c_str()), Index: tools/lldb-mi/MIDriver.cpp === --- tools/lldb-mi/MIDriver.cpp +++ tools/lldb-mi/MIDriver.cpp @@ -382,6 +382,7 @@ // that are only handled by *this driver: // --executable // --source or -s +// --synchronous // The application's options --interpreter and --executable in code act // very similar. // The --executable is necessary to differentiate whether the MI Driver @@ -397,6 +398,7 @@ // argument for a debug session. Using --interpreter on the command // line does not // issue additional commands to initialise a debug session. +// Option --synchronous disables an asynchronous mode in the lldb-mi driver. // Type:Overridden. // Args:argc- (R) An integer that contains the count of arguments // that follow in @@ -436,6 +438,10 @@ const CMIUtilSt
[Lldb-commits] [PATCH] D47110: [LLDB, lldb-mi] Add option --synchronous.
polyakov.alex added a comment. This option is needed by https://reviews.llvm.org/D46588. Repository: rL LLVM https://reviews.llvm.org/D47110 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex updated this revision to Diff 147681. polyakov.alex added a comment. This version of commit uses the new lldb-mi option that I added to review https://reviews.llvm.org/D47110. Repository: rL LLVM https://reviews.llvm.org/D46588 Files: lit/lit.cfg lit/tools/lldb-mi/breakpoint/break-insert.test lit/tools/lldb-mi/breakpoint/inputs/break-insert.c lit/tools/lldb-mi/breakpoint/lit.local.cfg tools/lldb-mi/MICmdCmdBreak.cpp tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp Index: tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp === --- tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp +++ tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp @@ -871,7 +871,10 @@ // Throws: None. //-- lldb::SBTarget CMICmnLLDBDebugSessionInfo::GetTarget() const { - return GetDebugger().GetSelectedTarget(); + auto target = GetDebugger().GetSelectedTarget(); + if (target.IsValid()) +return target; + return GetDebugger().GetDummyTarget(); } //++ Index: tools/lldb-mi/MICmdCmdBreak.cpp === --- tools/lldb-mi/MICmdCmdBreak.cpp +++ tools/lldb-mi/MICmdCmdBreak.cpp @@ -148,6 +148,11 @@ CMICMDBASE_GETOPTION(pArgRestrictBrkPtToThreadId, OptionShort, m_constStrArgNamedRestrictBrkPtToThreadId); + // Ask LLDB for the target to check if we have valid or dummy one. + CMICmnLLDBDebugSessionInfo &rSessionInfo( + CMICmnLLDBDebugSessionInfo::Instance()); + lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); + m_bBrkPtEnabled = !pArgDisableBrkPt->GetFound(); m_bBrkPtIsTemp = pArgTempBrkPt->GetFound(); m_bHaveArgOptionThreadGrp = pArgThreadGroup->GetFound(); @@ -157,7 +162,12 @@ nThreadGrp); m_strArgOptionThreadGrp = CMIUtilString::Format("i%d", nThreadGrp); } - m_bBrkPtIsPending = pArgPendingBrkPt->GetFound(); + + if (sbTarget == rSessionInfo.GetDebugger().GetDummyTarget()) +m_bBrkPtIsPending = true; + else +m_bBrkPtIsPending = pArgPendingBrkPt->GetFound(); + if (pArgLocation->GetFound()) m_brkName = pArgLocation->GetValue(); else if (m_bBrkPtIsPending) { @@ -225,9 +235,6 @@ // Ask LLDB to create a breakpoint bool bOk = MIstatus::success; - CMICmnLLDBDebugSessionInfo &rSessionInfo( - CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); switch (eBrkPtType) { case eBreakPoint_ByAddress: m_brkPt = sbTarget.BreakpointCreateByAddress(nAddress); Index: lit/tools/lldb-mi/breakpoint/lit.local.cfg === --- /dev/null +++ lit/tools/lldb-mi/breakpoint/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] Index: lit/tools/lldb-mi/breakpoint/inputs/break-insert.c === --- /dev/null +++ lit/tools/lldb-mi/breakpoint/inputs/break-insert.c @@ -0,0 +1,7 @@ +int breakpoint() { // Breakpoint will be set here. + return 0; +} + +int main() { + return breakpoint(); +} Index: lit/tools/lldb-mi/breakpoint/break-insert.test === --- /dev/null +++ lit/tools/lldb-mi/breakpoint/break-insert.test @@ -0,0 +1,15 @@ +# RUN: %cc %p/inputs/break-insert.c -g +# RUN: %lldb_mi < %s | FileCheck %s + +# Test that a breakpoint can be inserted before creating a target. + +-break-insert breakpoint +# CHECK: ^done,bkpt={number="1" + +-file-exec-and-symbols a.out +# CHECK: ^done + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + Index: lit/lit.cfg === --- lit/lit.cfg +++ lit/lit.cfg @@ -58,6 +58,8 @@ lldb = "%s -S %s/lit-lldb-init" % (lit.util.which('lldb', lldb_tools_dir), config.test_source_root) +lldb_mi = lit.util.which('lldb-mi', lldb_tools_dir) + if not os.path.exists(config.cc): config.cc = lit.util.which(config.cc, config.environment['PATH']) @@ -79,6 +81,7 @@ config.substitutions.append(('%cc', config.cc)) config.substitutions.append(('%cxx', config.cxx)) +config.substitutions.append(('%lldb_mi', lldb_mi + " --synchronous")) config.substitutions.append(('%lldb', lldb)) if debugserver is not None: ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47110: [LLDB, lldb-mi] Add option --synchronous.
polyakov.alex updated this revision to Diff 147806. polyakov.alex added a comment. Moved the option parsing code down by the others. Repository: rL LLVM https://reviews.llvm.org/D47110 Files: tools/lldb-mi/MICmnResources.cpp tools/lldb-mi/MICmnResources.h tools/lldb-mi/MIDriver.cpp tools/lldb-mi/MIDriverMgr.cpp Index: tools/lldb-mi/MIDriverMgr.cpp === --- tools/lldb-mi/MIDriverMgr.cpp +++ tools/lldb-mi/MIDriverMgr.cpp @@ -640,6 +640,7 @@ MIRSRC(IDE_MI_APP_ARG_VERSION), MIRSRC(IDE_MI_APP_ARG_VERSION_LONG), MIRSRC(IDE_MI_APP_ARG_INTERPRETER), MIRSRC(IDE_MI_APP_ARG_SOURCE), MIRSRC(IDE_MI_APP_ARG_EXECUTEABLE), + MIRSRC(IDE_MI_APP_ARG_SYNCHRONOUS), CMIUtilString::Format( MIRSRC(IDE_MI_APP_ARG_APP_LOG), CMICmnLogMediumFile::Instance().GetFileName().c_str()), Index: tools/lldb-mi/MIDriver.cpp === --- tools/lldb-mi/MIDriver.cpp +++ tools/lldb-mi/MIDriver.cpp @@ -382,6 +382,7 @@ // that are only handled by *this driver: // --executable // --source or -s +// --synchronous // The application's options --interpreter and --executable in code act // very similar. // The --executable is necessary to differentiate whether the MI Driver @@ -397,6 +398,7 @@ // argument for a debug session. Using --interpreter on the command // line does not // issue additional commands to initialise a debug session. +// Option --synchronous disables an asynchronous mode in the lldb-mi driver. // Type:Overridden. // Args:argc- (R) An integer that contains the count of arguments // that follow in @@ -469,6 +471,8 @@ // command line { // See fn description. bHaveExecutableLongOption = true; + } else if (strArg.compare("--synchronous") == 0) { +CMICmnLLDBDebugSessionInfo::Instance().GetDebugger().SetAsync(false); } } } Index: tools/lldb-mi/MICmnResources.h === --- tools/lldb-mi/MICmnResources.h +++ tools/lldb-mi/MICmnResources.h @@ -77,6 +77,7 @@ IDE_MI_APP_ARG_APP_LOG_DIR, IDE_MI_APP_ARG_EXAMPLE, IDE_MI_APP_ARG_EXECUTABLE, + IDE_MI_APP_ARG_SYNCHRONOUS, IDS_STDIN_ERR_INVALID_PROMPT, IDS_STDIN_ERR_THREAD_CREATION_FAILED, Index: tools/lldb-mi/MICmnResources.cpp === --- tools/lldb-mi/MICmnResources.cpp +++ tools/lldb-mi/MICmnResources.cpp @@ -110,6 +110,8 @@ {IDE_MI_APP_ARG_EXECUTABLE, "executable (NOT IMPLEMENTED)\n\tThe file " "path to the executable i.e. '\"C:\\My " "Dev\\foo.exe\"'."}, +{IDE_MI_APP_ARG_SYNCHRONOUS, "--synchronous\n\tBlock until each command " + "has finished executing.\n\tUsed for testing only."}, {IDS_STDIN_ERR_INVALID_PROMPT, "Stdin. Invalid prompt description '%s'"}, {IDS_STDIN_ERR_THREAD_CREATION_FAILED, Index: tools/lldb-mi/MIDriverMgr.cpp === --- tools/lldb-mi/MIDriverMgr.cpp +++ tools/lldb-mi/MIDriverMgr.cpp @@ -640,6 +640,7 @@ MIRSRC(IDE_MI_APP_ARG_VERSION), MIRSRC(IDE_MI_APP_ARG_VERSION_LONG), MIRSRC(IDE_MI_APP_ARG_INTERPRETER), MIRSRC(IDE_MI_APP_ARG_SOURCE), MIRSRC(IDE_MI_APP_ARG_EXECUTEABLE), + MIRSRC(IDE_MI_APP_ARG_SYNCHRONOUS), CMIUtilString::Format( MIRSRC(IDE_MI_APP_ARG_APP_LOG), CMICmnLogMediumFile::Instance().GetFileName().c_str()), Index: tools/lldb-mi/MIDriver.cpp === --- tools/lldb-mi/MIDriver.cpp +++ tools/lldb-mi/MIDriver.cpp @@ -382,6 +382,7 @@ // that are only handled by *this driver: // --executable // --source or -s +// --synchronous // The application's options --interpreter and --executable in code act // very similar. // The --executable is necessary to differentiate whether the MI Driver @@ -397,6 +398,7 @@ // argument for a debug session. Using --interpreter on the command // line does not // issue additional commands to initialise a debug session. +// Option --synchronous disables an asynchronous mode in the lldb-mi driver. // Type:Overridden. // Args:argc- (R) An integer that contains the count of arguments // that follow in @@ -469,6 +471,8 @@ // command line { // See fn description.
[Lldb-commits] [PATCH] D47302: [lldb, lldb-mi] Add method AddCurrentTargetSharedObjectPath to the SBDebugger.
polyakov.alex created this revision. polyakov.alex added a reviewer: aprantl. Herald added a subscriber: llvm-commits. The new method adds to the current target a path to search for a shared objects. Repository: rL LLVM https://reviews.llvm.org/D47302 Files: include/lldb/API/SBDebugger.h source/API/SBDebugger.cpp Index: source/API/SBDebugger.cpp === --- source/API/SBDebugger.cpp +++ source/API/SBDebugger.cpp @@ -1123,6 +1123,38 @@ return false; } +bool SBDebugger::AddCurrentTargetSharedObjectPath(const char *from, + const char *to, + lldb::SBError &sb_error) { + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + auto target_sp = GetSelectedTarget().GetSP(); + + if (target_sp->IsValid()) { +if (from[0] && to[0]) { + if (log) +log->Printf("SBDebugger::AddCurrentPlatformSharedObjectPath: '%s' -> '%s'", +from, to); + target_sp->GetImageSearchPathList().Append( + ConstString(from), ConstString(to), true); + return true; +} else { + if (from[0]) +sb_error.SetErrorString(" can't be empty> " + "(SBDebugger::AddCurrentPlatformSharedObjectPath) " +"returned false"); + else +sb_error.SetErrorString(" can't be empty> " + "(SBDebugger::AddCurrentPlatformSharedObjectPath) " +"returned false"); + return false; +} + } + sb_error.SetErrorString("invalid target " + "(SBDebugger::AddCurrentPlatformSharedObjectPath) " + "returned false"); + return false; +} + bool SBDebugger::GetCloseInputOnEOF() const { return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false); } Index: include/lldb/API/SBDebugger.h === --- include/lldb/API/SBDebugger.h +++ include/lldb/API/SBDebugger.h @@ -161,6 +161,10 @@ bool SetCurrentPlatformSDKRoot(const char *sysroot); + bool AddCurrentTargetSharedObjectPath(const char *from, +const char *to, +lldb::SBError &error); + // FIXME: Once we get the set show stuff in place, the driver won't need // an interface to the Set/Get UseExternalEditor. bool SetUseExternalEditor(bool input); Index: source/API/SBDebugger.cpp === --- source/API/SBDebugger.cpp +++ source/API/SBDebugger.cpp @@ -1123,6 +1123,38 @@ return false; } +bool SBDebugger::AddCurrentTargetSharedObjectPath(const char *from, + const char *to, + lldb::SBError &sb_error) { + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + auto target_sp = GetSelectedTarget().GetSP(); + + if (target_sp->IsValid()) { +if (from[0] && to[0]) { + if (log) +log->Printf("SBDebugger::AddCurrentPlatformSharedObjectPath: '%s' -> '%s'", +from, to); + target_sp->GetImageSearchPathList().Append( + ConstString(from), ConstString(to), true); + return true; +} else { + if (from[0]) +sb_error.SetErrorString(" can't be empty> " +"(SBDebugger::AddCurrentPlatformSharedObjectPath) " +"returned false"); + else +sb_error.SetErrorString(" can't be empty> " +"(SBDebugger::AddCurrentPlatformSharedObjectPath) " +"returned false"); + return false; +} + } + sb_error.SetErrorString("invalid target " + "(SBDebugger::AddCurrentPlatformSharedObjectPath) " + "returned false"); + return false; +} + bool SBDebugger::GetCloseInputOnEOF() const { return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false); } Index: include/lldb/API/SBDebugger.h === --- include/lldb/API/SBDebugger.h +++ include/lldb/API/SBDebugger.h @@ -161,6 +161,10 @@ bool SetCurrentPlatformSDKRoot(const char *sysroot); + bool AddCurrentTargetSharedObjectPath(const char *from, +const char *to, +lldb::SBError &error); + // FIXME: Once we get the set show stuff in place, the driver won't need // an interface to the Set/Get UseExternalEditor. bool SetUseExternalEditor(bool input); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47302: [lldb, lldb-mi] Add method AddCurrentTargetSharedObjectPath to the SBDebugger.
polyakov.alex added a comment. In https://reviews.llvm.org/D47302#1110441, @aprantl wrote: > The missing context here is that the lldb-mi -target-select command currently > calls `HandleCommand("target modules search-paths add", ...)`. > Is adding a new SBAPI the right approach to implementing this functionality > without going through HandleCommand? Or is HandleCommand appropriate in this > case? This approach is not mandatory, we could do almost the same(except errors processing) right in TargetSelect::Execute method. As you can see, the main thing here is: target_sp->GetImageSearchPathList().Append( ConstString(from), ConstString(to), true); Repository: rL LLVM https://reviews.llvm.org/D47302 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex added inline comments. Comment at: lit/lit.cfg:61 +lldb_mi = lit.util.which('lldb-mi', lldb_tools_dir) + aprantl wrote: > aprantl wrote: > > It looks like "lldb-mi" may not be a valid substitution. On Darwin the > > command > > > > `# RUN: %lldb_mi ` > > > > is expanded to > > > > bin/lldb -S .../llvm/tools/lldb/lit/lit-lldb-init_mi < ... > > > > So it behaves like `%lldb`+`_mi.` > > > Can you see if you can figure out what's going on? Perhaps we need to rename > it to lldbmi without the underscore? On linux it's ok. I'll remove underscore and be appreciated if you check it on Darwin. Repository: rL LLVM https://reviews.llvm.org/D46588 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D46588: [LLDB][lldb-mi] Add possibility to set breakpoints without selecting a target.
polyakov.alex updated this revision to Diff 148323. polyakov.alex added a comment. Removed underscore in the lldb-mi variable from lit.cfg. Repository: rL LLVM https://reviews.llvm.org/D46588 Files: lit/lit.cfg lit/tools/lldb-mi/breakpoint/break-insert.test lit/tools/lldb-mi/breakpoint/inputs/break-insert.c lit/tools/lldb-mi/breakpoint/lit.local.cfg tools/lldb-mi/MICmdCmdBreak.cpp tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp Index: tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp === --- tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp +++ tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp @@ -871,7 +871,10 @@ // Throws: None. //-- lldb::SBTarget CMICmnLLDBDebugSessionInfo::GetTarget() const { - return GetDebugger().GetSelectedTarget(); + auto target = GetDebugger().GetSelectedTarget(); + if (target.IsValid()) +return target; + return GetDebugger().GetDummyTarget(); } //++ Index: tools/lldb-mi/MICmdCmdBreak.cpp === --- tools/lldb-mi/MICmdCmdBreak.cpp +++ tools/lldb-mi/MICmdCmdBreak.cpp @@ -148,6 +148,11 @@ CMICMDBASE_GETOPTION(pArgRestrictBrkPtToThreadId, OptionShort, m_constStrArgNamedRestrictBrkPtToThreadId); + // Ask LLDB for the target to check if we have valid or dummy one. + CMICmnLLDBDebugSessionInfo &rSessionInfo( + CMICmnLLDBDebugSessionInfo::Instance()); + lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); + m_bBrkPtEnabled = !pArgDisableBrkPt->GetFound(); m_bBrkPtIsTemp = pArgTempBrkPt->GetFound(); m_bHaveArgOptionThreadGrp = pArgThreadGroup->GetFound(); @@ -157,7 +162,12 @@ nThreadGrp); m_strArgOptionThreadGrp = CMIUtilString::Format("i%d", nThreadGrp); } - m_bBrkPtIsPending = pArgPendingBrkPt->GetFound(); + + if (sbTarget == rSessionInfo.GetDebugger().GetDummyTarget()) +m_bBrkPtIsPending = true; + else +m_bBrkPtIsPending = pArgPendingBrkPt->GetFound(); + if (pArgLocation->GetFound()) m_brkName = pArgLocation->GetValue(); else if (m_bBrkPtIsPending) { @@ -225,9 +235,6 @@ // Ask LLDB to create a breakpoint bool bOk = MIstatus::success; - CMICmnLLDBDebugSessionInfo &rSessionInfo( - CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); switch (eBrkPtType) { case eBreakPoint_ByAddress: m_brkPt = sbTarget.BreakpointCreateByAddress(nAddress); Index: lit/tools/lldb-mi/breakpoint/lit.local.cfg === --- /dev/null +++ lit/tools/lldb-mi/breakpoint/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] Index: lit/tools/lldb-mi/breakpoint/inputs/break-insert.c === --- /dev/null +++ lit/tools/lldb-mi/breakpoint/inputs/break-insert.c @@ -0,0 +1,7 @@ +int breakpoint() { // Breakpoint will be set here. + return 0; +} + +int main() { + return breakpoint(); +} Index: lit/tools/lldb-mi/breakpoint/break-insert.test === --- /dev/null +++ lit/tools/lldb-mi/breakpoint/break-insert.test @@ -0,0 +1,15 @@ +# RUN: %cc %p/inputs/break-insert.c -g +# RUN: %lldbmi < %s | FileCheck %s + +# Test that a breakpoint can be inserted before creating a target. + +-break-insert breakpoint +# CHECK: ^done,bkpt={number="1" + +-file-exec-and-symbols a.out +# CHECK: ^done + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + Index: lit/lit.cfg === --- lit/lit.cfg +++ lit/lit.cfg @@ -58,6 +58,8 @@ lldb = "%s -S %s/lit-lldb-init" % (lit.util.which('lldb', lldb_tools_dir), config.test_source_root) +lldbmi = lit.util.which('lldb-mi', lldb_tools_dir) + if not os.path.exists(config.cc): config.cc = lit.util.which(config.cc, config.environment['PATH']) @@ -79,6 +81,7 @@ config.substitutions.append(('%cc', config.cc)) config.substitutions.append(('%cxx', config.cxx)) +config.substitutions.append(('%lldbmi', lldbmi + " --synchronous")) config.substitutions.append(('%lldb', lldb)) if debugserver is not None: ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47302: [lldb, lldb-mi] Add method AddCurrentTargetSharedObjectPath to the SBDebugger.
polyakov.alex added a comment. In https://reviews.llvm.org/D47302#078, @clayborg wrote: > It might make sense to create a new SBTargetSettings class that has > accessors. Then we can have to accessors on SBTarget: > > class SBTarget { > static SBTargetSettings GetGlobalSettings(); > SBTargetSettings GetSettings(); > }; > What global settings should be in your opinion? I guess that they should be stored in the `SBDebugger`, and a typical use case for them would be: SBTarget target; target.HookUpGlobalSettings; > This allows us to expose settings in a way that would allow us to serialize > the settings and then load them again later. > > class SBTargetSettings { > // Accessors for "target" setting > void AppendImageSearchPath(const char *from, const char *to); > size_t GetNumImageSearchPaths(); > const char *GetImageSearchPathAtIndex(size_t i); > // Save and load all settings > void Load(SBStream &s); > void Save(SBStream &s); > }; Serialization sounds good, but, to accurately understand you, do you mean "classic" serialization with saving data into the file or serialization just for the time when debugger is run? Repository: rL LLVM https://reviews.llvm.org/D47302 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47302: [lldb, lldb-mi] Add method AddCurrentTargetSharedObjectPath to the SBDebugger.
polyakov.alex added a comment. In https://reviews.llvm.org/D47302#351, @clayborg wrote: > In https://reviews.llvm.org/D47302#249, @polyakov.alex wrote: > > > In https://reviews.llvm.org/D47302#078, @clayborg wrote: > > > > > It might make sense to create a new SBTargetSettings class that has > > > accessors. Then we can have to accessors on SBTarget: > > > > > > class SBTarget { > > > static SBTargetSettings GetGlobalSettings(); > > > SBTargetSettings GetSettings(); > > > }; > > > > > > > > > What global settings should be in your opinion? I guess that they should be > > stored in the `SBDebugger`, and a typical use case for them would be: > > > > SBTarget target; > > target.HookUpGlobalSettings; > > > > > I would code it exactly as I specified above. Ask the SBTarget for its > settings. We would only expose the "target.*" settings through the > SBTargetSettings class. SBDebugger could have its own settings for everything > that is stored in the Debugger.cpp g_properties variable, those would be in > SBDebuggerSettings if we need access to those: > > class SBDebugger { > static SBDebuggerSettings GetGlobalSettings(); > SBDebuggerSettings GetSettings(); > }; > > > > > >> This allows us to expose settings in a way that would allow us to > >> serialize the settings and then load them again later. > >> > >> class SBTargetSettings { > >> // Accessors for "target" setting > >> void AppendImageSearchPath(const char *from, const char *to); > >> size_t GetNumImageSearchPaths(); > >> const char *GetImageSearchPathAtIndex(size_t i); > >> // Save and load all settings > >> void Load(SBStream &s); > >> void Save(SBStream &s); > >> }; > > > > Serialization sounds good, but, to accurately understand you, do you mean > > "classic" serialization with saving data into the file or serialization > > just for the time when debugger is run? > > SBStream can be a string buffer or a file. We should probably save to JSON > and load from JSON. But that doesn't need to be done in this patch. So, for now we'll just save settings to a string buffer? Repository: rL LLVM https://reviews.llvm.org/D47302 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47302: [lldb, lldb-mi] Add method AddCurrentTargetSharedObjectPath to the SBDebugger.
polyakov.alex added a comment. In https://reviews.llvm.org/D47302#377, @clayborg wrote: > In https://reviews.llvm.org/D47302#372, @polyakov.alex wrote: > > > In https://reviews.llvm.org/D47302#351, @clayborg wrote: > > > > > In https://reviews.llvm.org/D47302#249, @polyakov.alex wrote: > > > > > > > In https://reviews.llvm.org/D47302#078, @clayborg wrote: > > > > > > > > > It might make sense to create a new SBTargetSettings class that has > > > > > accessors. Then we can have to accessors on SBTarget: > > > > > > > > > > class SBTarget { > > > > > static SBTargetSettings GetGlobalSettings(); > > > > > SBTargetSettings GetSettings(); > > > > > }; > > > > > > > > > > > > > > > > > What global settings should be in your opinion? I guess that they > > > > should be stored in the `SBDebugger`, and a typical use case for them > > > > would be: > > > > > > > > SBTarget target; > > > > target.HookUpGlobalSettings; > > > > > > > > > > > > > I would code it exactly as I specified above. Ask the SBTarget for its > > > settings. We would only expose the "target.*" settings through the > > > SBTargetSettings class. SBDebugger could have its own settings for > > > everything that is stored in the Debugger.cpp g_properties variable, > > > those would be in SBDebuggerSettings if we need access to those: > > > > > > class SBDebugger { > > > static SBDebuggerSettings GetGlobalSettings(); > > > SBDebuggerSettings GetSettings(); > > > }; > > > > > > > > > > > > > > > >> This allows us to expose settings in a way that would allow us to > > > >> serialize the settings and then load them again later. > > > >> > > > >> class SBTargetSettings { > > > >> // Accessors for "target" setting > > > >> void AppendImageSearchPath(const char *from, const char *to); > > > >> size_t GetNumImageSearchPaths(); > > > >> const char *GetImageSearchPathAtIndex(size_t i); > > > >> // Save and load all settings > > > >> void Load(SBStream &s); > > > >> void Save(SBStream &s); > > > >> }; > > > > > > > > Serialization sounds good, but, to accurately understand you, do you > > > > mean "classic" serialization with saving data into the file or > > > > serialization just for the time when debugger is run? > > > > > > SBStream can be a string buffer or a file. We should probably save to > > > JSON and load from JSON. But that doesn't need to be done in this patch. > > > > > > So, for now we'll just save settings to a string buffer? > > > Don't worry about saving/loading in this patch. That was just a proposed > future direction we can easily do once we have the SBTargetOptions class > split out into its own class. So concentrate on making a SBTargetOptions and > optionally the SBDebuggerOptions class if you need access to debugger > settings as well. If I understood you right, the approach is to have a separated class `SBTargetSettings` with own data structures consisting of the settings. Also each instance of `SBTarget` will have a field `SBTargetSettings sb_settings;`. If so, we still need a `SBTarget::AddSharedObjectPath`. Repository: rL LLVM https://reviews.llvm.org/D47302 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47302: [lldb, lldb-mi] Add method AddCurrentTargetSharedObjectPath to the SBDebugger.
polyakov.alex added a comment. In https://reviews.llvm.org/D47302#497, @clayborg wrote: > no. Create a new SBTargetSettings class. SBTarget will hand one out for > global and for target instance settings, Add all settings accessors to > SBTargetSettings class What is a difference between `SBTargetSettings` and `TargetProperties` classes except API level? Repository: rL LLVM https://reviews.llvm.org/D47302 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47302: [lldb, lldb-mi] Add method AddCurrentTargetSharedObjectPath to the SBDebugger.
polyakov.alex added a comment. In https://reviews.llvm.org/D47302#637, @clayborg wrote: > In https://reviews.llvm.org/D47302#569, @polyakov.alex wrote: > > > In https://reviews.llvm.org/D47302#497, @clayborg wrote: > > > > > no. Create a new SBTargetSettings class. SBTarget will hand one out for > > > global and for target instance settings, Add all settings accessors to > > > SBTargetSettings class > > > > > > What is a difference between `SBTargetSettings` and `TargetProperties` > > classes except API level? > > > Not much difference except everything in SBTargetSettings will need to be > public C++ API safe (no virtual functions, one member variable in the class > that is a pointer std::unique_ptr or std::shared_ptr, no inheritance, no STL > in args or return values, no lldb_private classes in args or return values. > For this class to be API safe, we will actually need to keep a shared pointer > to the target properties. So the class in the API header will be something > like: > > namespace lldb { > SBTargetSettings { > lldb::TargetPropertiesSP m_opaque_sp; > }; > } > > > Then m_opaque_sp will be filled in by assigning from a TargetSP (since a > shared pointer to a target can be converted to a TargetPropertiesSP since > Target inherits from TargetProperties) or from a call to > Target::GetGlobalProperties(). And then we pass through all accessors we need. If so, to do: sb_target.settings.AppendImageSearchPath(...) we need to cast our pointer to `TargetProperties` to a pointer to `Target` since there is no such property(manipulating with image search paths) in `TargetProperties` and then use Target's methods. Repository: rL LLVM https://reviews.llvm.org/D47302 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47415: [lldb, lldb-mi] Re-implement MI -exec-continue command.
polyakov.alex created this revision. polyakov.alex added reviewers: aprantl, clayborg. Herald added subscribers: llvm-commits, ki.stfu. Now -exec-continue command uses SB API t resume target's process. Repository: rL LLVM https://reviews.llvm.org/D47415 Files: lit/tools/lldb-mi/exec/exec-continue.test lit/tools/lldb-mi/exec/inputs/main.c lit/tools/lldb-mi/exec/lit.local.cfg tools/lldb-mi/MICmdCmdExec.cpp Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -219,33 +219,20 @@ // Throws: None. //-- bool CMICmdCmdExecContinue::Execute() { - const char *pCmd = "continue"; - CMICmnLLDBDebugSessionInfo &rSessionInfo( - CMICmnLLDBDebugSessionInfo::Instance()); - const lldb::ReturnStatus rtn = - rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand( - pCmd, m_lldbResult); - MIunused(rtn); + lldb::SBError sb_error = + CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue(); - if (m_lldbResult.GetErrorSize() == 0) { + if (sb_error.Success()) { // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) { const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription()); SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), m_cmdData.strMiCmd.c_str(), rErrMsg.c_str())); return MIstatus::failure; } - } else { -// ToDo: Re-evaluate if this is required when application near finished as -// this is parsing LLDB error message -// which seems a hack and is code brittle -const char *pLldbErr = m_lldbResult.GetError(); -const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine()); -if (strLldbMsg == "error: Process must be launched.") { - CMIDriver::Instance().SetExitApplicationFlag(true); -} - } + } else +m_lldbResult.SetError(sb_error.GetCString()); return MIstatus::success; } Index: lit/tools/lldb-mi/exec/lit.local.cfg === --- /dev/null +++ lit/tools/lldb-mi/exec/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] Index: lit/tools/lldb-mi/exec/inputs/main.c === --- /dev/null +++ lit/tools/lldb-mi/exec/inputs/main.c @@ -0,0 +1,4 @@ +int main(void) { + int x = 0; + return x; +} Index: lit/tools/lldb-mi/exec/exec-continue.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-continue.test @@ -0,0 +1,17 @@ +# RUN: %cc %p/inputs/main.c -g +# RUN: %lldbmi < %s | FileCheck %s + +# Test that lldb-mi can continue executing a program after stop. + +-file-exec-and-symbols a.out +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-continue +# CHECK: ^running Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -219,33 +219,20 @@ // Throws: None. //-- bool CMICmdCmdExecContinue::Execute() { - const char *pCmd = "continue"; - CMICmnLLDBDebugSessionInfo &rSessionInfo( - CMICmnLLDBDebugSessionInfo::Instance()); - const lldb::ReturnStatus rtn = - rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand( - pCmd, m_lldbResult); - MIunused(rtn); + lldb::SBError sb_error = + CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue(); - if (m_lldbResult.GetErrorSize() == 0) { + if (sb_error.Success()) { // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) { const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription()); SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), m_cmdData.strMiCmd.c_str(), rErrMsg.c_str())); return MIstatus::failure; } - } else { -// ToDo: Re-evaluate if this is required when application near finished as -// this is parsing LLDB error message -// which seems a hack and is code brittle -const char *pLldbErr = m_lldbResult.GetError(); -const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine()); -if (strLldbMsg == "error: Process must be launched.") { - CMIDriver::Instance().SetExitApplicationFlag(true); -} - } + } else +m_lldbResult.SetError(sb_error.GetCString()); return MIstatus::success; } Index: lit/tools/lldb-mi/exec/lit.local.cfg === --- /dev/nu
[Lldb-commits] [PATCH] D47678: [lldb, lldm-mi] Fix hanging of -exec-run command.
polyakov.alex created this revision. polyakov.alex added reviewers: aprantl, stella.stamenova. Herald added subscribers: llvm-commits, ki.stfu. -exec-run command hanged in case of invalid or dummy target. Repository: rL LLVM https://reviews.llvm.org/D47678 Files: tools/lldb-mi/MICmdCmdExec.cpp Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -99,6 +99,19 @@ bool CMICmdCmdExecRun::Execute() { CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); + + { +// Check we have a valid target. +// Note: target created via 'file-exec-and-symbols' command. +lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); +if (sbTarget == rSessionInfo.GetDebugger().GetDummyTarget() || +!sbTarget.IsValid()) { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT), + m_cmdData.strMiCmd.c_str())); + return MIstatus::failure; +} + } + lldb::SBError error; lldb::SBStream errMsg; lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo(); Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -99,6 +99,19 @@ bool CMICmdCmdExecRun::Execute() { CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); + + { +// Check we have a valid target. +// Note: target created via 'file-exec-and-symbols' command. +lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); +if (sbTarget == rSessionInfo.GetDebugger().GetDummyTarget() || +!sbTarget.IsValid()) { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT), + m_cmdData.strMiCmd.c_str())); + return MIstatus::failure; +} + } + lldb::SBError error; lldb::SBStream errMsg; lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47678: [lldb, lldm-mi] Fix hanging of -exec-run command.
polyakov.alex added a comment. These changes fix the hanging of the lldb-mi lit tests. For example: `-file-exec-and-symbols a.out` command in test may cause a hanging if `a.out` is invalid name of binary. Repository: rL LLVM https://reviews.llvm.org/D47678 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47678: [lldb, lldm-mi] Fix hanging of -exec-run command.
polyakov.alex updated this revision to Diff 149619. polyakov.alex added a comment. A bit of refactoring. Repository: rL LLVM https://reviews.llvm.org/D47678 Files: tools/lldb-mi/MICmdCmdExec.cpp Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -99,6 +99,19 @@ bool CMICmdCmdExecRun::Execute() { CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); + + { +// Check we have a valid target. +// Note: target created via 'file-exec-and-symbols' command. +lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); +if (!sbTarget.IsValid() || +sbTarget == rSessionInfo.GetDebugger().GetDummyTarget()) { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT), + m_cmdData.strMiCmd.c_str())); + return MIstatus::failure; +} + } + lldb::SBError error; lldb::SBStream errMsg; lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo(); Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -99,6 +99,19 @@ bool CMICmdCmdExecRun::Execute() { CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); + + { +// Check we have a valid target. +// Note: target created via 'file-exec-and-symbols' command. +lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); +if (!sbTarget.IsValid() || +sbTarget == rSessionInfo.GetDebugger().GetDummyTarget()) { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT), + m_cmdData.strMiCmd.c_str())); + return MIstatus::failure; +} + } + lldb::SBError error; lldb::SBStream errMsg; lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47679: [lldb, lldb-mi] Enable lldb-mi -break-insert test on Windows.
polyakov.alex created this revision. polyakov.alex added reviewers: aprantl, stella.stamenova. Herald added subscribers: llvm-commits, ki.stfu. The default name for a compiler output on Linux is `a.out`, while on Windows it's `a.exe`. But if we add option `-o a.exe`, the compiler will create the executable `a.exe` on the both systems. Repository: rL LLVM https://reviews.llvm.org/D47679 Files: lit/tools/lldb-mi/breakpoint/break-insert.test Index: lit/tools/lldb-mi/breakpoint/break-insert.test === --- lit/tools/lldb-mi/breakpoint/break-insert.test +++ lit/tools/lldb-mi/breakpoint/break-insert.test @@ -1,16 +1,12 @@ -# REQUIRES: nowindows -# -> llvm.org/pr24452 -# Rather than XFAILing the test, skip it on Windows because it hangs - -# RUN: %cc %p/inputs/break-insert.c -g +# RUN: %cc -o a.exe %p/inputs/break-insert.c -g # RUN: %lldbmi < %s | FileCheck %s # Test that a breakpoint can be inserted before creating a target. -break-insert breakpoint # CHECK: ^done,bkpt={number="1" --file-exec-and-symbols a.out +-file-exec-and-symbols a.exe # CHECK: ^done -exec-run Index: lit/tools/lldb-mi/breakpoint/break-insert.test === --- lit/tools/lldb-mi/breakpoint/break-insert.test +++ lit/tools/lldb-mi/breakpoint/break-insert.test @@ -1,16 +1,12 @@ -# REQUIRES: nowindows -# -> llvm.org/pr24452 -# Rather than XFAILing the test, skip it on Windows because it hangs - -# RUN: %cc %p/inputs/break-insert.c -g +# RUN: %cc -o a.exe %p/inputs/break-insert.c -g # RUN: %lldbmi < %s | FileCheck %s # Test that a breakpoint can be inserted before creating a target. -break-insert breakpoint # CHECK: ^done,bkpt={number="1" --file-exec-and-symbols a.out +-file-exec-and-symbols a.exe # CHECK: ^done -exec-run ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47679: [lldb, lldb-mi] Enable lldb-mi -break-insert test on Windows.
polyakov.alex added a comment. I would really appreciate if you guys can check this test on Windows again. Repository: rL LLVM https://reviews.llvm.org/D47679 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47679: [lldb, lldb-mi] Enable lldb-mi -break-insert test on Windows.
polyakov.alex added a comment. You are right. I think that the reason of exiting *normally is much deeper. I'll look at this, but for now I don't have any ideas about what it may cause, do you have one? Repository: rL LLVM https://reviews.llvm.org/D47679 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47678: [lldb, lldm-mi] Fix hanging of -exec-run command.
polyakov.alex updated this revision to Diff 149626. polyakov.alex added a comment. Added the test. https://reviews.llvm.org/D47678 Files: lit/tools/lldb-mi/exec/exec-run-wrong-binary.test lit/tools/lldb-mi/exec/lit.local.cfg tools/lldb-mi/MICmdCmdExec.cpp Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -99,6 +99,19 @@ bool CMICmdCmdExecRun::Execute() { CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); + + { +// Check we have a valid target. +// Note: target created via 'file-exec-and-symbols' command. +lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); +if (!sbTarget.IsValid() || +sbTarget == rSessionInfo.GetDebugger().GetDummyTarget()) { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT), + m_cmdData.strMiCmd.c_str())); + return MIstatus::failure; +} + } + lldb::SBError error; lldb::SBStream errMsg; lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo(); Index: lit/tools/lldb-mi/exec/lit.local.cfg === --- /dev/null +++ lit/tools/lldb-mi/exec/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] Index: lit/tools/lldb-mi/exec/exec-run-wrong-binary.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-run-wrong-binary.test @@ -0,0 +1,6 @@ +# RUN: %lldbmi < %s | FileCheck %s + +# Test that -exec-run command won't hang in case of wrong name of binary file. + +-file-exec-and-symbols name.exe +# CHECK: ^error,msg="Command 'file-exec-and-symbols'. Target binary 'name.exe' is invalid. Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -99,6 +99,19 @@ bool CMICmdCmdExecRun::Execute() { CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); + + { +// Check we have a valid target. +// Note: target created via 'file-exec-and-symbols' command. +lldb::SBTarget sbTarget = rSessionInfo.GetTarget(); +if (!sbTarget.IsValid() || +sbTarget == rSessionInfo.GetDebugger().GetDummyTarget()) { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT), + m_cmdData.strMiCmd.c_str())); + return MIstatus::failure; +} + } + lldb::SBError error; lldb::SBStream errMsg; lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo(); Index: lit/tools/lldb-mi/exec/lit.local.cfg === --- /dev/null +++ lit/tools/lldb-mi/exec/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] Index: lit/tools/lldb-mi/exec/exec-run-wrong-binary.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-run-wrong-binary.test @@ -0,0 +1,6 @@ +# RUN: %lldbmi < %s | FileCheck %s + +# Test that -exec-run command won't hang in case of wrong name of binary file. + +-file-exec-and-symbols name.exe +# CHECK: ^error,msg="Command 'file-exec-and-symbols'. Target binary 'name.exe' is invalid. ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47679: [lldb, lldb-mi] Enable lldb-mi -break-insert test on Windows.
polyakov.alex updated this revision to Diff 149629. polyakov.alex added a comment. Due to https://reviews.llvm.org/D47678 we can enable this test with a XFAIL directive for Windows. https://reviews.llvm.org/D47679 Files: lit/tools/lldb-mi/breakpoint/break-insert.test Index: lit/tools/lldb-mi/breakpoint/break-insert.test === --- lit/tools/lldb-mi/breakpoint/break-insert.test +++ lit/tools/lldb-mi/breakpoint/break-insert.test @@ -1,16 +1,15 @@ -# REQUIRES: nowindows +# XFAIL: windows # -> llvm.org/pr24452 -# Rather than XFAILing the test, skip it on Windows because it hangs - -# RUN: %cc %p/inputs/break-insert.c -g +# +# RUN: %cc -o a.exe %p/inputs/break-insert.c -g # RUN: %lldbmi < %s | FileCheck %s # Test that a breakpoint can be inserted before creating a target. -break-insert breakpoint # CHECK: ^done,bkpt={number="1" --file-exec-and-symbols a.out +-file-exec-and-symbols a.exe # CHECK: ^done -exec-run Index: lit/tools/lldb-mi/breakpoint/break-insert.test === --- lit/tools/lldb-mi/breakpoint/break-insert.test +++ lit/tools/lldb-mi/breakpoint/break-insert.test @@ -1,16 +1,15 @@ -# REQUIRES: nowindows +# XFAIL: windows # -> llvm.org/pr24452 -# Rather than XFAILing the test, skip it on Windows because it hangs - -# RUN: %cc %p/inputs/break-insert.c -g +# +# RUN: %cc -o a.exe %p/inputs/break-insert.c -g # RUN: %lldbmi < %s | FileCheck %s # Test that a breakpoint can be inserted before creating a target. -break-insert breakpoint # CHECK: ^done,bkpt={number="1" --file-exec-and-symbols a.out +-file-exec-and-symbols a.exe # CHECK: ^done -exec-run ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47679: [lldb, lldb-mi] Enable lldb-mi -break-insert test on Windows.
polyakov.alex added a comment. In https://reviews.llvm.org/D47679#1120039, @stella.stamenova wrote: > You can actually follow the pattern in the other tests and do: > > %cc -o %t %p/inputs/break-insert.c -g > > %t then becomes the name of the output file and you can use that in our other > commands. This is better than specifying a hardcoded name. We can't use it here since lldb-mi reads `%s` file with input, then `%t` won't be changed to any path, so debugger will try to find executable with name `%t` and fail. https://reviews.llvm.org/D47679 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47679: [lldb, lldb-mi] Enable lldb-mi -break-insert test on Windows.
polyakov.alex added a comment. In https://reviews.llvm.org/D47679#1120172, @stella.stamenova wrote: > In https://reviews.llvm.org/D47679#1120081, @polyakov.alex wrote: > > > Due to https://reviews.llvm.org/D47678 we can enable this test with a XFAIL > > directive for Windows. > > > Not true. As I said, the original review when I disabled the test has the log > of what happens when you give it the correct path and the test still hangs in > that scenario. If you XFAIL it, it will hang. Yep, I got the same on Linux. But if you run it through llvm-lit(not `lldb-mi < input-file`) it won't hang. https://reviews.llvm.org/D47679 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47679: [lldb, lldb-mi] Enable lldb-mi -break-insert test on Windows.
polyakov.alex added a comment. Thank you. https://reviews.llvm.org/D47679 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47302: [lldb, lldb-mi] Add method AddCurrentTargetSharedObjectPath to the SBDebugger.
polyakov.alex added a comment. Do you know another way of implementing AppendImageSearchPaths method? Repository: rL LLVM https://reviews.llvm.org/D47302 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47797: [lldb-mi] Re-implement MI -exec-next command.
polyakov.alex created this revision. polyakov.alex added reviewers: aprantl, clayborg. Herald added a subscriber: ki.stfu. Now -exec-next command uses SB API for stepping over. https://reviews.llvm.org/D47797 Files: lit/tools/lldb-mi/exec/exec-next.test lit/tools/lldb-mi/exec/inputs/main.c tools/lldb-mi/MICmdCmdExec.cpp Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -22,6 +22,7 @@ #include "lldb/API/SBCommandInterpreter.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" +#include "lldb/API/SBThread.h" #include "lldb/lldb-enumerations.h" // In-house headers: @@ -378,12 +379,11 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger(); - CMIUtilString strCmd("thread step-over"); + if (nThreadId != UINT64_MAX) -strCmd += CMIUtilString::Format(" %llu", nThreadId); - rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, - false); +rSessionInfo.GetProcess().GetThreadByID(nThreadId).StepOver(); + else +rSessionInfo.GetProcess().GetSelectedThread().StepOver(); return MIstatus::success; } Index: lit/tools/lldb-mi/exec/inputs/main.c === --- /dev/null +++ lit/tools/lldb-mi/exec/inputs/main.c @@ -0,0 +1,4 @@ +int main(void) { + int x = 0; + return x; +} Index: lit/tools/lldb-mi/exec/exec-next.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-next.test @@ -0,0 +1,21 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-next command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-next +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -22,6 +22,7 @@ #include "lldb/API/SBCommandInterpreter.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" +#include "lldb/API/SBThread.h" #include "lldb/lldb-enumerations.h" // In-house headers: @@ -378,12 +379,11 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger(); - CMIUtilString strCmd("thread step-over"); + if (nThreadId != UINT64_MAX) -strCmd += CMIUtilString::Format(" %llu", nThreadId); - rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, - false); +rSessionInfo.GetProcess().GetThreadByID(nThreadId).StepOver(); + else +rSessionInfo.GetProcess().GetSelectedThread().StepOver(); return MIstatus::success; } Index: lit/tools/lldb-mi/exec/inputs/main.c === --- /dev/null +++ lit/tools/lldb-mi/exec/inputs/main.c @@ -0,0 +1,4 @@ +int main(void) { + int x = 0; + return x; +} Index: lit/tools/lldb-mi/exec/exec-next.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-next.test @@ -0,0 +1,21 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-next command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-next +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47797: [lldb-mi] Re-implement MI -exec-next command.
polyakov.alex updated this revision to Diff 150137. polyakov.alex added a reviewer: labath. polyakov.alex added a comment. Added some checks for invalid thread id. https://reviews.llvm.org/D47797 Files: lit/tools/lldb-mi/exec/exec-next.test lit/tools/lldb-mi/exec/inputs/main.c tools/lldb-mi/MICmdCmdExec.cpp Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -22,6 +22,7 @@ #include "lldb/API/SBCommandInterpreter.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" +#include "lldb/API/SBThread.h" #include "lldb/lldb-enumerations.h" // In-house headers: @@ -378,12 +379,18 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger(); - CMIUtilString strCmd("thread step-over"); - if (nThreadId != UINT64_MAX) -strCmd += CMIUtilString::Format(" %llu", nThreadId); - rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, - false); + + if (nThreadId != UINT64_MAX) { +lldb::SBThread sbThread = rSessionInfo.GetProcess().GetThreadByID(nThreadId); +if (sbThread.IsValid()) + sbThread.StepOver(); +else { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), + m_cmdData.strMiCmd.c_str(), + m_constStrArgThread.c_str())); + return MIstatus::failure; +} + } else rSessionInfo.GetProcess().GetSelectedThread().StepOver(); return MIstatus::success; } Index: lit/tools/lldb-mi/exec/inputs/main.c === --- /dev/null +++ lit/tools/lldb-mi/exec/inputs/main.c @@ -0,0 +1,4 @@ +int main(void) { + int x = 0; + return x; +} Index: lit/tools/lldb-mi/exec/exec-next.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-next.test @@ -0,0 +1,26 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-next command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-next --thread 0 +# Check that exec-next can process the case of invalid thread ID. +# CHECK: ^error,msg="Command 'exec-next'. Thread ID invalid" + +-exec-next +# Check that exec-next can step over in a selected thread. +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -22,6 +22,7 @@ #include "lldb/API/SBCommandInterpreter.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" +#include "lldb/API/SBThread.h" #include "lldb/lldb-enumerations.h" // In-house headers: @@ -378,12 +379,18 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger(); - CMIUtilString strCmd("thread step-over"); - if (nThreadId != UINT64_MAX) -strCmd += CMIUtilString::Format(" %llu", nThreadId); - rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, - false); + + if (nThreadId != UINT64_MAX) { +lldb::SBThread sbThread = rSessionInfo.GetProcess().GetThreadByID(nThreadId); +if (sbThread.IsValid()) + sbThread.StepOver(); +else { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), + m_cmdData.strMiCmd.c_str(), + m_constStrArgThread.c_str())); + return MIstatus::failure; +} + } else rSessionInfo.GetProcess().GetSelectedThread().StepOver(); return MIstatus::success; } Index: lit/tools/lldb-mi/exec/inputs/main.c === --- /dev/null +++ lit/tools/lldb-mi/exec/inputs/main.c @@ -0,0 +1,4 @@ +int main(void) { + int x = 0; + return x; +} Index: lit/tools/lldb-mi/exec/exec-next.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-next.test @@ -0,0 +1,26 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-next command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-next --thread 0 +# Che
[Lldb-commits] [PATCH] D47797: [lldb-mi] Re-implement MI -exec-next command.
polyakov.alex added inline comments. Comment at: tools/lldb-mi/MICmdCmdExec.cpp:384 + if (nThreadId != UINT64_MAX) { +lldb::SBThread sbThread = rSessionInfo.GetProcess().GetThreadByID(nThreadId); +if (sbThread.IsValid()) We can't test this branch until we have a way to get thread ID and then store it in some variable. https://reviews.llvm.org/D47797 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47838: [lldb-mi] Re-implement MI -exec-step command.
polyakov.alex created this revision. polyakov.alex added reviewers: aprantl, clayborg, labath, stella.stamenova. Herald added a subscriber: ki.stfu. Now -exec-step uses SB API instead of HandleCommand hack. https://reviews.llvm.org/D47838 Files: lit/tools/lldb-mi/exec/exec-step.test tools/lldb-mi/MICmdCmdExec.cpp Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -510,14 +510,28 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger(); - CMIUtilString strCmd("thread step-in"); - if (nThreadId != UINT64_MAX) -strCmd += CMIUtilString::Format(" %llu", nThreadId); - rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, - false); - return MIstatus::success; + lldb::SBError error; + if (nThreadId != UINT64_MAX) { +lldb::SBThread sbThread = rSessionInfo.GetProcess().GetThreadByID(nThreadId); +if (sbThread.IsValid()) + sbThread.StepInto(nullptr, LLDB_INVALID_LINE_NUMBER, error); +else { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), + m_cmdData.strMiCmd.c_str(), + m_constStrArgThread.c_str())); + return MIstatus::failure; +} + } else rSessionInfo.GetProcess().GetSelectedThread().StepInto( + nullptr, LLDB_INVALID_LINE_NUMBER, error); + + if (error.Success()) +return MIstatus::success; + + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_FNFAILED), + m_cmdData.strMiCmd.c_str(), + error.GetCString())); + return MIstatus::failure; } //++ Index: lit/tools/lldb-mi/exec/exec-step.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-step.test @@ -0,0 +1,26 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-step command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-step --thread 0 +# Check that exec-step can process the case of invalid thread ID. +# CHECK: ^error,msg="Command 'exec-step'. Thread ID invalid" + +-exec-step +# Check that exec-step can step-in in a selected thread. +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -510,14 +510,28 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger(); - CMIUtilString strCmd("thread step-in"); - if (nThreadId != UINT64_MAX) -strCmd += CMIUtilString::Format(" %llu", nThreadId); - rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, - false); - return MIstatus::success; + lldb::SBError error; + if (nThreadId != UINT64_MAX) { +lldb::SBThread sbThread = rSessionInfo.GetProcess().GetThreadByID(nThreadId); +if (sbThread.IsValid()) + sbThread.StepInto(nullptr, LLDB_INVALID_LINE_NUMBER, error); +else { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), + m_cmdData.strMiCmd.c_str(), + m_constStrArgThread.c_str())); + return MIstatus::failure; +} + } else rSessionInfo.GetProcess().GetSelectedThread().StepInto( + nullptr, LLDB_INVALID_LINE_NUMBER, error); + + if (error.Success()) +return MIstatus::success; + + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_FNFAILED), + m_cmdData.strMiCmd.c_str(), + error.GetCString())); + return MIstatus::failure; } //++ Index: lit/tools/lldb-mi/exec/exec-step.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-step.test @@ -0,0 +1,26 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-step command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-step --thread 0 +# Check that exec-step can process the case of invalid thread ID. +# CHECK: ^error,msg="Command 'exec-step'. Thread ID
[Lldb-commits] [PATCH] D47838: [lldb-mi] Re-implement MI -exec-step command.
polyakov.alex added a comment. I'm a little bit confused about situation with thread id before my changes. For example: (gdb) thread list ~"Process 31642 stopped\n* thread #1: tid = 31642, 0x0041eed0 bash`main, name = 'bash', stop reason = breakpoint 1.1\n" ^done What we should use as a thread ID? Thread number or tid? The main problem that before my changes exec-like commands used thread number, but SBThread uses tid, as I know. https://reviews.llvm.org/D47838 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47838: [lldb-mi] Re-implement MI -exec-step command.
polyakov.alex added a comment. In https://reviews.llvm.org/D47838#1124730, @labath wrote: > I don't know if there is any spec about what the gdb-mi protocol should use > for thread identification, but I think the most important part is to be > consistent. If you use indexes in one place and tid's in another you'll > confuse the hell out of clients trying to talk to lldb-mi. Due to https://sourceware.org/gdb/onlinedocs/gdb/Threads.html, gdb has its own thread numbers for each thread of an inferior. So we should do the same, I guess. https://reviews.llvm.org/D47838 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47797: [lldb-mi] Re-implement MI -exec-next command.
polyakov.alex updated this revision to Diff 150328. polyakov.alex added a comment. Changes for using thread ids in a gdb way. Also added case of specified thread into test case. https://reviews.llvm.org/D47797 Files: lit/tools/lldb-mi/exec/exec-next.test lit/tools/lldb-mi/exec/inputs/main.c tools/lldb-mi/MICmdCmdExec.cpp Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -22,6 +22,7 @@ #include "lldb/API/SBCommandInterpreter.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" +#include "lldb/API/SBThread.h" #include "lldb/lldb-enumerations.h" // In-house headers: @@ -378,12 +379,17 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger(); - CMIUtilString strCmd("thread step-over"); - if (nThreadId != UINT64_MAX) -strCmd += CMIUtilString::Format(" %llu", nThreadId); - rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, - false); + + if (nThreadId != UINT64_MAX) { +lldb::SBThread sbThread = rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId); +if (!sbThread.IsValid()) { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), + m_cmdData.strMiCmd.c_str(), + m_constStrArgThread.c_str())); + return MIstatus::failure; +} +sbThread.StepOver(); + } else rSessionInfo.GetProcess().GetSelectedThread().StepOver(); return MIstatus::success; } Index: lit/tools/lldb-mi/exec/inputs/main.c === --- /dev/null +++ lit/tools/lldb-mi/exec/inputs/main.c @@ -0,0 +1,4 @@ +int main(void) { + int x = 0; + return x; +} Index: lit/tools/lldb-mi/exec/exec-next.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-next.test @@ -0,0 +1,30 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-next command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-next --thread 0 +# Check that exec-next can process the case of invalid thread ID. +# CHECK: ^error,msg="Command 'exec-next'. Thread ID invalid" + +-exec-next --thread 1 +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" + +-exec-next +# Check that exec-next can step over in a selected thread. +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -22,6 +22,7 @@ #include "lldb/API/SBCommandInterpreter.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" +#include "lldb/API/SBThread.h" #include "lldb/lldb-enumerations.h" // In-house headers: @@ -378,12 +379,17 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger(); - CMIUtilString strCmd("thread step-over"); - if (nThreadId != UINT64_MAX) -strCmd += CMIUtilString::Format(" %llu", nThreadId); - rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, - false); + + if (nThreadId != UINT64_MAX) { +lldb::SBThread sbThread = rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId); +if (!sbThread.IsValid()) { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), + m_cmdData.strMiCmd.c_str(), + m_constStrArgThread.c_str())); + return MIstatus::failure; +} +sbThread.StepOver(); + } else rSessionInfo.GetProcess().GetSelectedThread().StepOver(); return MIstatus::success; } Index: lit/tools/lldb-mi/exec/inputs/main.c === --- /dev/null +++ lit/tools/lldb-mi/exec/inputs/main.c @@ -0,0 +1,4 @@ +int main(void) { + int x = 0; + return x; +} Index: lit/tools/lldb-mi/exec/exec-next.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-next.test @@ -0,0 +1,30 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-next command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run
[Lldb-commits] [PATCH] D47838: [lldb-mi] Re-implement MI -exec-step command.
polyakov.alex updated this revision to Diff 150332. polyakov.alex added a comment. Changes for using thread ids in a gdb way. Also added case of specified thread into test case. https://reviews.llvm.org/D47838 Files: lit/tools/lldb-mi/exec/exec-step.test tools/lldb-mi/MICmdCmdExec.cpp Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -509,14 +509,28 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger(); - CMIUtilString strCmd("thread step-in"); - if (nThreadId != UINT64_MAX) -strCmd += CMIUtilString::Format(" %llu", nThreadId); - rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, - false); - return MIstatus::success; + lldb::SBError error; + if (nThreadId != UINT64_MAX) { +lldb::SBThread sbThread = +rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId); +if (!sbThread.IsValid()) { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), + m_cmdData.strMiCmd.c_str(), + m_constStrArgThread.c_str())); + return MIstatus::failure; +} +sbThread.StepInto(nullptr, LLDB_INVALID_LINE_NUMBER, error); + } else rSessionInfo.GetProcess().GetSelectedThread().StepInto( + nullptr, LLDB_INVALID_LINE_NUMBER, error); + + if (error.Success()) +return MIstatus::success; + + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_FNFAILED), + m_cmdData.strMiCmd.c_str(), + error.GetCString())); + return MIstatus::failure; } //++ Index: lit/tools/lldb-mi/exec/exec-step.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-step.test @@ -0,0 +1,30 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-step command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-step --thread 0 +# Check that exec-step can process the case of invalid thread ID. +# CHECK: ^error,msg="Command 'exec-step'. Thread ID invalid" + +-exec-step --thread 1 +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" + +-exec-step +# Check that exec-step can step-in in a selected thread. +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -509,14 +509,28 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger(); - CMIUtilString strCmd("thread step-in"); - if (nThreadId != UINT64_MAX) -strCmd += CMIUtilString::Format(" %llu", nThreadId); - rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, - false); - return MIstatus::success; + lldb::SBError error; + if (nThreadId != UINT64_MAX) { +lldb::SBThread sbThread = +rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId); +if (!sbThread.IsValid()) { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), + m_cmdData.strMiCmd.c_str(), + m_constStrArgThread.c_str())); + return MIstatus::failure; +} +sbThread.StepInto(nullptr, LLDB_INVALID_LINE_NUMBER, error); + } else rSessionInfo.GetProcess().GetSelectedThread().StepInto( + nullptr, LLDB_INVALID_LINE_NUMBER, error); + + if (error.Success()) +return MIstatus::success; + + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_FNFAILED), + m_cmdData.strMiCmd.c_str(), + error.GetCString())); + return MIstatus::failure; } //++ Index: lit/tools/lldb-mi/exec/exec-step.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-step.test @@ -0,0 +1,30 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-step command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-step --thread 0 +# Check that exec-step can process the case of inva
[Lldb-commits] [PATCH] D47797: [lldb-mi] Re-implement MI -exec-next command.
This revision was automatically updated to reflect the committed changes. Closed by commit rL334215: [lldb-mi] Re-implement MI -exec-next command. (authored by apolyakov, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D47797?vs=150328&id=150381#toc Repository: rL LLVM https://reviews.llvm.org/D47797 Files: lldb/trunk/lit/tools/lldb-mi/exec/exec-next.test lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp Index: lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp === --- lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp +++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp @@ -22,6 +22,7 @@ #include "lldb/API/SBCommandInterpreter.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" +#include "lldb/API/SBThread.h" #include "lldb/lldb-enumerations.h" // In-house headers: @@ -378,12 +379,17 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger(); - CMIUtilString strCmd("thread step-over"); - if (nThreadId != UINT64_MAX) -strCmd += CMIUtilString::Format(" %llu", nThreadId); - rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, - false); + + if (nThreadId != UINT64_MAX) { +lldb::SBThread sbThread = rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId); +if (!sbThread.IsValid()) { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), + m_cmdData.strMiCmd.c_str(), + m_constStrArgThread.c_str())); + return MIstatus::failure; +} +sbThread.StepOver(); + } else rSessionInfo.GetProcess().GetSelectedThread().StepOver(); return MIstatus::success; } Index: lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c === --- lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c +++ lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c @@ -0,0 +1,4 @@ +int main(void) { + int x = 0; + return x; +} Index: lldb/trunk/lit/tools/lldb-mi/exec/exec-next.test === --- lldb/trunk/lit/tools/lldb-mi/exec/exec-next.test +++ lldb/trunk/lit/tools/lldb-mi/exec/exec-next.test @@ -0,0 +1,30 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-next command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-next --thread 0 +# Check that exec-next can process the case of invalid thread ID. +# CHECK: ^error,msg="Command 'exec-next'. Thread ID invalid" + +-exec-next --thread 1 +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" + +-exec-next +# Check that exec-next can step over in a selected thread. +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" Index: lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp === --- lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp +++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp @@ -22,6 +22,7 @@ #include "lldb/API/SBCommandInterpreter.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" +#include "lldb/API/SBThread.h" #include "lldb/lldb-enumerations.h" // In-house headers: @@ -378,12 +379,17 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger(); - CMIUtilString strCmd("thread step-over"); - if (nThreadId != UINT64_MAX) -strCmd += CMIUtilString::Format(" %llu", nThreadId); - rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, - false); + + if (nThreadId != UINT64_MAX) { +lldb::SBThread sbThread = rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId); +if (!sbThread.IsValid()) { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), + m_cmdData.strMiCmd.c_str(), + m_constStrArgThread.c_str())); + return MIstatus::failure; +} +sbThread.StepOver(); + } else rSessionInfo.GetProcess().GetSelectedThread().StepOver(); return MIstatus::success; } Index: lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c === --- lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c +++ lldb/trunk/lit/tools/lldb-mi/exec/inputs/main.c @@ -0,0 +1,4 @@ +int main(void) { + int x = 0; + return x; +} Index: lldb/trunk/lit/tools/lldb-mi/exec/exec-next.test ==
[Lldb-commits] [PATCH] D47415: [lldb, lldb-mi] Re-implement MI -exec-continue command.
polyakov.alex updated this revision to Diff 150391. polyakov.alex added a comment. Updated because of commited -exec-next and -exec-step commands. https://reviews.llvm.org/D47415 Files: lit/tools/lldb-mi/exec/exec-continue.test tools/lldb-mi/MICmdCmdExec.cpp Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -233,33 +233,19 @@ // Throws: None. //-- bool CMICmdCmdExecContinue::Execute() { - const char *pCmd = "continue"; - CMICmnLLDBDebugSessionInfo &rSessionInfo( - CMICmnLLDBDebugSessionInfo::Instance()); - const lldb::ReturnStatus rtn = - rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand( - pCmd, m_lldbResult); - MIunused(rtn); - - if (m_lldbResult.GetErrorSize() == 0) { + lldb::SBError error = + CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue(); + + if (error.Success()) { // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) { const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription()); SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), m_cmdData.strMiCmd.c_str(), rErrMsg.c_str())); return MIstatus::failure; } - } else { -// ToDo: Re-evaluate if this is required when application near finished as -// this is parsing LLDB error message -// which seems a hack and is code brittle -const char *pLldbErr = m_lldbResult.GetError(); -const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine()); -if (strLldbMsg == "error: Process must be launched.") { - CMIDriver::Instance().SetExitApplicationFlag(true); -} - } + } else m_lldbResult.SetError(error.GetCString()); return MIstatus::success; } Index: lit/tools/lldb-mi/exec/exec-continue.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-continue.test @@ -0,0 +1,20 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-continue command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-continue +# CHECK: ^running Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -233,33 +233,19 @@ // Throws: None. //-- bool CMICmdCmdExecContinue::Execute() { - const char *pCmd = "continue"; - CMICmnLLDBDebugSessionInfo &rSessionInfo( - CMICmnLLDBDebugSessionInfo::Instance()); - const lldb::ReturnStatus rtn = - rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand( - pCmd, m_lldbResult); - MIunused(rtn); - - if (m_lldbResult.GetErrorSize() == 0) { + lldb::SBError error = + CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue(); + + if (error.Success()) { // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) { const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription()); SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), m_cmdData.strMiCmd.c_str(), rErrMsg.c_str())); return MIstatus::failure; } - } else { -// ToDo: Re-evaluate if this is required when application near finished as -// this is parsing LLDB error message -// which seems a hack and is code brittle -const char *pLldbErr = m_lldbResult.GetError(); -const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine()); -if (strLldbMsg == "error: Process must be launched.") { - CMIDriver::Instance().SetExitApplicationFlag(true); -} - } + } else m_lldbResult.SetError(error.GetCString()); return MIstatus::success; } Index: lit/tools/lldb-mi/exec/exec-continue.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-continue.test @@ -0,0 +1,20 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-continue command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-continue +# CHECK: ^running ___ lldb-commits mailing list lldb-
[Lldb-commits] [PATCH] D47415: [lldb, lldb-mi] Re-implement MI -exec-continue command.
polyakov.alex added inline comments. Comment at: tools/lldb-mi/MICmdCmdExec.cpp:248 } - } else { -// ToDo: Re-evaluate if this is required when application near finished as -// this is parsing LLDB error message -// which seems a hack and is code brittle -const char *pLldbErr = m_lldbResult.GetError(); -const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine()); -if (strLldbMsg == "error: Process must be launched.") { - CMIDriver::Instance().SetExitApplicationFlag(true); -} - } + } else m_lldbResult.SetError(error.GetCString()); clayborg wrote: > An error can claim to fail but not have an error string set. It might be nice > to have a helper function that checks to make sure there is an error string > on error cases and if there is no error string when error.Success() is false > or error.Fail() is true, then set the error string to "unknown error". This functionality might be useful in all lldb-mi commands. So do you know where to place this function? Maybe inside SBError class? https://reviews.llvm.org/D47415 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47415: [lldb, lldb-mi] Re-implement MI -exec-continue command.
polyakov.alex added inline comments. Comment at: tools/lldb-mi/MICmdCmdExec.cpp:248 } - } else { -// ToDo: Re-evaluate if this is required when application near finished as -// this is parsing LLDB error message -// which seems a hack and is code brittle -const char *pLldbErr = m_lldbResult.GetError(); -const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine()); -if (strLldbMsg == "error: Process must be launched.") { - CMIDriver::Instance().SetExitApplicationFlag(true); -} - } + } else m_lldbResult.SetError(error.GetCString()); clayborg wrote: > clayborg wrote: > > clayborg wrote: > > > polyakov.alex wrote: > > > > clayborg wrote: > > > > > An error can claim to fail but not have an error string set. It might > > > > > be nice to have a helper function that checks to make sure there is > > > > > an error string on error cases and if there is no error string when > > > > > error.Success() is false or error.Fail() is true, then set the error > > > > > string to "unknown error". > > > > This functionality might be useful in all lldb-mi commands. So do you > > > > know where to place this function? Maybe inside SBError class? > > > I would put it somewhere in lldb-mi in a static function that is > > > something like: > > > ``` > > > static void SetErrorString(lldb::SBError &error, T &lldbResult) { > > > const char *error_cstr = error.GetCString(); > > > if (error_cstr) > > > lldbResult.SetError(error.GetCString()); > > > else > > > lldbResult.SetError("unknown error"); > > > } > > > ``` > > > Where the T is the type of m_lldbResult. > > Actually, are we using m_lldbResult now? I didn't realize its type was > > lldb::SBCommandReturnObject. That was only needed if we were calling: > > ``` > > rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(pCmd, > > m_lldbResult); > > ``` > > > > So we can get rid of all "lldb::SBCommandReturnObject m_lldbResult" member > > variables in any lldb-mi functions where we switch to using the API. > Since we can get rid of m_lldbResult, this should be: > > ``` > } else return MIstatus::failure; > ``` It should be: ``` else { SetError(CMIUtilString::Format(..., error.GetCString())); return MIstatus::failure; } ``` So, we anyway need a C-style error string. https://reviews.llvm.org/D47415 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47914: [lldb-mi] Add overloaded method for setting an error.
apolyakov created this revision. apolyakov added reviewers: aprantl, clayborg. Herald added a subscriber: ki.stfu. https://reviews.llvm.org/D47914 Files: tools/lldb-mi/MICmdBase.cpp tools/lldb-mi/MICmdBase.h Index: tools/lldb-mi/MICmdBase.h === --- tools/lldb-mi/MICmdBase.h +++ tools/lldb-mi/MICmdBase.h @@ -12,6 +12,8 @@ // C Includes // C++ Includes // Other libraries and framework includes +#include "lldb/API/SBError.h" + // Project includes #include "MICmdArgSet.h" #include "MICmdData.h" @@ -80,6 +82,7 @@ // Methods: protected: void SetError(const CMIUtilString &rErrMsg); + void SetError(const lldb::SBError &error); template T *GetOption(const CMIUtilString &vStrOptionName); bool ParseValidateCmdOptions(); Index: tools/lldb-mi/MICmdBase.cpp === --- tools/lldb-mi/MICmdBase.cpp +++ tools/lldb-mi/MICmdBase.cpp @@ -214,6 +214,23 @@ //++ // +// Details: Short cut function to enter error information into the command's +// metadata object and set the command's error status. +// Type:Method. +// Args:error - (R) Command result description. +// Return: None. +// Throws: None. +//-- +void CMICmdBase::SetError(const lldb::SBError &error) { + const char *error_cstr = error.GetCString(); + if (error_cstr) +SetError(error_cstr); + else +SetError("unknown error"); +} + +//++ +// // Details: Ask a command to provide its unique identifier. // Type:Method. // Args:A unique identifier for this command class. Index: tools/lldb-mi/MICmdBase.h === --- tools/lldb-mi/MICmdBase.h +++ tools/lldb-mi/MICmdBase.h @@ -12,6 +12,8 @@ // C Includes // C++ Includes // Other libraries and framework includes +#include "lldb/API/SBError.h" + // Project includes #include "MICmdArgSet.h" #include "MICmdData.h" @@ -80,6 +82,7 @@ // Methods: protected: void SetError(const CMIUtilString &rErrMsg); + void SetError(const lldb::SBError &error); template T *GetOption(const CMIUtilString &vStrOptionName); bool ParseValidateCmdOptions(); Index: tools/lldb-mi/MICmdBase.cpp === --- tools/lldb-mi/MICmdBase.cpp +++ tools/lldb-mi/MICmdBase.cpp @@ -214,6 +214,23 @@ //++ // +// Details: Short cut function to enter error information into the command's +// metadata object and set the command's error status. +// Type:Method. +// Args:error - (R) Command result description. +// Return: None. +// Throws: None. +//-- +void CMICmdBase::SetError(const lldb::SBError &error) { + const char *error_cstr = error.GetCString(); + if (error_cstr) +SetError(error_cstr); + else +SetError("unknown error"); +} + +//++ +// // Details: Ask a command to provide its unique identifier. // Type:Method. // Args:A unique identifier for this command class. ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47914: [lldb-mi] Add overloaded method for setting an error.
This revision was automatically updated to reflect the committed changes. Closed by commit rL334245: [lldb-mi] Add overloaded method for setting an error. (authored by apolyakov, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D47914?vs=150421&id=150428#toc Repository: rL LLVM https://reviews.llvm.org/D47914 Files: lldb/trunk/tools/lldb-mi/MICmdBase.cpp lldb/trunk/tools/lldb-mi/MICmdBase.h Index: lldb/trunk/tools/lldb-mi/MICmdBase.cpp === --- lldb/trunk/tools/lldb-mi/MICmdBase.cpp +++ lldb/trunk/tools/lldb-mi/MICmdBase.cpp @@ -214,6 +214,23 @@ //++ // +// Details: Short cut function to enter error information into the command's +// metadata object and set the command's error status. +// Type:Method. +// Args:error - (R) Command result description. +// Return: None. +// Throws: None. +//-- +void CMICmdBase::SetError(const lldb::SBError &error) { + const char *error_cstr = error.GetCString(); + if (error_cstr) +SetError(error_cstr); + else +SetError("unknown error"); +} + +//++ +// // Details: Ask a command to provide its unique identifier. // Type:Method. // Args:A unique identifier for this command class. Index: lldb/trunk/tools/lldb-mi/MICmdBase.h === --- lldb/trunk/tools/lldb-mi/MICmdBase.h +++ lldb/trunk/tools/lldb-mi/MICmdBase.h @@ -12,6 +12,8 @@ // C Includes // C++ Includes // Other libraries and framework includes +#include "lldb/API/SBError.h" + // Project includes #include "MICmdArgSet.h" #include "MICmdData.h" @@ -80,6 +82,7 @@ // Methods: protected: void SetError(const CMIUtilString &rErrMsg); + void SetError(const lldb::SBError &error); template T *GetOption(const CMIUtilString &vStrOptionName); bool ParseValidateCmdOptions(); Index: lldb/trunk/tools/lldb-mi/MICmdBase.cpp === --- lldb/trunk/tools/lldb-mi/MICmdBase.cpp +++ lldb/trunk/tools/lldb-mi/MICmdBase.cpp @@ -214,6 +214,23 @@ //++ // +// Details: Short cut function to enter error information into the command's +// metadata object and set the command's error status. +// Type:Method. +// Args:error - (R) Command result description. +// Return: None. +// Throws: None. +//-- +void CMICmdBase::SetError(const lldb::SBError &error) { + const char *error_cstr = error.GetCString(); + if (error_cstr) +SetError(error_cstr); + else +SetError("unknown error"); +} + +//++ +// // Details: Ask a command to provide its unique identifier. // Type:Method. // Args:A unique identifier for this command class. Index: lldb/trunk/tools/lldb-mi/MICmdBase.h === --- lldb/trunk/tools/lldb-mi/MICmdBase.h +++ lldb/trunk/tools/lldb-mi/MICmdBase.h @@ -12,6 +12,8 @@ // C Includes // C++ Includes // Other libraries and framework includes +#include "lldb/API/SBError.h" + // Project includes #include "MICmdArgSet.h" #include "MICmdData.h" @@ -80,6 +82,7 @@ // Methods: protected: void SetError(const CMIUtilString &rErrMsg); + void SetError(const lldb::SBError &error); template T *GetOption(const CMIUtilString &vStrOptionName); bool ParseValidateCmdOptions(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47415: [lldb, lldb-mi] Re-implement MI -exec-continue command.
apolyakov added inline comments. Comment at: tools/lldb-mi/MICmdCmdExec.cpp:248 } - } else { -// ToDo: Re-evaluate if this is required when application near finished as -// this is parsing LLDB error message -// which seems a hack and is code brittle -const char *pLldbErr = m_lldbResult.GetError(); -const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine()); -if (strLldbMsg == "error: Process must be launched.") { - CMIDriver::Instance().SetExitApplicationFlag(true); -} - } + } else m_lldbResult.SetError(error.GetCString()); labath wrote: > polyakov.alex wrote: > > clayborg wrote: > > > clayborg wrote: > > > > clayborg wrote: > > > > > polyakov.alex wrote: > > > > > > clayborg wrote: > > > > > > > An error can claim to fail but not have an error string set. It > > > > > > > might be nice to have a helper function that checks to make sure > > > > > > > there is an error string on error cases and if there is no error > > > > > > > string when error.Success() is false or error.Fail() is true, > > > > > > > then set the error string to "unknown error". > > > > > > This functionality might be useful in all lldb-mi commands. So do > > > > > > you know where to place this function? Maybe inside SBError class? > > > > > I would put it somewhere in lldb-mi in a static function that is > > > > > something like: > > > > > ``` > > > > > static void SetErrorString(lldb::SBError &error, T &lldbResult) { > > > > > const char *error_cstr = error.GetCString(); > > > > > if (error_cstr) > > > > > lldbResult.SetError(error.GetCString()); > > > > > else > > > > > lldbResult.SetError("unknown error"); > > > > > } > > > > > ``` > > > > > Where the T is the type of m_lldbResult. > > > > Actually, are we using m_lldbResult now? I didn't realize its type was > > > > lldb::SBCommandReturnObject. That was only needed if we were calling: > > > > ``` > > > > rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(pCmd, > > > > m_lldbResult); > > > > ``` > > > > > > > > So we can get rid of all "lldb::SBCommandReturnObject m_lldbResult" > > > > member variables in any lldb-mi functions where we switch to using the > > > > API. > > > Since we can get rid of m_lldbResult, this should be: > > > > > > ``` > > > } else return MIstatus::failure; > > > ``` > > It should be: > > ``` > > else { > > SetError(CMIUtilString::Format(..., error.GetCString())); > > return MIstatus::failure; > > } > > ``` > > So, we anyway need a C-style error string. > AFAICT, `SBError::GetCString` calls `Status::AsCString` which has a default > argument `const char *default_error_str = "unknown error"`. So it sounds like > this issue is already taken care of down below. If we are still getting null > strings for failed SBErrors, maybe we need to fix something else instead of > adding another layer here. `SBError::GetCString` potentially may return NULL: ``` const char *SBError::GetCString() const { if (m_opaque_ap.get()) return m_opaque_ap->AsCString(); return NULL; } ``` https://reviews.llvm.org/D47415 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47415: [lldb, lldb-mi] Re-implement MI -exec-continue command.
polyakov.alex updated this revision to Diff 150486. polyakov.alex added a reviewer: labath. polyakov.alex added a comment. Removed unnecessary m_lldbResult attribute. https://reviews.llvm.org/D47415 Files: lit/tools/lldb-mi/exec/exec-continue.test tools/lldb-mi/MICmdCmdExec.cpp tools/lldb-mi/MICmdCmdExec.h Index: tools/lldb-mi/MICmdCmdExec.h === --- tools/lldb-mi/MICmdCmdExec.h +++ tools/lldb-mi/MICmdCmdExec.h @@ -93,8 +93,6 @@ /* dtor */ ~CMICmdCmdExecContinue() override; // Attributes: -private: - lldb::SBCommandReturnObject m_lldbResult; }; //++ Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -233,35 +233,23 @@ // Throws: None. //-- bool CMICmdCmdExecContinue::Execute() { - const char *pCmd = "continue"; - CMICmnLLDBDebugSessionInfo &rSessionInfo( - CMICmnLLDBDebugSessionInfo::Instance()); - const lldb::ReturnStatus rtn = - rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand( - pCmd, m_lldbResult); - MIunused(rtn); - - if (m_lldbResult.GetErrorSize() == 0) { + lldb::SBError error = + CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue(); + + if (error.Success()) { // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) { const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription()); SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), m_cmdData.strMiCmd.c_str(), rErrMsg.c_str())); return MIstatus::failure; } - } else { -// ToDo: Re-evaluate if this is required when application near finished as -// this is parsing LLDB error message -// which seems a hack and is code brittle -const char *pLldbErr = m_lldbResult.GetError(); -const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine()); -if (strLldbMsg == "error: Process must be launched.") { - CMIDriver::Instance().SetExitApplicationFlag(true); -} +return MIstatus::success; } - return MIstatus::success; + SetError(error.GetCString()); + return MIstatus::failure; } //++ @@ -276,19 +264,9 @@ // Throws: None. //-- bool CMICmdCmdExecContinue::Acknowledge() { - if (m_lldbResult.GetErrorSize() > 0) { -const CMICmnMIValueConst miValueConst(m_lldbResult.GetError()); -const CMICmnMIValueResult miValueResult("message", miValueConst); -const CMICmnMIResultRecord miRecordResult( -m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, -miValueResult); -m_miResultRecord = miRecordResult; - } else { -const CMICmnMIResultRecord miRecordResult( -m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); -m_miResultRecord = miRecordResult; - } - + const CMICmnMIResultRecord miRecordResult( + m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); + m_miResultRecord = miRecordResult; return MIstatus::success; } Index: lit/tools/lldb-mi/exec/exec-continue.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-continue.test @@ -0,0 +1,20 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-continue command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-continue +# CHECK: ^running ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47914: [lldb-mi] Add overloaded method for setting an error.
apolyakov added a comment. No, it's not used in a subsequent commit. Moreover, I think that we should revert this commit sometimes in a future, since it doesn't provide additional useful functionality. Repository: rL LLVM https://reviews.llvm.org/D47914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47415: [lldb, lldb-mi] Re-implement MI -exec-continue command.
This revision was automatically updated to reflect the committed changes. Closed by commit rL334350: [lldb, lldb-mi] Re-implement MI -exec-continue command. (authored by apolyakov, committed by ). Changed prior to commit: https://reviews.llvm.org/D47415?vs=150486&id=150629#toc Repository: rL LLVM https://reviews.llvm.org/D47415 Files: lldb/trunk/lit/tools/lldb-mi/exec/exec-continue.test lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp lldb/trunk/tools/lldb-mi/MICmdCmdExec.h Index: lldb/trunk/lit/tools/lldb-mi/exec/exec-continue.test === --- lldb/trunk/lit/tools/lldb-mi/exec/exec-continue.test +++ lldb/trunk/lit/tools/lldb-mi/exec/exec-continue.test @@ -0,0 +1,20 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-continue command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-continue +# CHECK: ^running Index: lldb/trunk/tools/lldb-mi/MICmdCmdExec.h === --- lldb/trunk/tools/lldb-mi/MICmdCmdExec.h +++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.h @@ -93,8 +93,6 @@ /* dtor */ ~CMICmdCmdExecContinue() override; // Attributes: -private: - lldb::SBCommandReturnObject m_lldbResult; }; //++ Index: lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp === --- lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp +++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp @@ -233,35 +233,23 @@ // Throws: None. //-- bool CMICmdCmdExecContinue::Execute() { - const char *pCmd = "continue"; - CMICmnLLDBDebugSessionInfo &rSessionInfo( - CMICmnLLDBDebugSessionInfo::Instance()); - const lldb::ReturnStatus rtn = - rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand( - pCmd, m_lldbResult); - MIunused(rtn); - - if (m_lldbResult.GetErrorSize() == 0) { + lldb::SBError error = + CMICmnLLDBDebugSessionInfo::Instance().GetProcess().Continue(); + + if (error.Success()) { // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) { const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription()); SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), m_cmdData.strMiCmd.c_str(), rErrMsg.c_str())); return MIstatus::failure; } - } else { -// ToDo: Re-evaluate if this is required when application near finished as -// this is parsing LLDB error message -// which seems a hack and is code brittle -const char *pLldbErr = m_lldbResult.GetError(); -const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine()); -if (strLldbMsg == "error: Process must be launched.") { - CMIDriver::Instance().SetExitApplicationFlag(true); -} +return MIstatus::success; } - return MIstatus::success; + SetError(error.GetCString()); + return MIstatus::failure; } //++ @@ -276,19 +264,9 @@ // Throws: None. //-- bool CMICmdCmdExecContinue::Acknowledge() { - if (m_lldbResult.GetErrorSize() > 0) { -const CMICmnMIValueConst miValueConst(m_lldbResult.GetError()); -const CMICmnMIValueResult miValueResult("message", miValueConst); -const CMICmnMIResultRecord miRecordResult( -m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, -miValueResult); -m_miResultRecord = miRecordResult; - } else { -const CMICmnMIResultRecord miRecordResult( -m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); -m_miResultRecord = miRecordResult; - } - + const CMICmnMIResultRecord miRecordResult( + m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); + m_miResultRecord = miRecordResult; return MIstatus::success; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47838: [lldb-mi] Re-implement MI -exec-step command.
polyakov.alex updated this revision to Diff 150632. polyakov.alex added a comment. Removed unnecessary m_lldbResult attribute, updated python test to successfully process new error messages in exec-step command. https://reviews.llvm.org/D47838 Files: lit/tools/lldb-mi/exec/exec-step.test packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py tools/lldb-mi/MICmdCmdExec.cpp tools/lldb-mi/MICmdCmdExec.h Index: tools/lldb-mi/MICmdCmdExec.h === --- tools/lldb-mi/MICmdCmdExec.h +++ tools/lldb-mi/MICmdCmdExec.h @@ -152,7 +152,6 @@ // Attributes: private: - lldb::SBCommandReturnObject m_lldbResult; const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but // Eclipse gives this option }; Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -487,14 +487,26 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger(); - CMIUtilString strCmd("thread step-in"); - if (nThreadId != UINT64_MAX) -strCmd += CMIUtilString::Format(" %llu", nThreadId); - rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, - false); - return MIstatus::success; + lldb::SBError error; + if (nThreadId != UINT64_MAX) { +lldb::SBThread sbThread = +rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId); +if (!sbThread.IsValid()) { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), + m_cmdData.strMiCmd.c_str(), + m_constStrArgThread.c_str())); + return MIstatus::failure; +} +sbThread.StepInto(nullptr, LLDB_INVALID_LINE_NUMBER, error); + } else rSessionInfo.GetProcess().GetSelectedThread().StepInto( + nullptr, LLDB_INVALID_LINE_NUMBER, error); + + if (error.Success()) +return MIstatus::success; + + SetError(error.GetCString()); + return MIstatus::failure; } //++ @@ -509,21 +521,8 @@ // Throws: None. //-- bool CMICmdCmdExecStep::Acknowledge() { - if (m_lldbResult.GetErrorSize() > 0) { -const char *pLldbErr = m_lldbResult.GetError(); -MIunused(pLldbErr); -const CMICmnMIValueConst miValueConst(m_lldbResult.GetError()); -const CMICmnMIValueResult miValueResult("message", miValueConst); -const CMICmnMIResultRecord miRecordResult( -m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, -miValueResult); -m_miResultRecord = miRecordResult; - } else { -const CMICmnMIResultRecord miRecordResult( -m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); -m_miResultRecord = miRecordResult; - } - + m_miResultRecord = CMICmnMIResultRecord( + m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); return MIstatus::success; } Index: packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py === --- packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py +++ packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py @@ -330,9 +330,9 @@ # Test that an invalid --thread is handled self.runCmd("-exec-step --thread 0") -self.expect("\^error,message=\"error: Thread index 0 is out of range") +self.expect("\^error,msg=\"Command 'exec-step'. Thread ID invalid") self.runCmd("-exec-step --thread 10") -self.expect("\^error,message=\"error: Thread index 10 is out of range") +self.expect("\^error,msg=\"Command 'exec-step'. Thread ID invalid") # Test that an invalid --frame is handled # FIXME: no error is returned Index: lit/tools/lldb-mi/exec/exec-step.test === --- /dev/null +++ lit/tools/lldb-mi/exec/exec-step.test @@ -0,0 +1,30 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-step command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-step --thread 0 +# Check that exec-step can process the case of invalid thread ID. +# CHECK: ^error,msg="Command 'exec-step'. Thread ID invalid" + +-exec-step --thread 1 +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" + +-exec-step +# Check that exec-step can step-in in a selected thread. +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" ___ lldb-commits m
[Lldb-commits] [PATCH] D47991: Add method SBThread::StepOver with SBError parameter.
apolyakov created this revision. apolyakov added reviewers: aprantl, clayborg, labath. The new method will allow to get error messages from StepOver function. https://reviews.llvm.org/D47991 Files: include/lldb/API/SBThread.h source/API/SBThread.cpp Index: source/API/SBThread.cpp === --- source/API/SBThread.cpp +++ source/API/SBThread.cpp @@ -633,6 +633,11 @@ } void SBThread::StepOver(lldb::RunMode stop_other_threads) { + SBError error; + StepOver(error, stop_other_threads); +} + +void SBThread::StepOver(SBError &error, lldb::RunMode stop_other_threads) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -662,9 +667,8 @@ } } -// This returns an error, we should use it! -ResumeNewPlan(exe_ctx, new_plan_sp.get()); - } +error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + } else error.SetErrorString("this SBThread object is invalid"); } void SBThread::StepInto(lldb::RunMode stop_other_threads) { Index: include/lldb/API/SBThread.h === --- include/lldb/API/SBThread.h +++ include/lldb/API/SBThread.h @@ -93,6 +93,9 @@ void StepOver(lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); + void StepOver(SBError &error, +lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); + void StepInto(lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); void StepInto(const char *target_name, Index: source/API/SBThread.cpp === --- source/API/SBThread.cpp +++ source/API/SBThread.cpp @@ -633,6 +633,11 @@ } void SBThread::StepOver(lldb::RunMode stop_other_threads) { + SBError error; + StepOver(error, stop_other_threads); +} + +void SBThread::StepOver(SBError &error, lldb::RunMode stop_other_threads) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -662,9 +667,8 @@ } } -// This returns an error, we should use it! -ResumeNewPlan(exe_ctx, new_plan_sp.get()); - } +error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + } else error.SetErrorString("this SBThread object is invalid"); } void SBThread::StepInto(lldb::RunMode stop_other_threads) { Index: include/lldb/API/SBThread.h === --- include/lldb/API/SBThread.h +++ include/lldb/API/SBThread.h @@ -93,6 +93,9 @@ void StepOver(lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); + void StepOver(SBError &error, +lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); + void StepInto(lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); void StepInto(const char *target_name, ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47991: Add method SBThread::StepOver with SBError parameter.
apolyakov added a comment. Also, I suggest to make similar things in other SBThread methods like StepOut etc. https://reviews.llvm.org/D47991 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47992: [lldb-mi] Correct error processing in exec-next command.
apolyakov created this revision. apolyakov added reviewers: aprantl, clayborg, labath. Herald added a subscriber: ki.stfu. https://reviews.llvm.org/D47992 Files: tools/lldb-mi/MICmdCmdExec.cpp tools/lldb-mi/MICmdCmdExec.h Index: tools/lldb-mi/MICmdCmdExec.h === --- tools/lldb-mi/MICmdCmdExec.h +++ tools/lldb-mi/MICmdCmdExec.h @@ -121,7 +121,6 @@ // Attributes: private: - lldb::SBCommandReturnObject m_lldbResult; const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but // Eclipse gives this option }; Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -358,18 +358,23 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); + lldb::SBError error; if (nThreadId != UINT64_MAX) { lldb::SBThread sbThread = rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId); if (!sbThread.IsValid()) { SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str())); return MIstatus::failure; } -sbThread.StepOver(); - } else rSessionInfo.GetProcess().GetSelectedThread().StepOver(); +sbThread.StepOver(error); + } else rSessionInfo.GetProcess().GetSelectedThread().StepOver(error); - return MIstatus::success; + if (error.Success()) +return MIstatus::success; + + SetError(error.GetCString()); + return MIstatus::failure; } //++ @@ -384,21 +389,8 @@ // Throws: None. //-- bool CMICmdCmdExecNext::Acknowledge() { - if (m_lldbResult.GetErrorSize() > 0) { -const char *pLldbErr = m_lldbResult.GetError(); -MIunused(pLldbErr); -const CMICmnMIValueConst miValueConst(m_lldbResult.GetError()); -const CMICmnMIValueResult miValueResult("message", miValueConst); -const CMICmnMIResultRecord miRecordResult( -m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, -miValueResult); -m_miResultRecord = miRecordResult; - } else { -const CMICmnMIResultRecord miRecordResult( -m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); -m_miResultRecord = miRecordResult; - } - + m_miResultRecord = CMICmnMIResultRecord( + m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); return MIstatus::success; } Index: tools/lldb-mi/MICmdCmdExec.h === --- tools/lldb-mi/MICmdCmdExec.h +++ tools/lldb-mi/MICmdCmdExec.h @@ -121,7 +121,6 @@ // Attributes: private: - lldb::SBCommandReturnObject m_lldbResult; const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but // Eclipse gives this option }; Index: tools/lldb-mi/MICmdCmdExec.cpp === --- tools/lldb-mi/MICmdCmdExec.cpp +++ tools/lldb-mi/MICmdCmdExec.cpp @@ -358,18 +358,23 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); + lldb::SBError error; if (nThreadId != UINT64_MAX) { lldb::SBThread sbThread = rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId); if (!sbThread.IsValid()) { SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str())); return MIstatus::failure; } -sbThread.StepOver(); - } else rSessionInfo.GetProcess().GetSelectedThread().StepOver(); +sbThread.StepOver(error); + } else rSessionInfo.GetProcess().GetSelectedThread().StepOver(error); - return MIstatus::success; + if (error.Success()) +return MIstatus::success; + + SetError(error.GetCString()); + return MIstatus::failure; } //++ @@ -384,21 +389,8 @@ // Throws: None. //-- bool CMICmdCmdExecNext::Acknowledge() { - if (m_lldbResult.GetErrorSize() > 0) { -const char *pLldbErr = m_lldbResult.GetError(); -MIunused(pLldbErr); -const CMICmnMIValueConst miValueConst(m_lldbResult.GetError()); -const CMICmnMIValueResult miValueResult("message", miValueConst); -const CMICmnMIResultRecord miRecordResult( -m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, -miValueResult); -m_miResultRecord = miRecordResult; - } else { -const CMICmnMIResultRecord miRecordResult( -m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); -m_miResultRecord = miRecordResult; - } - + m_miResultRecord = CMICmnMIResultRecord( + m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); return MIstatus::success; } __
[Lldb-commits] [PATCH] D47992: [lldb-mi] Correct error processing in exec-next command.
apolyakov added a comment. This patch uses changes from https://reviews.llvm.org/D47991. Is allows to: (gdb) -file-exec-and-symbols "bash" ^done (gdb) =library-loaded,id="/bin/bash",target-name="/bin/bash",host-name="/bin/bash",symbols-loaded="0",loaded_addr="-",size="0" -exec-next ^error,msg="this SBThread object is invalid" instead of simple `^running` message. https://reviews.llvm.org/D47992 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47838: [lldb-mi] Re-implement MI -exec-step command.
This revision was automatically updated to reflect the committed changes. Closed by commit rL334364: [lldb-mi] Re-implement MI -exec-step command. (authored by apolyakov, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D47838?vs=150632&id=150652#toc Repository: rL LLVM https://reviews.llvm.org/D47838 Files: lldb/trunk/lit/tools/lldb-mi/exec/exec-step.test lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp lldb/trunk/tools/lldb-mi/MICmdCmdExec.h Index: lldb/trunk/lit/tools/lldb-mi/exec/exec-step.test === --- lldb/trunk/lit/tools/lldb-mi/exec/exec-step.test +++ lldb/trunk/lit/tools/lldb-mi/exec/exec-step.test @@ -0,0 +1,30 @@ +# XFAIL: windows +# -> llvm.org/pr24452 +# +# RUN: %cc -o %t %p/inputs/main.c -g +# RUN: %lldbmi %t < %s | FileCheck %s + +# Test lldb-mi -exec-step command. + +# Check that we have a valid target created via '%lldbmi %t'. +# CHECK: ^done + +-break-insert main +# CHECK: ^done,bkpt={number="1" + +-exec-run +# CHECK: ^running +# CHECK: *stopped,reason="breakpoint-hit" + +-exec-step --thread 0 +# Check that exec-step can process the case of invalid thread ID. +# CHECK: ^error,msg="Command 'exec-step'. Thread ID invalid" + +-exec-step --thread 1 +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" + +-exec-step +# Check that exec-step can step-in in a selected thread. +# CHECK: ^running +# CHECK: *stopped,reason="end-stepping-range" Index: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py === --- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py +++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/control/TestMiExec.py @@ -330,9 +330,9 @@ # Test that an invalid --thread is handled self.runCmd("-exec-step --thread 0") -self.expect("\^error,message=\"error: Thread index 0 is out of range") +self.expect("\^error,msg=\"Command 'exec-step'. Thread ID invalid") self.runCmd("-exec-step --thread 10") -self.expect("\^error,message=\"error: Thread index 10 is out of range") +self.expect("\^error,msg=\"Command 'exec-step'. Thread ID invalid") # Test that an invalid --frame is handled # FIXME: no error is returned Index: lldb/trunk/tools/lldb-mi/MICmdCmdExec.h === --- lldb/trunk/tools/lldb-mi/MICmdCmdExec.h +++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.h @@ -152,7 +152,6 @@ // Attributes: private: - lldb::SBCommandReturnObject m_lldbResult; const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but // Eclipse gives this option }; Index: lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp === --- lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp +++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp @@ -487,14 +487,26 @@ CMICmnLLDBDebugSessionInfo &rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance()); - lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger(); - CMIUtilString strCmd("thread step-in"); - if (nThreadId != UINT64_MAX) -strCmd += CMIUtilString::Format(" %llu", nThreadId); - rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, - false); - return MIstatus::success; + lldb::SBError error; + if (nThreadId != UINT64_MAX) { +lldb::SBThread sbThread = +rSessionInfo.GetProcess().GetThreadByIndexID(nThreadId); +if (!sbThread.IsValid()) { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), + m_cmdData.strMiCmd.c_str(), + m_constStrArgThread.c_str())); + return MIstatus::failure; +} +sbThread.StepInto(nullptr, LLDB_INVALID_LINE_NUMBER, error); + } else rSessionInfo.GetProcess().GetSelectedThread().StepInto( + nullptr, LLDB_INVALID_LINE_NUMBER, error); + + if (error.Success()) +return MIstatus::success; + + SetError(error.GetCString()); + return MIstatus::failure; } //++ @@ -509,21 +521,8 @@ // Throws: None. //-- bool CMICmdCmdExecStep::Acknowledge() { - if (m_lldbResult.GetErrorSize() > 0) { -const char *pLldbErr = m_lldbResult.GetError(); -MIunused(pLldbErr); -const CMICmnMIValueConst miValueConst(m_lldbResult.GetError()); -const CMICmnMIValueResult miValueResult("message", miValueConst); -const CMICmnMIResultRecord miRecordResult( -m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, -miValueResult); -m_miResultRecord = miRecordResult; - } else { -const CMICmnMIResultRecord miRecordResult( -m_cmdData
[Lldb-commits] [PATCH] D47838: [lldb-mi] Re-implement MI -exec-step command.
polyakov.alex added inline comments. Comment at: lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp:524 bool CMICmdCmdExecStep::Acknowledge() { - if (m_lldbResult.GetErrorSize() > 0) { -const char *pLldbErr = m_lldbResult.GetError(); -MIunused(pLldbErr); -const CMICmnMIValueConst miValueConst(m_lldbResult.GetError()); -const CMICmnMIValueResult miValueResult("message", miValueConst); -const CMICmnMIResultRecord miRecordResult( -m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, -miValueResult); -m_miResultRecord = miRecordResult; - } else { -const CMICmnMIResultRecord miRecordResult( -m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); -m_miResultRecord = miRecordResult; - } - + m_miResultRecord = CMICmnMIResultRecord( + m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running); clayborg wrote: > How does this code handle the error case for stepping now? If there is an error in lldb-mi command execution, it'll be detected in `Execute` function: ``` if (error.Success()) return MIstatus::sucess; SetError(error.GetCString()); return MIstatus::failure ``` If `Execute` function returns `MIstatus::failure`, then `Acknowledge` function won't be called. Repository: rL LLVM https://reviews.llvm.org/D47838 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47991: Add method SBThread::StepOver with SBError parameter.
apolyakov added inline comments. Comment at: include/lldb/API/SBThread.h:96 + void StepOver(SBError &error, +lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); aprantl wrote: > Where is the SBAPI documentation that is displayed on http://lldb.llvm.org ? > Apparently no in this file, but it must exist *somewhere*, can you update it > too, please? Due to http://lldb.llvm.org/: `This documentation is generated directly from the source code with doxygen.`. So I think that we don't need to change anything except source files. https://reviews.llvm.org/D47991 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47991: Add method SBThread::StepOver with SBError parameter.
apolyakov added a comment. I found it out. Info about each method is located in header file. For example, you may look at `include/lldb/API/SBThread.h` and find text from docs. https://reviews.llvm.org/D47991 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47991: Add method SBThread::StepOver with SBError parameter.
apolyakov added a comment. In https://reviews.llvm.org/D47991#1128477, @labath wrote: > In https://reviews.llvm.org/D47991#1128433, @aprantl wrote: > > > Hmm.. it looks like most C++ API calls don't have any documentation. > > > > http://lldb.llvm.org/cpp_reference/html/classlldb_1_1SBThread.html#a42755a170e127881a5dd65162217f68b > > > > It does look like the python API has more documentation.. where does that > > come from? > > > scripts/interface/SBThread.i Do you know what is the difference between `autodoc` and `docstring` there? https://reviews.llvm.org/D47991 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47991: Improve SBThread's stepping API using SBError parameter.
apolyakov updated this revision to Diff 150814. apolyakov retitled this revision from "Add method SBThread::StepOver with SBError parameter." to "Improve SBThread's stepping API using SBError parameter.". apolyakov edited the summary of this revision. apolyakov added a comment. Documented changes and overloaded all stepping functions. https://reviews.llvm.org/D47991 Files: include/lldb/API/SBThread.h scripts/interface/SBThread.i source/API/SBThread.cpp Index: source/API/SBThread.cpp === --- source/API/SBThread.cpp +++ source/API/SBThread.cpp @@ -633,6 +633,11 @@ } void SBThread::StepOver(lldb::RunMode stop_other_threads) { + SBError error; + StepOver(error, stop_other_threads); +} + +void SBThread::StepOver(SBError &error, lldb::RunMode stop_other_threads) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -662,9 +667,8 @@ } } -// This returns an error, we should use it! -ResumeNewPlan(exe_ctx, new_plan_sp.get()); - } +error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + } else error.SetErrorString("this SBThread object is invalid"); } void SBThread::StepInto(lldb::RunMode stop_other_threads) { @@ -722,10 +726,15 @@ } error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); - } + } else error.SetErrorString("this SBThread object is invalid"); } void SBThread::StepOut() { + SBError error; + StepOut(error); +} + +void SBThread::StepOut(SBError &error) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -746,12 +755,16 @@ abort_other_plans, NULL, false, stop_other_threads, eVoteYes, eVoteNoOpinion, 0, avoid_no_debug)); -// This returns an error, we should use it! -ResumeNewPlan(exe_ctx, new_plan_sp.get()); - } +error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + } else error.SetErrorString("this SBThread object is invalid"); +} + +void SBThread::StepOutOfFrame(SBFrame &sb_frame) { + SBError error; + StepOutOfFrame(sb_frame, error); } -void SBThread::StepOutOfFrame(lldb::SBFrame &sb_frame) { +void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -789,12 +802,16 @@ abort_other_plans, NULL, false, stop_other_threads, eVoteYes, eVoteNoOpinion, frame_sp->GetFrameIndex())); -// This returns an error, we should use it! -ResumeNewPlan(exe_ctx, new_plan_sp.get()); - } +error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + } else error.SetErrorString("this SBThread object is invalid"); } void SBThread::StepInstruction(bool step_over) { + SBError error; + StepInstruction(step_over, error); +} + +void SBThread::StepInstruction(bool step_over, SBError &error) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -809,12 +826,16 @@ ThreadPlanSP new_plan_sp( thread->QueueThreadPlanForStepSingleInstruction(step_over, true, true)); -// This returns an error, we should use it! -ResumeNewPlan(exe_ctx, new_plan_sp.get()); - } +error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + } else error.SetErrorString("this SBThread object is invalid"); } void SBThread::RunToAddress(lldb::addr_t addr) { + SBError error; + RunToAddress(addr, error); +} + +void SBThread::RunToAddress(lldb::addr_t addr, SBError &error) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -835,9 +856,8 @@ ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForRunToAddress( abort_other_plans, target_addr, stop_other_threads)); -// This returns an error, we should use it! -ResumeNewPlan(exe_ctx, new_plan_sp.get()); - } +error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + } else error.SetErrorString("this SBThread object is invalid"); } SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, @@ -1082,6 +1102,11 @@ } bool SBThread::Suspend() { + SBError error; + return Suspend(error); +} + +bool SBThread::Suspend(SBError &error) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1097,14 +1122,19 @@ log->Printf("SBThread(%p)::Suspend() => error: process is running", static_cast(exe_ctx.GetThreadPtr())); } - } + } else error.SetErrorString("this SBThread object is invalid"); if (log) log->Printf("SBThread(%p)::Suspend() => %i", static_cast(exe_ctx.GetThreadPtr()), result); return result; } bool SBThread::Resume() { + SBError error; + return Resume(error); +} + +bool SBThread::Resume(SBError &error) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; ExecutionC
[Lldb-commits] [PATCH] D47991: Improve SBThread's stepping API using SBError parameter.
apolyakov added a comment. In https://reviews.llvm.org/D47991#1128831, @aprantl wrote: > Have you looked into making the error the first vs the last argument? If the > majority of all SBAPI calls put the error last, we should do this here, too. As you could see, SBError is on first place only in one function - `StepOver`. When I replaced it to last place, I got an error: /home/alexander/workspace/gsoc/llvm/tools/lldb/scripts/./interface/SBThread.i:218: Error: Non-optional argument 'error' follows an optional argument. so I returned it back. https://reviews.llvm.org/D47991 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47991: Improve SBThread's stepping API using SBError parameter.
apolyakov added a comment. By the way, we can do something like: void StepOver() { StepOver(lldb:eOnlyDuringStepping); } void StepOver(lldb::RunMode stop_other_threads) { SBError error; StepOver(stop_other_threads, error); } and so on. https://reviews.llvm.org/D47991 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47991: Improve SBThread's stepping API using SBError parameter.
apolyakov updated this revision to Diff 150913. apolyakov added a comment. Some readability improvements(more comments). I think that we should keep `StepOver` signature as void StepOver(SBError &error, lldb::RunMode stop_other_threads); since it seems that in SBThread methods SBError paramater is the last non-optional one, as @aprantl said. https://reviews.llvm.org/D47991 Files: include/lldb/API/SBThread.h scripts/interface/SBThread.i source/API/SBThread.cpp Index: source/API/SBThread.cpp === --- source/API/SBThread.cpp +++ source/API/SBThread.cpp @@ -632,7 +632,14 @@ return sb_error; } -void SBThread::StepOver(lldb::RunMode stop_other_threads) { +void SBThread::StepOver(lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping */) { + SBError error; // Ignored + StepOver(error, stop_other_threads); +} + +void SBThread::StepOver(SBError &error, lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping */) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -662,23 +669,25 @@ } } -// This returns an error, we should use it! -ResumeNewPlan(exe_ctx, new_plan_sp.get()); - } +error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + } else error.SetErrorString("this SBThread object is invalid"); } -void SBThread::StepInto(lldb::RunMode stop_other_threads) { +void SBThread::StepInto(lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping */) { StepInto(NULL, stop_other_threads); } void SBThread::StepInto(const char *target_name, -lldb::RunMode stop_other_threads) { - SBError error; +lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping*/) { + SBError error; // Ignored StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads); } void SBThread::StepInto(const char *target_name, uint32_t end_line, -SBError &error, lldb::RunMode stop_other_threads) { +SBError &error, lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping */) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -722,10 +731,15 @@ } error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); - } + } else error.SetErrorString("this SBThread object is invalid"); } void SBThread::StepOut() { + SBError error; // Ignored + StepOut(error); +} + +void SBThread::StepOut(SBError &error) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -746,12 +760,16 @@ abort_other_plans, NULL, false, stop_other_threads, eVoteYes, eVoteNoOpinion, 0, avoid_no_debug)); -// This returns an error, we should use it! -ResumeNewPlan(exe_ctx, new_plan_sp.get()); - } +error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + } else error.SetErrorString("this SBThread object is invalid"); +} + +void SBThread::StepOutOfFrame(SBFrame &sb_frame) { + SBError error; // Ignored + StepOutOfFrame(sb_frame, error); } -void SBThread::StepOutOfFrame(lldb::SBFrame &sb_frame) { +void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -789,12 +807,16 @@ abort_other_plans, NULL, false, stop_other_threads, eVoteYes, eVoteNoOpinion, frame_sp->GetFrameIndex())); -// This returns an error, we should use it! -ResumeNewPlan(exe_ctx, new_plan_sp.get()); - } +error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + } else error.SetErrorString("this SBThread object is invalid"); } void SBThread::StepInstruction(bool step_over) { + SBError error; // Ignored + StepInstruction(step_over, error); +} + +void SBThread::StepInstruction(bool step_over, SBError &error) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -809,12 +831,16 @@ ThreadPlanSP new_plan_sp( thread->QueueThreadPlanForStepSingleInstruction(step_over, true, true)); -// This returns an error, we should use it! -ResumeNewPlan(exe_ctx, new_plan_sp.get()); - } +error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + } else error.SetErrorString("this SBThread object is invalid"); } void SBThread::RunToAddress(lldb::addr_t addr) { + SBError error; // Ignored + RunToAddress(addr, error); +} + +void SBThread::RunToAddress(lldb::addr_t addr, SBError &error) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -835,9 +861,8 @@ ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForRunToAddress( abort_other_plans, target_addr, stop_other_thread
[Lldb-commits] [PATCH] D47991: Improve SBThread's stepping API using SBError parameter.
apolyakov updated this revision to Diff 150983. apolyakov added a comment. Added early exits. https://reviews.llvm.org/D47991 Files: include/lldb/API/SBThread.h scripts/interface/SBThread.i source/API/SBThread.cpp Index: source/API/SBThread.cpp === --- source/API/SBThread.cpp +++ source/API/SBThread.cpp @@ -632,7 +632,14 @@ return sb_error; } -void SBThread::StepOver(lldb::RunMode stop_other_threads) { +void SBThread::StepOver(lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping */) { + SBError error; // Ignored + StepOver(error, stop_other_threads); +} + +void SBThread::StepOver(SBError &error, lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping */) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -643,42 +650,46 @@ static_cast(exe_ctx.GetThreadPtr()), Thread::RunModeAsCString(stop_other_threads)); - if (exe_ctx.HasThreadScope()) { -Thread *thread = exe_ctx.GetThreadPtr(); -bool abort_other_plans = false; -StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0)); - -ThreadPlanSP new_plan_sp; -if (frame_sp) { - if (frame_sp->HasDebugInformation()) { -const LazyBool avoid_no_debug = eLazyBoolCalculate; -SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); -new_plan_sp = thread->QueueThreadPlanForStepOverRange( -abort_other_plans, sc.line_entry, sc, stop_other_threads, -avoid_no_debug); - } else { -new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction( -true, abort_other_plans, stop_other_threads); - } -} + if (!exe_ctx.HasThreadScope()) { +error.SetErrorString("this SBThread object is invalid"); +return; + } + + Thread *thread = exe_ctx.GetThreadPtr(); + bool abort_other_plans = false; + StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0)); -// This returns an error, we should use it! -ResumeNewPlan(exe_ctx, new_plan_sp.get()); + ThreadPlanSP new_plan_sp; + if (frame_sp) { +if (frame_sp->HasDebugInformation()) { + const LazyBool avoid_no_debug = eLazyBoolCalculate; + SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); + new_plan_sp = thread->QueueThreadPlanForStepOverRange( + abort_other_plans, sc.line_entry, sc, stop_other_threads, + avoid_no_debug); +} else { + new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction( + true, abort_other_plans, stop_other_threads); +} } + error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); } -void SBThread::StepInto(lldb::RunMode stop_other_threads) { +void SBThread::StepInto(lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping */) { StepInto(NULL, stop_other_threads); } void SBThread::StepInto(const char *target_name, -lldb::RunMode stop_other_threads) { - SBError error; +lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping*/) { + SBError error; // Ignored StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads); } void SBThread::StepInto(const char *target_name, uint32_t end_line, -SBError &error, lldb::RunMode stop_other_threads) { +SBError &error, lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping */) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -691,41 +702,48 @@ target_name ? target_name : "", Thread::RunModeAsCString(stop_other_threads)); - if (exe_ctx.HasThreadScope()) { -bool abort_other_plans = false; - -Thread *thread = exe_ctx.GetThreadPtr(); -StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0)); -ThreadPlanSP new_plan_sp; + if (!exe_ctx.HasThreadScope()) { +error.SetErrorString("this SBThread object is invalid"); +return; + } -if (frame_sp && frame_sp->HasDebugInformation()) { - SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); - AddressRange range; - if (end_line == LLDB_INVALID_LINE_NUMBER) -range = sc.line_entry.range; - else { -if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, error.ref())) - return; - } + bool abort_other_plans = false; - const LazyBool step_out_avoids_code_without_debug_info = - eLazyBoolCalculate; - const LazyBool step_in_avoids_code_without_debug_info = - eLazyBoolCalculate; - new_plan_sp = thread->QueueThreadPlanForStepInRange( - abort_other_plans, range, sc, target_name, stop_other_threads, - step_in_avoids_code_without_debug_info, -
[Lldb-commits] [PATCH] D47991: Improve SBThread's stepping API using SBError parameter.
apolyakov added inline comments. Comment at: source/API/SBThread.cpp:1136 bool result = false; if (exe_ctx.HasThreadScope()) { Process::StopLocker stop_locker; @aprantl do you think that we should use early exit here? There is printing to log at the end of the function, so in case of early exit, we must duplicate `log->Printf()`. Is it worth it? https://reviews.llvm.org/D47991 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47991: Improve SBThread's stepping API using SBError parameter.
apolyakov updated this revision to Diff 150996. apolyakov added a comment. Added `StepOver` overload without optional parameters. https://reviews.llvm.org/D47991 Files: include/lldb/API/SBThread.h scripts/interface/SBThread.i source/API/SBThread.cpp Index: source/API/SBThread.cpp === --- source/API/SBThread.cpp +++ source/API/SBThread.cpp @@ -632,7 +632,13 @@ return sb_error; } -void SBThread::StepOver(lldb::RunMode stop_other_threads) { +void SBThread::StepOver(lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping */) { + SBError error; // Ignored + StepOver(stop_other_threads, error); +} + +void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -643,42 +649,46 @@ static_cast(exe_ctx.GetThreadPtr()), Thread::RunModeAsCString(stop_other_threads)); - if (exe_ctx.HasThreadScope()) { -Thread *thread = exe_ctx.GetThreadPtr(); -bool abort_other_plans = false; -StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0)); - -ThreadPlanSP new_plan_sp; -if (frame_sp) { - if (frame_sp->HasDebugInformation()) { -const LazyBool avoid_no_debug = eLazyBoolCalculate; -SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); -new_plan_sp = thread->QueueThreadPlanForStepOverRange( -abort_other_plans, sc.line_entry, sc, stop_other_threads, -avoid_no_debug); - } else { -new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction( -true, abort_other_plans, stop_other_threads); - } -} + if (!exe_ctx.HasThreadScope()) { +error.SetErrorString("this SBThread object is invalid"); +return; + } + + Thread *thread = exe_ctx.GetThreadPtr(); + bool abort_other_plans = false; + StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0)); -// This returns an error, we should use it! -ResumeNewPlan(exe_ctx, new_plan_sp.get()); + ThreadPlanSP new_plan_sp; + if (frame_sp) { +if (frame_sp->HasDebugInformation()) { + const LazyBool avoid_no_debug = eLazyBoolCalculate; + SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); + new_plan_sp = thread->QueueThreadPlanForStepOverRange( + abort_other_plans, sc.line_entry, sc, stop_other_threads, + avoid_no_debug); +} else { + new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction( + true, abort_other_plans, stop_other_threads); +} } + error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); } -void SBThread::StepInto(lldb::RunMode stop_other_threads) { +void SBThread::StepInto(lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping */) { StepInto(NULL, stop_other_threads); } void SBThread::StepInto(const char *target_name, -lldb::RunMode stop_other_threads) { - SBError error; +lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping*/) { + SBError error; // Ignored StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads); } void SBThread::StepInto(const char *target_name, uint32_t end_line, -SBError &error, lldb::RunMode stop_other_threads) { +SBError &error, lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping */) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -691,41 +701,48 @@ target_name ? target_name : "", Thread::RunModeAsCString(stop_other_threads)); - if (exe_ctx.HasThreadScope()) { -bool abort_other_plans = false; + if (!exe_ctx.HasThreadScope()) { +error.SetErrorString("this SBThread object is invalid"); +return; + } -Thread *thread = exe_ctx.GetThreadPtr(); -StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0)); -ThreadPlanSP new_plan_sp; + bool abort_other_plans = false; -if (frame_sp && frame_sp->HasDebugInformation()) { - SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); - AddressRange range; - if (end_line == LLDB_INVALID_LINE_NUMBER) -range = sc.line_entry.range; - else { -if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, error.ref())) - return; - } - - const LazyBool step_out_avoids_code_without_debug_info = - eLazyBoolCalculate; - const LazyBool step_in_avoids_code_without_debug_info = - eLazyBoolCalculate; - new_plan_sp = thread->QueueThreadPlanForStepInRange( - abort_other_plans, range, sc, target_name, stop_other_threads, - step_in_avoids_code_without_debug_info, - step_out_avoids_code_without_debu
[Lldb-commits] [PATCH] D47991: Improve SBThread's stepping API using SBError parameter.
apolyakov added inline comments. Comment at: source/API/SBThread.cpp:816 +error.SetErrorString("passed a frame from another thread"); +return; } I found this place and added `return`. https://reviews.llvm.org/D47991 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47991: Improve SBThread's stepping API using SBError parameter.
apolyakov updated this revision to Diff 151000. apolyakov added a comment. Minor update: moved `error.SetErrorString` to the top of `if` statement to increase readability. https://reviews.llvm.org/D47991 Files: include/lldb/API/SBThread.h scripts/interface/SBThread.i source/API/SBThread.cpp Index: source/API/SBThread.cpp === --- source/API/SBThread.cpp +++ source/API/SBThread.cpp @@ -632,7 +632,13 @@ return sb_error; } -void SBThread::StepOver(lldb::RunMode stop_other_threads) { +void SBThread::StepOver(lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping */) { + SBError error; // Ignored + StepOver(stop_other_threads, error); +} + +void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -643,42 +649,46 @@ static_cast(exe_ctx.GetThreadPtr()), Thread::RunModeAsCString(stop_other_threads)); - if (exe_ctx.HasThreadScope()) { -Thread *thread = exe_ctx.GetThreadPtr(); -bool abort_other_plans = false; -StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0)); - -ThreadPlanSP new_plan_sp; -if (frame_sp) { - if (frame_sp->HasDebugInformation()) { -const LazyBool avoid_no_debug = eLazyBoolCalculate; -SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); -new_plan_sp = thread->QueueThreadPlanForStepOverRange( -abort_other_plans, sc.line_entry, sc, stop_other_threads, -avoid_no_debug); - } else { -new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction( -true, abort_other_plans, stop_other_threads); - } -} + if (!exe_ctx.HasThreadScope()) { +error.SetErrorString("this SBThread object is invalid"); +return; + } + + Thread *thread = exe_ctx.GetThreadPtr(); + bool abort_other_plans = false; + StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0)); -// This returns an error, we should use it! -ResumeNewPlan(exe_ctx, new_plan_sp.get()); + ThreadPlanSP new_plan_sp; + if (frame_sp) { +if (frame_sp->HasDebugInformation()) { + const LazyBool avoid_no_debug = eLazyBoolCalculate; + SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); + new_plan_sp = thread->QueueThreadPlanForStepOverRange( + abort_other_plans, sc.line_entry, sc, stop_other_threads, + avoid_no_debug); +} else { + new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction( + true, abort_other_plans, stop_other_threads); +} } + error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); } -void SBThread::StepInto(lldb::RunMode stop_other_threads) { +void SBThread::StepInto(lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping */) { StepInto(NULL, stop_other_threads); } void SBThread::StepInto(const char *target_name, -lldb::RunMode stop_other_threads) { - SBError error; +lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping*/) { + SBError error; // Ignored StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads); } void SBThread::StepInto(const char *target_name, uint32_t end_line, -SBError &error, lldb::RunMode stop_other_threads) { +SBError &error, lldb::RunMode stop_other_threads +/* = lldb::eOnlyDuringStepping */) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); std::unique_lock lock; @@ -691,41 +701,48 @@ target_name ? target_name : "", Thread::RunModeAsCString(stop_other_threads)); - if (exe_ctx.HasThreadScope()) { -bool abort_other_plans = false; + if (!exe_ctx.HasThreadScope()) { +error.SetErrorString("this SBThread object is invalid"); +return; + } -Thread *thread = exe_ctx.GetThreadPtr(); -StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0)); -ThreadPlanSP new_plan_sp; + bool abort_other_plans = false; -if (frame_sp && frame_sp->HasDebugInformation()) { - SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); - AddressRange range; - if (end_line == LLDB_INVALID_LINE_NUMBER) -range = sc.line_entry.range; - else { -if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, error.ref())) - return; - } - - const LazyBool step_out_avoids_code_without_debug_info = - eLazyBoolCalculate; - const LazyBool step_in_avoids_code_without_debug_info = - eLazyBoolCalculate; - new_plan_sp = thread->QueueThreadPlanForStepInRange( - abort_other_plans, range, sc, target_name, stop_other_threads, - step_in_avoids_code_without_debug_info, -
[Lldb-commits] [PATCH] D47991: Improve SBThread's stepping API using SBError parameter.
apolyakov added a comment. In https://reviews.llvm.org/D47991#1131043, @clayborg wrote: > Looks good. Just a question about including the commented out default > arguments Don't you think it increases readability of this code? https://reviews.llvm.org/D47991 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D48212: Revert "[lldb-mi] Add overload method for setting an error"
This revision was automatically updated to reflect the committed changes. Closed by commit rL334860: Revert "[lldb-mi] Add overload method for setting an error" (authored by apolyakov, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D48212?vs=151482&id=151553#toc Repository: rL LLVM https://reviews.llvm.org/D48212 Files: lldb/trunk/tools/lldb-mi/MICmdBase.cpp lldb/trunk/tools/lldb-mi/MICmdBase.h Index: lldb/trunk/tools/lldb-mi/MICmdBase.cpp === --- lldb/trunk/tools/lldb-mi/MICmdBase.cpp +++ lldb/trunk/tools/lldb-mi/MICmdBase.cpp @@ -214,23 +214,6 @@ //++ // -// Details: Short cut function to enter error information into the command's -// metadata object and set the command's error status. -// Type:Method. -// Args:error - (R) Command result description. -// Return: None. -// Throws: None. -//-- -void CMICmdBase::SetError(const lldb::SBError &error) { - const char *error_cstr = error.GetCString(); - if (error_cstr) -SetError(error_cstr); - else -SetError("unknown error"); -} - -//++ -// // Details: Ask a command to provide its unique identifier. // Type:Method. // Args:A unique identifier for this command class. Index: lldb/trunk/tools/lldb-mi/MICmdBase.h === --- lldb/trunk/tools/lldb-mi/MICmdBase.h +++ lldb/trunk/tools/lldb-mi/MICmdBase.h @@ -12,8 +12,6 @@ // C Includes // C++ Includes // Other libraries and framework includes -#include "lldb/API/SBError.h" - // Project includes #include "MICmdArgSet.h" #include "MICmdData.h" @@ -82,7 +80,6 @@ // Methods: protected: void SetError(const CMIUtilString &rErrMsg); - void SetError(const lldb::SBError &error); template T *GetOption(const CMIUtilString &vStrOptionName); bool ParseValidateCmdOptions(); Index: lldb/trunk/tools/lldb-mi/MICmdBase.cpp === --- lldb/trunk/tools/lldb-mi/MICmdBase.cpp +++ lldb/trunk/tools/lldb-mi/MICmdBase.cpp @@ -214,23 +214,6 @@ //++ // -// Details: Short cut function to enter error information into the command's -// metadata object and set the command's error status. -// Type:Method. -// Args:error - (R) Command result description. -// Return: None. -// Throws: None. -//-- -void CMICmdBase::SetError(const lldb::SBError &error) { - const char *error_cstr = error.GetCString(); - if (error_cstr) -SetError(error_cstr); - else -SetError("unknown error"); -} - -//++ -// // Details: Ask a command to provide its unique identifier. // Type:Method. // Args:A unique identifier for this command class. Index: lldb/trunk/tools/lldb-mi/MICmdBase.h === --- lldb/trunk/tools/lldb-mi/MICmdBase.h +++ lldb/trunk/tools/lldb-mi/MICmdBase.h @@ -12,8 +12,6 @@ // C Includes // C++ Includes // Other libraries and framework includes -#include "lldb/API/SBError.h" - // Project includes #include "MICmdArgSet.h" #include "MICmdData.h" @@ -82,7 +80,6 @@ // Methods: protected: void SetError(const CMIUtilString &rErrMsg); - void SetError(const lldb::SBError &error); template T *GetOption(const CMIUtilString &vStrOptionName); bool ParseValidateCmdOptions(); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47992: [lldb-mi] Correct error processing in exec-next command.
apolyakov added a comment. If you look at `bool CMICmdCmdExecContinue::Execute()`, you'll see that there are cases in which we need a flexible way to finish MI command(specific action in error case for example). We have a few options: not to add such an utility function, add and use it in simple situations where we just want to check on SBError status or we may create utility function with lambda functions in which user could specify actions he needs. What are your thoughts about this? https://reviews.llvm.org/D47992 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D47302: [WIP] New class SBTargetSettings to store and manipulate all target's properties.
polyakov.alex updated this revision to Diff 151682. polyakov.alex retitled this revision from "[lldb, lldb-mi] Add method AddCurrentTargetSharedObjectPath to the SBDebugger." to "[WIP] New class SBTargetSettings to store and manipulate all target's properties.". polyakov.alex edited the summary of this revision. polyakov.alex added a comment. Herald added a subscriber: mgorny. As we discussed previously, it would be nice to have a class in SB API that will manipulate with SBTarget's properties. I started to work on this and , as I expected, faced with a problem: `TargetProperties` class doesn't have a property with image search paths while `Target` does. It means that we should have a pointer to `Target` to implement things like `SBTargetSettings::AppendImageSearchPath(const char *from, const char *to, SBError &error)`. We may store an additional pointer to `Target`, but, as I understood, it's not what we want from `SBTargetSettings` to be. Moreover, it looks strange that image search path isn't a part of `TargetProperties` while executable and debug file search paths are. I'm looking forward for your comments about this. https://reviews.llvm.org/D47302 Files: include/lldb/API/SBTarget.h include/lldb/API/SBTargetSettings.h source/API/CMakeLists.txt source/API/SBTargetSettings.cpp Index: source/API/SBTargetSettings.cpp === --- /dev/null +++ source/API/SBTargetSettings.cpp @@ -0,0 +1,41 @@ +//===-- SBTargetSettings.cpp *- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "lldb/API/SBTargetSettings.h" + +#include "lldb/Target/Target.h" +#include "lldb/Utility/Log.h" +#include "llvm/Support/Casting.h" + +using namespace lldb; +using namespace lldb_private; + +//-- +// SBTargetSettings constructors +//-- +SBTargetSettings::SBTargetSettings() : m_opaque_sp() {} + +SBTargetSettings::SBTargetSettings(const lldb::SBTarget &sb_target) +: m_opaque_sp(sb_target.GetSP()) {} + +//-- +// Destructor +//-- +SBTargetSettings::~SBTargetSettings() = default; + +void SBTargetSettings::AppendImageSearchPath(const char *from, + const char *to) { + SBError error; + AppendImageSearchPath(from, to, error); +} + +void SBTargetSettings::AppendImageSearchPath(const char *from, + const char *to, + SBError &error) { +} Index: source/API/CMakeLists.txt === --- source/API/CMakeLists.txt +++ source/API/CMakeLists.txt @@ -63,6 +63,7 @@ SBSymbolContext.cpp SBSymbolContextList.cpp SBTarget.cpp + SBTargetSettings.cpp SBThread.cpp SBThreadCollection.cpp SBThreadPlan.cpp Index: include/lldb/API/SBTargetSettings.h === --- /dev/null +++ include/lldb/API/SBTargetSettings.h @@ -0,0 +1,50 @@ +//===-- SBTargetSettings.h --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLDB_SBTargetSettings_h_ +#define LLDB_SBTargetSettings_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/API/SBTarget.h" +#include "lldb/API/SBError.h" + +namespace lldb { + +class LLDB_API SBTargetSettings { +public: + //-- + // Constructors + //-- + SBTargetSettings(); + + SBTargetSettings(const lldb::SBTarget &sb_target); + + //-- + // Destructor + //-- + ~SBTargetSettings(); + + void AppendImageSearchPath(const char *from, const char *to); + + void AppendImageSearchPath(const char *from, const char *to, SBError &error); + + //size_t GetNumImageSearchPaths() const; + + //const char *GetImageSearchPathAtIndex(size_t i); + +private: + lldb::TargetPropertiesSP m_opaque_sp; +}; + +} // namespace lldb + +#endif // LLDB_SBTargetSettings_h_ Index: include/lldb/A