First commit, forked from sourceforge tar

This commit is contained in:
Xavier ASUS 2019-10-29 01:20:21 +01:00
commit 394922bfd2
9 changed files with 7095 additions and 0 deletions

1
README.txt Executable file
View File

@ -0,0 +1 @@
See https://stm8-binutils-gdb.sourceforge.io/ for installation and usage.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,25 @@
From 613571635409f08c9eb0460e011616dd16250ecb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=85ke=20Rehnman?= <ake_rehnman_at_gmail_com>
Date: Sat, 4 Mar 2017 00:06:10 +0100
Subject: [PATCH 2/6] added clear_proceed_status in run_command_1 causing run
command to hang.
---
gdb/infcmd.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 976276b694..2050634c29 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -675,6 +675,7 @@ run_command_1 (const char *args, int from_tty, enum run_how run_how)
/* Start the target running. Do not use -1 continuation as it would skip
breakpoint right at the entry point. */
+ clear_proceed_status (0);
proceed (regcache_read_pc (get_current_regcache ()), GDB_SIGNAL_0);
/* Since there was no error, there's no need to finish the thread
--
2.12.2

View File

@ -0,0 +1,130 @@
From a98428b14d141be893403aa7c7935012aef1f8e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=85ke=20Rehnman?= <ake_rehnman_at_gmail_com>
Date: Sat, 4 Mar 2017 23:47:44 +0100
Subject: [PATCH 3/6] Changed the run functionality to mimic running native
code.
In addition two new remote settings were added to facilitate debugging with
IDE's like eclipse. These settings will make gdb behave like if it is debugging
native code removing the necessity to use remote, load and continue commands.
set remote run-connect on (default is on)
The run-connect setting makes gdb automatically connect to localhost port 3333
(openocd server port) when run command is entered.
set remote run-load on (default is on)
The run-load setting makes gdb automatically load the program when run command
is entered.
# Conflicts:
# gdb/remote.c
---
gdb/remote.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 48 insertions(+), 2 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index a426508723..208bf4609b 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -76,6 +76,9 @@
#include "environ.h"
#include "common/byte-vector.h"
+int remote_run_connect = 1;
+int remote_run_load = 1;
+
/* Per-program-space data key. */
static const struct program_space_data *remote_pspace_data;
@@ -9669,6 +9672,17 @@ Remote replied unexpectedly while setting startup-with-shell: %s"),
extended_remote_set_inferior_cwd (rs);
+ //akre
+ if (remote_run_connect)
+ {
+ ops->to_open("localhost:3333", from_tty);
+ if (remote_run_load)
+ generic_load (exec_file, from_tty);
+ init_thread_list ();
+ run_worked = 0;
+ }
+ else
+ {
/* Now restart the remote server. */
run_worked = extended_remote_run (args) != -1;
if (!run_worked)
@@ -9683,7 +9697,7 @@ Remote replied unexpectedly while setting startup-with-shell: %s"),
/* Fall back to "R". */
extended_remote_restart ();
}
-
+ }
if (!have_inferiors ())
{
/* Clean up from the last time we ran, before we mark the target
@@ -13673,6 +13687,14 @@ Specify the serial device it is connected to\n\
remote_thread_handle_to_thread_info;
}
+//akre
+//
+static int
+extended_remote_can_run (struct target_ops *self)
+{
+ return remote_run_connect;
+}
+
/* Set up the extended remote vector by making a copy of the standard
remote vector and adding to it. */
@@ -13694,6 +13716,9 @@ Specify the serial device it is connected to (e.g. /dev/ttya).";
extended_remote_ops.to_post_attach = extended_remote_post_attach;
extended_remote_ops.to_supports_disable_randomization
= extended_remote_supports_disable_randomization;
+
+ extended_remote_ops.to_can_run
+ = extended_remote_can_run;
}
static int
@@ -13707,7 +13732,11 @@ remote_can_async_p (struct target_ops *ops)
return 0;
/* We're async whenever the serial device is. */
- return serial_can_async_p (rs->remote_desc);
+ //akre check if we have a remote connection
+ if (rs->remote_desc)
+ return serial_can_async_p (rs->remote_desc);
+ else
+ return 0;
}
static int
@@ -13991,6 +14020,23 @@ the packets being used"),
&remote_show_cmdlist, "show remote ",
0 /* allow-unknown */, &showlist);
+//akre
+ add_setshow_boolean_cmd ("run-connect", class_support,
+ &remote_run_connect, _("\
+Enable connecting to localhost:3333 with run command."), _(" \
+Show remote-run-connect."), _(" \
+If set remote target is connected automatically when program is run."),
+ NULL, NULL,
+ &remote_set_cmdlist, &remote_show_cmdlist);
+
+ add_setshow_boolean_cmd ("run-load", class_support,
+ &remote_run_load, _("\
+Enable loading with run command."), _(" \
+Show remote-run-load."), _(" \
+If set remote target is loaded automatically when program is run."),
+ NULL, NULL,
+ &remote_set_cmdlist, &remote_show_cmdlist);
+
add_cmd ("compare-sections", class_obscure, compare_sections_command, _("\
Compare section data on target to the exec file.\n\
Argument is a single section name (default: all loaded sections).\n\
--
2.12.2

View File

@ -0,0 +1,180 @@
From 85f95b1d46d4ab7bff529f9f0de5cc3263a205bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=85ke=20Rehnman?= <ake_rehnman_at_gmail_com>
Date: Sun, 23 Apr 2017 21:26:53 +0200
Subject: [PATCH 4/6] Added --debug option to gas to enable debugging printout
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Åke Rehnman <ake_rehnman_at_gmail_com>
---
gas/config/tc-stm8.c | 58 +++++++++++++++++++++++++++++++++++++---------------
1 file changed, 42 insertions(+), 16 deletions(-)
diff --git a/gas/config/tc-stm8.c b/gas/config/tc-stm8.c
index 84e667278e..1fa4503ce2 100644
--- a/gas/config/tc-stm8.c
+++ b/gas/config/tc-stm8.c
@@ -54,6 +54,7 @@ const char line_separator_chars[] = "{";
int md_short_jump_size = 3;
int md_long_jump_size = 4;
+int stm8_debug = 0;
/* The target specific pseudo-ops which we support. */
/* example:
@@ -95,17 +96,38 @@ md_show_usage (FILE *stream)
fprintf (stream, _("\
STM8 options:\n\
"));
+ fprintf (stream, _("\
+ --debug turn on debug messages\n"));
}
+enum options
+{
+ OPTION_DEBUG = OPTION_MD_BASE + 1,
+};
+
const char *md_shortopts = "";
struct option md_longopts[] =
{
+ { "debug", no_argument, NULL, OPTION_DEBUG },
{NULL, no_argument, NULL, 0}
};
size_t md_longopts_size = sizeof (md_longopts);
+int
+md_parse_option (int c, const char *arg __attribute__((unused)))
+{
+ switch (c)
+ {
+ case OPTION_DEBUG:
+ stm8_debug = 1;
+ return 1;
+ }
+ return 0;
+}
+
+
void
md_begin (void)
{
@@ -228,7 +250,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT segment ATTRIBUTE_UNUSED)
long val = * (long *) valP;
char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
- print_fixup(fixP);
+ if (stm8_debug)
+ print_fixup(fixP);
switch (fixP->fx_r_type)
{
@@ -329,7 +352,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
{
arelent *reloc;
- print_fixup(fixp);
+ if (stm8_debug)
+ print_fixup(fixp);
reloc = XNEW (arelent);
reloc->sym_ptr_ptr = XNEW (asymbol *);
@@ -359,12 +383,6 @@ md_section_align (segT seg, valueT size)
return (size + mask) & ~mask;
}
-int
-md_parse_option (int c __attribute__((unused)), const char *arg __attribute__((unused)))
-{
- return 1;
-}
-
symbolS *
md_undefined_symbol (char *name)
{
@@ -529,7 +547,8 @@ int read_arg_ptr(char *str, expressionS *exps)
}
expression(exps);
- print_expr(exps);
+ if (stm8_debug)
+ print_expr(exps);
/* restore c */
if (p)
@@ -565,7 +584,8 @@ char* toupperstr(char *str);
char* toupperstr(char *str)
{
- for(int i = 0; str[i]; i++){
+ int i;
+ for(i = 0; str[i]; i++){
str[i] = toupper(str[i]);
}
return str;
@@ -591,7 +611,8 @@ int read_arg(char *str, expressionS *exps)
exps->X_md = OP_IMM;
input_line_pointer = str;
expression(exps);
- print_expr(exps);
+ if (stm8_debug)
+ print_expr(exps);
return 1;
}
@@ -654,7 +675,8 @@ int read_arg(char *str, expressionS *exps)
str=strtok(str,",");
input_line_pointer=str;
expression(exps);
- print_expr(exps);
+ if (stm8_debug)
+ print_expr(exps);
exps->X_md=OP_OFF_X;
return 1;
}
@@ -680,7 +702,8 @@ int read_arg(char *str, expressionS *exps)
str=strtok(str,",");
input_line_pointer=str;
expression(exps);
- print_expr(exps);
+ if (stm8_debug)
+ print_expr(exps);
exps->X_md=OP_OFF_X;
return 1;
}
@@ -691,7 +714,8 @@ int read_arg(char *str, expressionS *exps)
str=strtok(str,",");
input_line_pointer=str;
expression(exps);
- print_expr(exps);
+ if (stm8_debug)
+ print_expr(exps);
exps->X_md=OP_OFF_SP;
return 1;
}
@@ -705,7 +729,8 @@ int read_arg(char *str, expressionS *exps)
exps->X_md = OP_SHORTMEM;
input_line_pointer = str;
expression(exps);
- print_expr(exps);
+ if (stm8_debug)
+ print_expr(exps);
*p = c;
input_line_pointer += 6;
return 1;
@@ -713,7 +738,8 @@ int read_arg(char *str, expressionS *exps)
input_line_pointer = str;
expression(exps);
- print_expr(exps);
+ if (stm8_debug)
+ print_expr(exps);
if (exps->X_op == O_register)
{
--
2.12.2

View File

@ -0,0 +1,174 @@
From c5d6641a345485cab823426a5b364a8126e7eda3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=85ke=20Rehnman?= <ake_rehnman_at_gmail_com>
Date: Sun, 23 Apr 2017 21:30:18 +0200
Subject: [PATCH 5/6] Fixed printf formatting warnings Removed target
description registers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Åke Rehnman <ake_rehnman_at_gmail_com>
---
gdb/stm8-tdep.c | 38 ++++++++++++++++++++------------------
1 file changed, 20 insertions(+), 18 deletions(-)
diff --git a/gdb/stm8-tdep.c b/gdb/stm8-tdep.c
index 30b345cfd7..fd4b96c6c0 100644
--- a/gdb/stm8-tdep.c
+++ b/gdb/stm8-tdep.c
@@ -34,7 +34,6 @@
#include "dis-asm.h"
#include "objfiles.h"
#include "target-descriptions.h"
-#include <algorithm>
#include "dwarf2-frame.h"
enum stm8_regnum
@@ -279,7 +278,7 @@ stm8_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
CORE_ADDR pc = *pcptr;
if (stm8_debug)
- fprintf_unfiltered (gdb_stdlog, "stm8_breakpoint_kind_from_pc called %8.8lx\n",pc);
+ fprintf_unfiltered (gdb_stdlog, "stm8_breakpoint_kind_from_pc called %8.8lx\n", (unsigned long)pc);
return 1;
}
@@ -336,19 +335,19 @@ stm8_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
frame_unwind_register (next_frame, STM8_PC_REGNUM, buf);
pc = extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr);
if (stm8_debug)
- fprintf_unfiltered (gdb_stdlog, "stm8_unwind_pc called: pc=%8.8lx\n",pc);
+ fprintf_unfiltered (gdb_stdlog, "stm8_unwind_pc called: pc=%8.8lx\n", (unsigned long)pc);
return pc;
}
static CORE_ADDR
stm8_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
{
- ULONGEST sp;
+ CORE_ADDR sp;
sp = frame_unwind_register_unsigned (next_frame, STM8_SP_REGNUM);
sp = gdbarch_addr_bits_remove (gdbarch, sp);
if (stm8_debug)
- fprintf_unfiltered (gdb_stdlog, "stm8_unwind_sp called: sp=%8.8llx\n",sp);
+ fprintf_unfiltered (gdb_stdlog, "stm8_unwind_sp called: sp=%8.8lx\n", (unsigned long)sp);
return sp;
}
@@ -451,7 +450,7 @@ stm8_get_return_insn (CORE_ADDR pc)
//defaut to RET
if (stm8_debug)
- fprintf_unfiltered(gdb_stdlog, "WARNING: stm8_get_return_insn: No return instruction found in function %s start_addr = %8.8lx end_addr = %8.8lx\n", name, func_addr, func_end);
+ fprintf_unfiltered(gdb_stdlog, "WARNING: stm8_get_return_insn: No return instruction found in function %s start_addr = %8.8lx end_addr = %8.8lx\n", name, (unsigned long)func_addr, (unsigned long)func_end);
return RETURN_RET;
}
@@ -468,7 +467,7 @@ stm8_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
gdb_byte buf[4];
if (stm8_debug)
- fprintf_unfiltered(gdb_stdlog, "stm8_analyze_prologue called (pc=%8.8lx current_pc=%8.8lx)\n",pc,current_pc);
+ fprintf_unfiltered(gdb_stdlog, "stm8_analyze_prologue called (pc=%8.8lx current_pc=%8.8lx)\n", (unsigned long)pc, (unsigned long)current_pc);
/* Initialize info about frame. */
cache->framesize = 0;
@@ -582,7 +581,7 @@ static CORE_ADDR
stm8_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
{
if (stm8_debug)
- fprintf_unfiltered (gdb_stdlog, "stm8_skip_prologue called: start_pc=%8.8lx\n", start_pc);
+ fprintf_unfiltered (gdb_stdlog, "stm8_skip_prologue called: start_pc=%8.8lx\n", (unsigned long)start_pc);
struct symtab_and_line sal;
CORE_ADDR func_start, func_end, ostart_pc;
@@ -605,7 +604,7 @@ stm8_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
&cache);
if (stm8_debug)
- fprintf_unfiltered (gdb_stdlog, "stm8_skip_prologue: start_pc=%8.8lx ostart_pc=%8.8lx\n",start_pc,ostart_pc);
+ fprintf_unfiltered (gdb_stdlog, "stm8_skip_prologue: start_pc=%8.8lx ostart_pc=%8.8lx\n", (unsigned long)start_pc, (unsigned long)ostart_pc);
if (ostart_pc > start_pc)
return ostart_pc;
@@ -629,7 +628,7 @@ static struct stm8_frame_cache *
stm8_frame_cache (struct frame_info *next_frame, void **this_cache)
{
if (stm8_debug)
- fprintf_unfiltered (gdb_stdlog, "stm8_frame_cache called (next_frame=%p)\n",next_frame);
+ fprintf_unfiltered (gdb_stdlog, "stm8_frame_cache called (next_frame=%p)\n", next_frame);
struct stm8_frame_cache *cache;
struct gdbarch *gdbarch = get_frame_arch (next_frame);
@@ -712,7 +711,7 @@ stm8_frame_cache (struct frame_info *next_frame, void **this_cache)
if (stm8_debug)
{
fprintf_unfiltered (gdb_stdlog, "stm8_frame_cache: (next_frame=%p) base=%4.4lx curr_pc=%4.4lx curr_sp=%4.4lx fp_regnum=%d fp=%4.4lx framesize=%4.4x stackadj=%4.4x retsize=%d\n",
- next_frame, cache->base, current_pc, current_sp, cache->fp_regnum, fp, cache->framesize, cache->stackadj, retsize);
+ next_frame, (unsigned long)cache->base, (unsigned long)current_pc, (unsigned long)current_sp, cache->fp_regnum, (unsigned long)fp, cache->framesize, cache->stackadj, retsize);
CORE_ADDR frame_pc;
CORE_ADDR frame_sp;
@@ -729,9 +728,9 @@ stm8_frame_cache (struct frame_info *next_frame, void **this_cache)
frame_fp = fp;
frame_pc = frame_pc >> 16;
- fprintf_unfiltered (gdb_stdlog, "stm8_frame_cache: (next_frame=%p) pc=%8.8llx *pc=%8.8lx\n", next_frame, cache->saved_regs[STM8_PC_REGNUM].addr, frame_pc);
- fprintf_unfiltered (gdb_stdlog, "stm8_frame_cache: (next_frame=%p) sp=%8.8llx *sp=%8.8lx\n", next_frame, cache->saved_regs[STM8_SP_REGNUM].addr, frame_sp);
- fprintf_unfiltered (gdb_stdlog, "stm8_frame_cache: (next_frame=%p) fp=%8.8llx *fp=%8.8lx\n", next_frame, cache->saved_regs[STM8_FP_REGNUM].addr, frame_fp);
+ fprintf_unfiltered (gdb_stdlog, "stm8_frame_cache: (next_frame=%p) pc=%8.8lx *pc=%8.8lx\n", next_frame, (unsigned long)cache->saved_regs[STM8_PC_REGNUM].addr, (unsigned long)frame_pc);
+ fprintf_unfiltered (gdb_stdlog, "stm8_frame_cache: (next_frame=%p) sp=%8.8lx *sp=%8.8lx\n", next_frame, (unsigned long)cache->saved_regs[STM8_SP_REGNUM].addr, (unsigned long)frame_sp);
+ fprintf_unfiltered (gdb_stdlog, "stm8_frame_cache: (next_frame=%p) fp=%8.8lx *fp=%8.8lx\n", next_frame, (unsigned long)cache->saved_regs[STM8_FP_REGNUM].addr, (unsigned long)frame_fp);
}
return (struct stm8_frame_cache *) (*this_cache);
@@ -759,7 +758,7 @@ stm8_frame_this_id (struct frame_info *next_frame, void **this_cache,
(*this_id) = frame_id_build (base, func);
if (stm8_debug)
- fprintf_unfiltered (gdb_stdlog, "stm8_frame_this_id: base=%8.8lx pc=%8.8lx\n",base, func);
+ fprintf_unfiltered (gdb_stdlog, "stm8_frame_this_id: base=%8.8lx pc=%8.8lx\n", (unsigned long)base, (unsigned long)func);
}
static struct value *
@@ -789,7 +788,7 @@ stm8_frame_prev_register (struct frame_info *this_frame,
}
if (stm8_debug)
- fprintf_unfiltered (gdb_stdlog, "stm8_frame_prev_register: regnum(%d)=%8.8llx\n", regnum, value_as_long(value));
+ fprintf_unfiltered (gdb_stdlog, "stm8_frame_prev_register: regnum(%d)=%8.8lx\n", regnum, (unsigned long)value_as_long(value));
return value;
}
@@ -885,7 +884,7 @@ stm8_frame_base_address (struct frame_info *next_frame,
stm8_frame_cache (next_frame, this_cache);
if (stm8_debug)
- fprintf_unfiltered (gdb_stdlog, "stm8_frame_base_address: fb=%8.8lx\n", cache->base);
+ fprintf_unfiltered (gdb_stdlog, "stm8_frame_base_address: fb=%8.8lx\n", (unsigned long)cache->base);
return cache->base;
}
@@ -906,7 +905,7 @@ stm8_frame_args_address (struct frame_info *this_frame, void **this_cache)
addr += 5; //2 bytes fp + 2 bytes pc + 1
if (stm8_debug)
- fprintf_unfiltered (gdb_stdlog, "stm8_frame_args_address: addr = %8.8lx\n",addr);
+ fprintf_unfiltered (gdb_stdlog, "stm8_frame_args_address: addr = %8.8lx\n", (unsigned long)addr);
return addr;
}
@@ -966,6 +965,9 @@ stm8_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
if (tdesc == NULL)
tdesc = tdesc_stm8;
+ //override target registers... /ARE
+ tdesc = tdesc_stm8;
+
/* Check any target description for validity. */
if (tdesc_has_registers (tdesc))
{
--
2.12.2

File diff suppressed because it is too large Load Diff

12
configure_binutils.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
cd binutils-2.30
if [ x$HOST=x"" ]; then
_HOST=$(./config.guess)
else
_HOST=$HOST
fi
if [ x$PREFIX != x"" ]; then
_PREFIX="-prefix=$PREFIX"
fi
./configure --host=$_HOST --target=stm8-none-elf32 $_PREFIX --program-prefix=stm8-

10
patch_binutils.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
wget -nc https://ftp.gnu.org/gnu/binutils/binutils-2.30.tar.xz
wget -nc https://ftp.gnu.org/gnu/gdb/gdb-8.1.tar.xz
mkdir -p binutils-2.30
tar -xvf gdb-8.1.tar.xz --strip-components=1 --directory=binutils-2.30
tar -xvf binutils-2.30.tar.xz
for f in ./binutils_patches/*.patch
do
patch -N -p 1 -d binutils-2.30 <$f
done