[fix,segfault,when,it,is,working,with,incorrect,debug,info] Skip loop iteration after catch error
Commit Message
From: Maxim Dzabraev <dzabraew@gmail.com>
When compiler generate incorrect debug/symbol information
function value_static_field may raise exception. As far as
function is not finished, we should not use it's returned value,
because it is NULL. After exception gdb print error message and
goto the next iteration.
---
gdb/ChangeLog | 5 +++++
gdb/cp-valprint.c | 1 +
gdb/testsuite/ChangeLog | 5 +++++
gdb/testsuite/gdb.cp/print-regex.cc | 6 ++++++
gdb/testsuite/gdb.cp/print-regex.exp | 33 +++++++++++++++++++++++++++++++++
5 files changed, 50 insertions(+)
create mode 100644 gdb/testsuite/gdb.cp/print-regex.cc
create mode 100644 gdb/testsuite/gdb.cp/print-regex.exp
@@ -1,3 +1,8 @@
+2018-01-19 Maksim Dzabraev <dzabraew@gmail.com>
+
+ * cp-valprint.c (cp_print_value_fields): Execute
+ "continue" in loop iteration if catch error.
+
2017-12-31 Ruslan Kabatsayev <b7.10110111@gmail.com>
* psymtab.c (recursively_search_psymtabs): Use pointer arithmetic
@@ -326,6 +326,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
fprintf_filtered (stream,
_("<error reading variable: %s>"),
ex.message);
+ continue;
}
END_CATCH
@@ -1,3 +1,8 @@
+2018-01-19 Maksim Dzabraev <dzabraew@gmail.com>
+
+ * gdb.cp/print-regex.exp: Test gdb doesn't get segfault
+ when it is printing std::regex.
+
2017-12-27 Stafford Horne <shorne@gmail.com>
* gdb.xml/extra-regs.xml: Add example foo reggroup.
new file mode 100644
@@ -0,0 +1,6 @@
+#include <regex>
+
+int main(void) {
+ std::regex regex("");
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,33 @@
+# Copyright 2018 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+if { [skip_cplus_tests] } { continue }
+
+standard_testfile .cc
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
+ {debug c++ additional_flags="-std=c++17"}]} {
+ return -1
+}
+
+if ![runto_main] then {
+ fail "can't run to main"
+ return 0
+}
+
+# When program is being compiled with gcc 7.2.0 and with -std=c++17
+# and if we try to print std::regex regex("") gdb crashes with segfaul
+gdb_test "print regex" "{.*" "check that gdb did not crash with segfault"