Skip to content

Commit 484b84a

Browse files
committed
Cumulative fixup
Will be squashed.
1 parent 79d6d09 commit 484b84a

File tree

14 files changed

+36
-23
lines changed

14 files changed

+36
-23
lines changed

regression/snapshot-harness/nondet_initialize_static_arrays/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.c
3-
p --harness-type initialise-with-memory-snapshot --initial-location main:4 --min-null-tree-depth 10 --max-nondet-tree-depth 4 --havoc-variables p
3+
p --harness-type initialise-with-memory-snapshot --initial-goto-location main:4 --min-null-tree-depth 10 --max-nondet-tree-depth 4 --havoc-variables p
44
^EXIT=0$
55
^SIGNAL=0$
66
VERIFICATION SUCCESSFUL

regression/snapshot-harness/pointer-function-parameters-struct-mutual-recursion/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.c
3-
p --harness-type initialise-with-memory-snapshot --initial-location main:4 --havoc-variables p --min-null-tree-depth 10 --max-nondet-tree-depth 3
3+
p --harness-type initialise-with-memory-snapshot --initial-goto-location main:4 --havoc-variables p --min-null-tree-depth 10 --max-nondet-tree-depth 3
44
^SIGNAL=0$
55
^EXIT=0$
66
VERIFICATION SUCCESSFUL

regression/snapshot-harness/pointer-to-array-char/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.c
3-
first,second,array_size --harness-type initialise-with-memory-snapshot --initial-location main:4
3+
first,second,array_size --harness-type initialise-with-memory-snapshot --initial-goto-location main:4
44
^SIGNAL=0$
55
^EXIT=0$
66
VERIFICATION SUCCESSFUL

regression/snapshot-harness/pointer-to-array-function-parameters-multi-arg-right/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.c
3-
first,second,string_size,prefix,prefix_size --harness-type initialise-with-memory-snapshot --initial-location main:4 --havoc-variables prefix,prefix_size --size-of-array prefix:prefix_size --max-array-size 5
3+
first,second,string_size,prefix,prefix_size --harness-type initialise-with-memory-snapshot --initial-goto-location main:4 --havoc-variables prefix,prefix_size --size-of-array prefix:prefix_size --max-array-size 5
44
^SIGNAL=0$
55
^EXIT=0$
66
VERIFICATION SUCCESSFUL

regression/snapshot-harness/pointer-to-array-int/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.c
3-
first,second,array_size,prefix,prefix_size --harness-type initialise-with-memory-snapshot --initial-location main:4 --havoc-variables prefix --size-of-array prefix:prefix_size --max-array-size 4
3+
first,second,array_size,prefix,prefix_size --harness-type initialise-with-memory-snapshot --initial-goto-location main:4 --havoc-variables prefix --size-of-array prefix:prefix_size --max-array-size 4
44
^SIGNAL=0$
55
^EXIT=0$
66
VERIFICATION SUCCESSFUL

regression/snapshot-harness/pointer_07/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.c
3-
p1 --harness-type initialise-with-memory-snapshot --initial-location main:4
3+
p1 --harness-type initialise-with-memory-snapshot --initial-goto-location main:4
44
^EXIT=10$
55
^SIGNAL=0$
66
\[main.assertion.1\] line [0-9]+ assertion p1\[0\] == 1: SUCCESS

regression/snapshot-harness/static-array-char/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.c
3-
tmp,first,second,array_size --harness-type initialise-with-memory-snapshot --initial-location main:4
3+
tmp,first,second,array_size --harness-type initialise-with-memory-snapshot --initial-goto-location main:4
44
^SIGNAL=0$
55
^EXIT=0$
66
VERIFICATION SUCCESSFUL

src/goto-harness/memory_snapshot_harness_generator.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ Author: Daniel Poetzl
2727
#include <linking/static_lifetime_init.h>
2828

2929
#include "goto_harness_generator_factory.h"
30-
#include <algorithm>
3130

