This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[PATCH] MSP430: Define exit () in C code
- From: Jozef Lawrynowicz <jozef dot l at mittosystems dot com>
- To: newlib at sourceware dot org
- Date: Tue, 8 Oct 2019 12:05:58 +0100
- Subject: [PATCH] MSP430: Define exit () in C code
>From 421a876debc3f370dabb6f702f29aaa730689c64 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Tue, 8 Oct 2019 11:53:44 +0100
Subject: [PATCH] MSP430: Define exit () in C code
The debug information emitted by the GNU assembler is not sufficient for
the TI CCS Debugger to be able to display debug information when we
reach a library functon such as exit ().
This is problematic for exit () in particular, as it is not immediately
obvious whether the program serious malfunctioned or exit () has been
called.
By defining exit () in C code, sufficient debug information is generated
that the TI CCS Debugger can display debug information such as function
name and the call frame.
---
libgloss/msp430/Makefile.in | 1 +
libgloss/msp430/ciosyscalls.S | 8 --------
libgloss/msp430/exit.c | 14 ++++++++++++++
3 files changed, 15 insertions(+), 8 deletions(-)
create mode 100644 libgloss/msp430/exit.c
diff --git a/libgloss/msp430/Makefile.in b/libgloss/msp430/Makefile.in
index 59c11a9a9..f9fe69300 100644
--- a/libgloss/msp430/Makefile.in
+++ b/libgloss/msp430/Makefile.in
@@ -74,6 +74,7 @@ SIM_OBJS = syscalls.o \
NOSYS_OBJS = ciosyscalls.o \
cio.o \
write.o \
+ exit.o \
unlink.o \
sbrk.o
diff --git a/libgloss/msp430/ciosyscalls.S b/libgloss/msp430/ciosyscalls.S
index 889deae9e..32a9ad4ed 100644
--- a/libgloss/msp430/ciosyscalls.S
+++ b/libgloss/msp430/ciosyscalls.S
@@ -46,14 +46,6 @@
.endm
-START_FUNC exit, _exit
- /* For some reason, the board fails to stop at a breakpoint
- placed on top of a software breakpoint instruction. */
-/* MOV.B #0,R3 ; this is a software breakpoint instruction */
-1: br_ #1b
-END_FUNC exit, _exit
-
-
START_FUNC isatty,_isatty
MOV #1,R12
ret_
diff --git a/libgloss/msp430/exit.c b/libgloss/msp430/exit.c
new file mode 100644
index 000000000..0f110dc96
--- /dev/null
+++ b/libgloss/msp430/exit.c
@@ -0,0 +1,14 @@
+/* Implement exit () in C code so we get debugging information when reaching
+ exit in the TI CCS debugger.
+ The debug information emitted by the assembler is not sufficient for
+ any meaningful debug information to be displayed. */
+void __attribute__((naked, weak))
+exit (int status __attribute__((unused)))
+{
+ /* For some reason, the board fails to stop at a breakpoint
+ placed on top of a software breakpoint instruction. */
+ /* __asm__("MOV.B #0,R3") ; this is a software breakpoint instruction */
+ while(1);
+}
+
+void _exit (int) __attribute__((weak, alias ("exit")));
--
2.17.1