This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/18506] New: The ISA mode of mips16 maybe changed by calling a function in GDB console by hand


https://sourceware.org/bugzilla/show_bug.cgi?id=18506

            Bug ID: 18506
           Summary: The ISA mode of mips16 maybe changed by calling a
                    function in GDB console by hand
           Product: gdb
           Version: 7.9
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: ggs334 at 163 dot com
  Target Milestone: ---

some times we want to call a function in GDB by hand,and GDB will create a
dummy frame for that function. when the function finished, it needs return to
the caller, so GDB will set a return location in ra (for mips, the return
location is ON_STACK, and the location address doesn't include ISA mode bit). 
When we do this on a mips16 target, when the function finished, and cpu try to
execute the instruction: 
jr      ra
as the address in ra without ISA mode bit, cpu will swith to mips mode.

Please look this log:
Breakpoint 1, main ()
    at
/home/guosheng_gao/repo/debugger/gdb-7.9/gdb/testsuite/gdb.base/call-sc.c:58
58        Fun(foo);
(gdb) set debug remote 1
(gdb) p /c fun()
Sending packet: $p102#03...Packet received: deadbeef
Packet p (fetch-register) is supported
.................
.................
Sending packet: $p123#06...Packet received: deadbeef
Sending packet: $X800fff98,4:\000\000\000\000#2d...Packet received: OK
Sending packet: $X800fff9c,2:ÃÂ#e3...Packet received: OK
Sending packet: $P19=8000114d#b9...Packet received: OK

Sending packet: $P1f=800fff9c#8b...Packet received: OK

-----look, GDB try to set a return location for ra, but this address without
ISA -----mode bit.

Sending packet: $P1d=800fff90#55...Packet received: OK
Sending packet: $m800fff9a,2#2f...Packet received: 0000
Sending packet: $m800fff98,2#06...Packet received: 0000
Sending packet: $P25=8000114d#b6...Packet received: OK
Sending packet: $Z0,800011ba,2#01...Packet received: OK
Sending packet: $Z0,800fff9c,2#7a...Packet received: OK

Sending packet: $vCont;c#a8...Packet received: T0525:800fff9d;1d:800fff90;

-----look, the remote target returns stop location without ISA bit mode,cpu 
-----have swithed to mips32 

Sending packet: $qL1200000000000000000#50...Packet received:
Sending packet: $z0,800011ba,2#21...Packet received: OK
Sending packet: $z0,800fff9c,2#9a...Packet received: OK
........................
........................
Sending packet: $p123#06...Packet received: deadbeef
Sending packet: $P2=00000000#3f...Packet received: OK
Sending packet: $P18=00000001#77...Packet received: OK
Sending packet: $P1d=800fffa8#85...Packet received: OK
Sending packet: $P1f=8000127f#ec...Packet received: OK
Sending packet: $P25=800011bb#e2...Packet received: OK
$1 = 49 '1'
(gdb) disassemble fun
Dump of assembler code for function fun:
Sending packet: $m80001140,40#8b...Packet received:
63fd620597056303ef00650063ffd101673db207651a67588240651a6758651a675865b991016301e82065008000347063ffd101673d651c6758c148b305651b
   0x8000114d <+11>:    addiu   sp,-8
   0x8000114f <+1>:     sw      s1,4(sp)
   0x80001151 <+3>:     move    s1,sp
   0x80001153 <+5>:     lw      v0,0x8000116c <fun+31>
   0x80001155 <+7>:     move    t8,v0
   0x80001157 <+9>:     move    v0,t8
   0x80001159 <+11>:    lb      v0,0(v0)
   0x8000115b <+13>:    move    t8,v0
   0x8000115d <+15>:    move    v0,t8
   0x8000115f <+17>:    move    t8,v0
   0x80001161 <+19>:    move    v0,t8
   0x80001163 <+21>:    move    sp,s1
   0x80001165 <+23>:    lw      s1,4(sp)
   0x80001167 <+25>:    addiu   sp,8

   0x80001169 <+27>:    jr      ra

-----in fact this inst change the cpu ISA mode.

   0x8000116b <+29>:    nop
   0x8000116d <+31>:    lb      s0,0(s0)
   0x8000116f <+33>:    sll     a0,v1,4
End of assembler dump.

So I think we must add the ISA mode to the return location.

We can add this in the function
static CORE_ADDR
mips_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
                      CORE_ADDR funaddr, struct value **args,
                      int nargs, struct type *value_type,
                      CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
                      struct regcache *regcache)
{
...................
...................
  /*
   * I think we can add the ISA bit mode according to current pc.
   * (The location where we call the function).
   */
  if (mips_pc_is_mips16 (gdbarch, regcache_read_pc (regcache)))
    *bp_addr = make_compact_addr (*bp_addr);

...................
...................

  return sp;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]