Skip to content

Commit 3a98188

Browse files
committed
Teach GDB about more Windows entry points
Windows programs have several conventional entry points depending on various circumstances. Upstream GDB is only aware of "main" and the "start" command behaves poorly or incorrectly otherwise.
1 parent 98a7d85 commit 3a98188

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,9 @@ RUN /libiconv-$LIBICONV_VERSION/configure \
338338
&& make install
339339

340340
WORKDIR /gdb
341-
RUN sed -i 's/quiet = 0/quiet = 1/' /gdb-$GDB_VERSION/gdb/main.c \
341+
COPY src/gdb-*.patch $PREFIX/src/
342+
RUN cat $PREFIX/src/gdb-*.patch | patch -d/gdb-$GDB_VERSION -p1 \
343+
&& sed -i 's/quiet = 0/quiet = 1/' /gdb-$GDB_VERSION/gdb/main.c \
342344
&& /gdb-$GDB_VERSION/configure \
343345
--host=$ARCH \
344346
--with-libexpat-prefix=/deps \

src/gdb-000-alternate-main.patch

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--- a/gdb/symtab.c
2+
+++ b/gdb/symtab.c
3+
@@ -6300,6 +6300,23 @@
4+
if (symbol_found_p)
5+
return;
6+
7+
+ if (gdbarch_osabi (target_gdbarch ()) == GDB_OSABI_WINDOWS)
8+
+ {
9+
+ static const char *const mains[] = {
10+
+ "wmain", "WinMain", "wWinMain", "WinMainCRTStartup", "mainCRTStartup"
11+
+ };
12+
+ for (const char *main : mains)
13+
+ {
14+
+ struct bound_minimal_symbol msym;
15+
+ msym = lookup_minimal_symbol (main, NULL, NULL);
16+
+ if (msym.minsym != NULL)
17+
+ {
18+
+ set_main_name (main, language_unknown);
19+
+ return;
20+
+ }
21+
+ }
22+
+ }
23+
+
24+
set_main_name ("main", language_unknown);
25+
}
26+

0 commit comments

Comments
 (0)