Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Debugger] windows debugger and process drawable #953

Merged
merged 30 commits into from
Oct 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c21bc01
Update assert.h
ManDude Oct 24, 2021
599ee34
stuff for `process-drawable` to work
ManDude Oct 24, 2021
0b76734
add windows code for debugger
ManDude Oct 24, 2021
464f16a
debugger attaches
ManDude Oct 24, 2021
3c92555
something works
ManDude Oct 25, 2021
49af7ab
remove bad ideas
ManDude Oct 25, 2021
6590070
`(:break)` works
ManDude Oct 25, 2021
321921e
connection fixes
ManDude Oct 25, 2021
ea42bbd
fixes + update docs
ManDude Oct 25, 2021
105ef37
crates & `defskelgroup` macro
ManDude Oct 25, 2021
47dd89d
clang
ManDude Oct 25, 2021
b5ccc83
update tests and a few types
ManDude Oct 26, 2021
408a743
temp
ManDude Oct 27, 2021
2c90428
temp
ManDude Oct 27, 2021
d659ef5
fix files
ManDude Oct 27, 2021
662f519
game builds
ManDude Oct 27, 2021
1dc232a
reverse TypeConsistency operation
ManDude Oct 27, 2021
2b28be9
Merge branch 'master' into d/windows-debugger-and-process-drawable
ManDude Oct 27, 2021
a973b09
add eye stuff for merc art login
ManDude Oct 27, 2021
7723393
add `(:sym-name)`
ManDude Oct 27, 2021
f9780ad
oops
ManDude Oct 27, 2021
284973e
add `--auto-dbg` option to gc args
ManDude Oct 27, 2021
5cbafca
codacy
ManDude Oct 27, 2021
c62389f
improve robustness of dgo unpacker and objectfiledb reading
ManDude Oct 27, 2021
04a511e
`cavegeyserrock`
ManDude Oct 27, 2021
ef4e375
hopefully fix linux
ManDude Oct 27, 2021
141100a
windows FormatMessage weirdness?
ManDude Oct 27, 2021
463d388
mutex fixes
ManDude Oct 29, 2021
8f180a2
Merge branch 'master' into d/windows-debugger-and-process-drawable
ManDude Oct 30, 2021
8f762b7
fix merge conflicts
water111 Oct 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
350 changes: 330 additions & 20 deletions common/cross_os_debug/xdbg.cpp

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions common/cross_os_debug/xdbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#ifdef __linux
#include <sys/types.h>
#elif _WIN32
// todo - windows includes
#define NOMINMAX
#include <Windows.h>
#endif

namespace xdbg {
Expand All @@ -40,15 +41,16 @@ struct MemoryHandle {

#elif _WIN32
struct ThreadID {
// todo - whatever windows uses to identify a thread
DWORD pid = 0;
DWORD tid = 0;

std::string to_string() const;
ThreadID(const std::string& str);
ThreadID(); // todo - add id type here, like in linux version
ThreadID(DWORD pid, DWORD tid);
ThreadID() = default;
};

struct MemoryHandle {
int a;
};
struct MemoryHandle {};
#endif

/*!
Expand Down Expand Up @@ -86,8 +88,12 @@ struct SignalInfo {
ILLEGAL_INSTR, // bad instruction
UNKNOWN, // some other signal that is unsupported
DISAPPEARED, // process disappeared (maybe killed by the user)
NOTHING, // nothing of importance. Windows sends many irrelevant (to us) events
EXCEPTION, // some unhandled exception

} kind = UNKNOWN;

std::string msg;
};

// Functions
Expand Down
8 changes: 5 additions & 3 deletions common/util/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@

#if defined NDEBUG && defined _WIN32

#define _OLD_NDEBUG NDEBUG
#pragma push_macro("NDEBUG")

#undef NDEBUG
#undef assert
#include <cassert>
#define NDEBUG _OLD_NDEBUG

#undef _OLD_NDEBUG
#pragma pop_macro("NDEBUG")

#else

#include <cassert>

#endif

#define ASSERT assert
6 changes: 5 additions & 1 deletion decompiler/ObjectFile/ObjectFileDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ ObjectFileDB::ObjectFileDB(const std::vector<std::string>& _dgos,

lg::info("-Loading {} DGOs...", _dgos.size());
for (auto& dgo : _dgos) {
get_objs_from_dgo(dgo, config);
try {
get_objs_from_dgo(dgo, config);
} catch (std::runtime_error& e) {
lg::warn("Error when reading DGOs: {}", e.what());
}
}

lg::info("-Loading {} plain object files...", object_files.size());
Expand Down
10 changes: 5 additions & 5 deletions decompiler/analysis/final_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ std::string write_from_top_level_form(Form* top_form,
if (!something_matched) {
auto debug_match_result = match(defun_debug_matcher, &f);
if (debug_match_result.matched) {
auto first_name = debug_match_result.maps.strings.at(0);
auto second_name = debug_match_result.maps.strings.at(2);
auto& first_name = debug_match_result.maps.strings.at(0);
auto& second_name = debug_match_result.maps.strings.at(2);
if (first_name == second_name) {
auto func = file.try_get_function_at_label(debug_match_result.maps.label.at(1));
if (func) {
Expand All @@ -400,7 +400,7 @@ std::string write_from_top_level_form(Form* top_form,
auto define_match_result = match(define_symbol_matcher, &f);
if (define_match_result.matched) {
something_matched = true;
auto sym_name = define_match_result.maps.strings.at(0);
auto& sym_name = define_match_result.maps.strings.at(0);
auto symbol_type = dts.lookup_symbol_type(sym_name);
result +=
fmt::format(";; definition for symbol {}, type {}\n", sym_name, symbol_type.print());
Expand All @@ -419,7 +419,7 @@ std::string write_from_top_level_form(Form* top_form,
define_perm_match_result.maps.strings.at(0) ==
define_perm_match_result.maps.strings.at(2)) {
something_matched = true;
auto sym_name = define_perm_match_result.maps.strings.at(0);
auto& sym_name = define_perm_match_result.maps.strings.at(0);
auto symbol_type = dts.lookup_symbol_type(sym_name);

result += fmt::format(";; definition (perm) for symbol {}, type {}\n", sym_name,
Expand Down Expand Up @@ -500,4 +500,4 @@ std::string write_from_top_level(const Function& top_level,

return write_from_top_level_form(top_form, dts, file, skip_functions, env);
}
} // namespace decompiler
} // namespace decompiler
Loading