public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
To: newlib@sourceware.org
Subject: [PATCH] MSP430: Define exit () in C code
Date: Tue, 08 Oct 2019 11:06:00 -0000	[thread overview]
Message-ID: <20191008120558.3f739518@jozef-kubuntu> (raw)

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2: 0001-MSP430-Define-exit-in-C-code.patch --]
[-- Type: text/x-patch, Size: 2539 bytes --]

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


             reply	other threads:[~2019-10-08 11:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-08 11:06 Jozef Lawrynowicz [this message]
2019-10-10 13:21 ` Jozef Lawrynowicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191008120558.3f739518@jozef-kubuntu \
    --to=jozef.l@mittosystems.com \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).