Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By cal
#18937 Regarding "scratch registers"

When the gdb stub gets activated by call or exception or ctrl-c it takes a snapshot of cpu state and runs as
a "normal" program. On step etc. it restores state and gives back control.
Makes some things more tricky because of sharing the same hardware.
For example i currently poll the uart instead of using interrupts.
But its fun poking at the memory.
Would be nice if "call"ing functions would work but thats an open gdb issue.
Maybe i use the same trick that the xt-ocd uses and use rcmd for that.

Cal
User avatar
By jcmvbkbc
#18947
cal wrote:Would be nice if "call"ing functions would work but thats an open gdb issue.

I think I've fixed it: https://github.com/jcmvbkbc/binutils-gd ... ffc634e9e4
Pushed the fix to the xtensa-gdb-assertions branch here: https://github.com/jcmvbkbc/binutils-gd ... assertions
Please let me know if it works for you.
User avatar
By cal
#18965
jcmvbkbc wrote:
cal wrote:Would be nice if "call"ing functions would work but thats an open gdb issue.

I think I've fixed it: https://github.com/jcmvbkbc/binutils-gd ... ffc634e9e4
Pushed the fix to the xtensa-gdb-assertions branch here: https://github.com/jcmvbkbc/binutils-gd ... assertions
Please let me know if it works for you.


My remark about an open gdb wasn't meant to push you!
I will test your whole branch.
Maybe I wasn't clear but I applied the same change (without condition) to the esp open sdk version and it just
hung up. Last log message was in my post. You suggested to add an issue for that and i will do it if
needed after building your branch.

Thanks for caring,
Cal
User avatar
By cal
#19026 Moin,

I got xtensa-gdb-assertions branch built.

* the litben issue is fixed.
* "call" seems to have an issue on my stub not continuing properly
* I added angus bt fix and my prologue hack to improve bt
Code: Select alldiff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index 55e7d98..038b967 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -1497,10 +1497,10 @@ xtensa_frame_prev_register (struct frame_info *this_frame,
     }
   else /* Call0 ABI.  */
     {
-      int reg = (regnum >= gdbarch_tdep (gdbarch)->ar_base
-               && regnum <= (gdbarch_tdep (gdbarch)->ar_base
+      int reg = (regnum >= gdbarch_tdep (gdbarch)->a0_base
+               && regnum <= (gdbarch_tdep (gdbarch)->a0_base
                               + C0_NREGS))
-                 ? regnum - gdbarch_tdep (gdbarch)->ar_base : regnum;
+                 ? regnum - gdbarch_tdep (gdbarch)->a0_base : regnum;
 
       if (reg < C0_NREGS)
        {
@@ -2410,7 +2410,7 @@ call0_analyze_prologue (struct gdbarch *gdbarch,
   /* Find out, if we have an information about the prologue from DWARF.  */
   prologue_sal = find_pc_line (start, 0);
   if (prologue_sal.line != 0) /* Found debug info.  */
-    body_pc = prologue_sal.end;
+    body_pc = prologue_sal.end + 6; // TODO: we need real end of prologue even if prologue and method code got mixed!
 
   /* If we are going to analyze the prologue in general without knowing about
      the current PC, make the best assumtion for the end of the prologue.  */


result looks good so far:

Code: Select allGNU gdb (binutils-gdb-xtensa) 7.9.50.20150529-cvs
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-build_unknown-linux-gnu --target=xtensa-lx106-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
gdb_breakpoint () at arch_esp8266.c:20
20      asm("break 0,0");
add symbol table from file "../esp-elf-rom/esp-elf-rom/bootrom.elf" at
   .text_addr = 0x40000000
warning: section .text not found in .../esp-elf-rom/esp-elf-rom/bootrom.elf
(gdb) bt
#0  gdb_breakpoint () at arch_esp8266.c:20
#1  0x4023d215 in nodemcu_init () at user_main.c:276
#2  0x4022817d in __x_wdt_init ()
#3  0x40103ff4 in __x_call_user_start_4 ()
Reply contains invalid hex digit 84
(gdb) disassemble               
Dump of assembler code for function gdb_breakpoint:
=> 0x4025aa38 <+0>:   break   0, 0
   0x4025aa3b <+3>:   ret.n
End of assembler dump.
(gdb) list gdb_breakpoint
15    * gdb_breakpoint - stop program and enter debugger
16    */
17   void gdb_breakpoint() {
18      // do not add code here or automatic breakpoint skipping won't work!
19      // TODO: 0,0 is arbitrary. somewhere was a recommendation?
20      asm("break 0,0");
21   }
22   
23   /**
24    * Copy system specific register struct to gdb layouted


The
Code: Select allReply contains invalid hex digit 84
is an illegal memory access I guess.
I don't check for that yet.
Ignore the strange looking symbols, they are generated.

Thanks,
Carsten