3231
void memory_snapshot_harness_generatort::handle_option(
3332
const std::string &option,
@@ -83,7 +82,7 @@ void memory_snapshot_harness_generatort::handle_option(
8382
{
8483
memory_snapshot_file = require_exactly_one_value(option, values);
8584
}
86-
else if(option == MEMORY_SNAPSHOT_HARNESS_INITIAL_LOCATION_OPT)
85+
else if(option == MEMORY_SNAPSHOT_HARNESS_INITIAL_GOTO_LOC_OPT)
8786
{
8887
initial_goto_location_line = require_exactly_one_value(option, values);
8988
}
@@ -96,7 +95,7 @@ void memory_snapshot_harness_generatort::handle_option(
9695
variables_to_havoc.insert(candidate);
9796
}
9897
}
99-
else if(option == "initial-source-location")
98+
else if(option == MEMORY_SNAPSHOT_HARNESS_INITIAL_SOURCE_LOC_OPT)
10099
{
101100
initial_source_location_line = require_exactly_one_value(option, values);
102101
}

src/goto-harness/memory_snapshot_harness_generator_options.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ Author: Diffblue Ltd.
1212
#include "common_harness_generator_options.h"
1313

1414
#define MEMORY_SNAPSHOT_HARNESS_SNAPSHOT_OPT "memory-snapshot"
15-
#define MEMORY_SNAPSHOT_HARNESS_INITIAL_LOCATION_OPT "initial-location"
15+
#define MEMORY_SNAPSHOT_HARNESS_INITIAL_GOTO_LOC_OPT "initial-goto-location"
16+
#define MEMORY_SNAPSHOT_HARNESS_INITIAL_SOURCE_LOC_OPT "initial-source-location"
1617
#define MEMORY_SNAPSHOT_HARNESS_HAVOC_VARIABLES_OPT "havoc-variables"
1718
#define MEMORY_SNAPSHOT_HARNESS_TREAT_POINTER_AS_ARRAY_OPT "pointer-as-array"
1819
#define MEMORY_SNAPSHOT_HARNESS_ASSOCIATED_ARRAY_SIZE_OPT "size-of-array"
1920

2021
// clang-format off
2122
#define MEMORY_SNAPSHOT_HARNESS_GENERATOR_OPTIONS \
2223
"(" MEMORY_SNAPSHOT_HARNESS_SNAPSHOT_OPT "):" \
23-
"(" MEMORY_SNAPSHOT_HARNESS_INITIAL_LOCATION_OPT "):" \
24+
"(" MEMORY_SNAPSHOT_HARNESS_INITIAL_GOTO_LOC_OPT "):" \
25+
"(" MEMORY_SNAPSHOT_HARNESS_INITIAL_SOURCE_LOC_OPT "):" \
2426
"(" MEMORY_SNAPSHOT_HARNESS_HAVOC_VARIABLES_OPT "):" \
2527
"(" MEMORY_SNAPSHOT_HARNESS_TREAT_POINTER_AS_ARRAY_OPT "):" \
2628
"(" MEMORY_SNAPSHOT_HARNESS_ASSOCIATED_ARRAY_SIZE_OPT "):" \
@@ -34,9 +36,12 @@ Author: Diffblue Ltd.
3436
" initialise-from-memory-snapshot)\n\n" \
3537
"--" MEMORY_SNAPSHOT_HARNESS_SNAPSHOT_OPT " <file> initialise memory " \
3638
"from JSON memory snapshot\n" \
37-
"--" MEMORY_SNAPSHOT_HARNESS_INITIAL_LOCATION_OPT " <func[:<n>]>\n" \
39+
"--" MEMORY_SNAPSHOT_HARNESS_INITIAL_GOTO_LOC_OPT " <func[:<n>]>\n" \
3840
" use given function and location number as " \
3941
"entry\n point\n" \
42+
"--" MEMORY_SNAPSHOT_HARNESS_INITIAL_SOURCE_LOC_OPT " <file:<n>>\n" \
43+
" use given file name and line number as " \
44+
"entry\n point\n" \
4045
"--" MEMORY_SNAPSHOT_HARNESS_HAVOC_VARIABLES_OPT " vars initialise" \
4146
" variables from `vars' to\n" \
4247
" non-deterministic values\n" \

src/memory-analyzer/analyze_symbol.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ exprt gdb_value_extractort::get_pointer_value(
420420

421421
// non-member: split for char/non-char
422422
const auto target_expr =
423-
is_c_char(expr.type().subtype())
423+
is_c_char_type(expr.type().subtype())
424424
? get_char_pointer_value(expr, memory_location, location)
425425
: get_non_char_pointer_value(expr, memory_location, location);
426426

@@ -528,7 +528,7 @@ exprt gdb_value_extractort::get_expr_value(
528528
return zero_expr;
529529
const std::string value = *maybe_value;
530530

531-
return from_c_boolean_value(value, type);
531+
return from_c_boolean_value(id2boolean(value), type);
532532
}
533533
else if(type.id() == ID_c_enum)
534534
{
@@ -640,5 +640,8 @@ void gdb_value_extractort::process_outstanding_assignments()
640640

641641
std::string gdb_value_extractort::get_gdb_value(const exprt &expr)
642642
{
643-
return gdb_api.get_value(c_converter.convert(expr));
643+
std::string c_expr = c_converter.convert(expr);
644+
const auto maybe_value = gdb_api.get_value(c_expr);
645+
CHECK_RETURN(maybe_value.has_value());
646+
return *maybe_value;
644647
}

src/memory-analyzer/gdb_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ Author: Malte Mues <[email protected]>
2424
#include <goto-programs/goto_model.h>
2525

2626
#include <util/prefix.h>
27-
#include <util/string_utils.h>
2827
#include <util/string2int.h>
28+
#include <util/string_utils.h>
2929

3030
#include <sys/wait.h>
3131

src/memory-analyzer/gdb_api.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class gdb_apit
6767

6868
struct pointer_valuet
6969
{
70-
pointer_valuet() = delete;
7170
pointer_valuet(
7271
const std::string &address = "",
7372
const std::string &pointee = "",

src/util/c_types_util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ constant_exprt convert_member_name_to_enum_value(
100100
/// Convert id to a Boolean value
101101
/// \param bool_value: A string that is compared to "true" ignoring case.
102102
/// \return a constant of type Boolean
103-
bool id2boolean(const irep_idt &bool_value)
103+
bool id2boolean(const std::string &bool_value)
104104
{
105-
std::string string_value = id2string(bool_value);
105+
std::string string_value = bool_value;
106106
std::transform(
107107
string_value.begin(), string_value.end(), string_value.begin(), ::tolower);
108108
if(string_value == "true")

unit/memory-analyzer/gdb_api.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,16 @@ TEST_CASE("gdb api test", "[core][memory-analyzer]")
167167
const bool r = gdb_api.run_gdb_to_breakpoint("checkpoint");
168168
REQUIRE(r);
169169

170-
REQUIRE(gdb_api.get_value("x") == "8");
171-
REQUIRE(gdb_api.get_value("y") == "2.5");
172-
REQUIRE(gdb_api.get_value("z") == "c");
170+
const auto &x_value = gdb_api.get_value("x");
171+
const auto &y_value = gdb_api.get_value("y");
172+
const auto &z_value = gdb_api.get_value("z");
173+
174+
REQUIRE(x_value.has_value());
175+
REQUIRE(*x_value == "8");
176+
REQUIRE(y_value.has_value());
177+
REQUIRE(*y_value == "2.5");
178+
REQUIRE(z_value.has_value());
179+
REQUIRE(*z_value == "c");
173180
}
174181

175182
SECTION("query pointers")

0 commit comments

Comments
 (0)