Skip to content

Commit fee115b

Browse files
committed
Adapt gdb interaction exception to cprover style
1 parent b5754c4 commit fee115b

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

src/memory-analyzer/gdb_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ std::string gdb_apit::extract_value(const std::string &line)
268268
std::regex memmory_access_error("Cannot access memory");
269269
if(regex_search(line, memmory_access_error))
270270
{
271-
throw gdb_inaccessible_memoryt("ERROR: " + line);
271+
throw gdb_inaccessible_memory_exceptiont("ERROR: " + line);
272272
}
273273
throw gdb_interaction_exceptiont("Cannot extract value from this: " + line);
274274
}

src/memory-analyzer/gdb_api.h

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,36 @@ class gdb_apit
4242
static gdb_output_recordt parse_gdb_output_record(const std::string &s);
4343
};
4444

45-
class gdb_interaction_exceptiont : public std::exception
45+
class gdb_interaction_exceptiont : public cprover_exception_baset
4646
{
4747
public:
48-
explicit gdb_interaction_exceptiont(std::string reason) : std::exception()
48+
explicit gdb_interaction_exceptiont(std::string reason) : reason(reason)
4949
{
50-
error = reason;
5150
}
52-
const char *what() const throw()
51+
std::string what() const override
5352
{
54-
return error.c_str();
53+
return reason;
5554
}
5655

5756
private:
58-
std::string error;
57+
std::string reason;
5958
};
6059

61-
class gdb_inaccessible_memoryt : public gdb_interaction_exceptiont
60+
class gdb_inaccessible_memory_exceptiont : public cprover_exception_baset
6261
{
6362
public:
64-
explicit gdb_inaccessible_memoryt(std::string reason)
65-
: gdb_interaction_exceptiont(reason)
63+
explicit gdb_inaccessible_memory_exceptiont(std::string reason)
64+
: reason(reason)
6665
{
6766
}
67+
68+
std::string what() const override
69+
{
70+
return reason;
71+
}
72+
73+
private:
74+
std::string reason;
6875
};
6976
#endif
7077
#endif

unit/memory-analyzer/gdb_api.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ SCENARIO(
218218
const std::string line = "Cannot access memory at address 0x71";
219219
THEN("a gdb_inaccesible_memoryt excepition must be raised")
220220
{
221-
REQUIRE_THROWS_AS(gdb_api.extract_value(line), gdb_inaccessible_memoryt);
221+
REQUIRE_THROWS_AS(
222+
gdb_api.extract_value(line), gdb_inaccessible_memory_exceptiont);
222223
}
223224
}
224225

0 commit comments

Comments
 (0)