summaryrefslogtreecommitdiffhomepage
path: root/src/dbg.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2023-05-16 22:12:57 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2023-05-16 23:00:24 +0100
commitcba9387c361c3d33dcf1b21ff0e5beb4b0a81ade (patch)
treec3b590a682447959a41c0d90f690e59b23365a3d /src/dbg.c
parent182b36609acc44d3338f64ca3975e1604b50f619 (diff)
Do some pedantic spring cleaning
- Use const in more places where it makes sense - not absolutely everywhere because it can get a bit annoying - Make all the instruction search loops a bit more readable by casting the function pointer into a temporary variable to loop over - Add a few more doc comments and fix a typo or two - Make that RTTI thing flexibly-sized, finally - Don't include gamedata.h in vcall.h for no reason; consequently include gamedata.h in a bunch of places where it was implictly pulled in before - Fix dbg_toghidra() and ent_getedict() having mismatched return types between their headers and respective source files - Remove that one broken, hacky, secret Portal non-feature that probably nobody even ended up using; it can be implemented properly later if required
Diffstat (limited to 'src/dbg.c')
-rw-r--r--src/dbg.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/dbg.c b/src/dbg.c
index 2eb88f6..0db23ec 100644
--- a/src/dbg.c
+++ b/src/dbg.c
@@ -24,7 +24,7 @@
#include "ppmagic.h"
#include "udis86.h"
-void dbg_hexdump(char *name, const void *p, int len) {
+void dbg_hexdump(const char *name, const void *p, int len) {
struct rgba nice_colour = {160, 64, 200, 255}; // a nice purple colour
con_colourmsg(&nice_colour, "Hex dump \"%s\" (%p):", name, p);
for (const uchar *cp = p; cp - (uchar *)p < len; ++cp) {
@@ -38,7 +38,7 @@ void dbg_hexdump(char *name, const void *p, int len) {
con_msg("\n");
}
-void dbg_asmdump(char *name, const void *p, int len) {
+void dbg_asmdump(const char *name, const void *p, int len) {
struct rgba nice_colour = {40, 160, 140, 255}; // a nice teal colour
struct ud udis;
ud_init(&udis);
@@ -52,15 +52,15 @@ void dbg_asmdump(char *name, const void *p, int len) {
}
#ifdef _WIN32
-usize dbg_toghidra(void *addr) {
- void *mod;
+usize dbg_toghidra(const void *addr) {
+ const void *mod;
if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (ushort *)addr,
- (HMODULE *)&mod/*please leave me alone*/)) {
+ (HMODULE *)&mod /* please leave me alone */)) {
con_warn("dbg_toghidra: couldn't get base address\n");
return 0;
}
- return (char *)addr - (char *)mod + 0x10000000;
+ return (const char *)addr - (const char *)mod + 0x10000000;
}
#endif