[uClinux-dev] gdbserver kills the shell?

Stuart Hughes stuarth at freescale.com
Fri Oct 7 04:25:37 EDT 2005


John Williams wrote:

>>For the m68knommu platform I'm working on, it doesn't have entries in
>>ptrace.h for: PT_TEXT_ADDR, PT_DATA_ADDR, PT_TEXT_LEN
>>
>>Rather than try to put that into my kernel source, I did it this way:
>>
>>+#if defined(__m68k__)
>>+/********************************************************************
>>+   Note that some architectures define the following in ptrace.h
>>+   For an example see: include/asm-v850/ptrace.h in the kernel
>>+*********************************************************************/
>>+#define PT_TEXT_ADDR 49*4
>>+#define PT_TEXT_LEN  50*4
>>+#define PT_DATA_ADDR 51*4
>>+#endif
>>+
> 
> 
>>I suspect there is a better way of doing it than hard coding the
>>constants in the linux-low.c file, but I couldn't think of a simple way.
> 
> 
> take a look at include/asm-microblaze/ptrace.h - or asm-v850 which I
> based it on.  All you do is define these magic values relative to the
> last "real" one:
> 
> /* These are `magic' values for PTRACE_PEEKUSR that return info about
> where a process is located in memory.  */
> #define PT_TEXT_ADDR    (PT_SIZE + 1)
> #define PT_TEXT_LEN     (PT_SIZE + 2)
> #define PT_DATA_ADDR    (PT_SIZE + 3)
> 
> 

Hi John,

I did see those, I'm having trouble figuring how to compute the value of 
PT_SIZE for m68knommu

I see from include/asm-v850/ptrace.h:

struct pt_regs does not have any #ifdefs.

/* Size of struct pt_regs, including alignment.  */
#define PT_SIZE         ((NUM_GPRS + 6) * _PT_REG_SIZE)
.....
/* The number of bytes used to store each register.  *
#define _PT_REG_SIZE    4
....
#define NUM_GPRS        32

Looking back at the platform I'm working on (m68knommu), I see that 
there are some #ifdefs in the struct pt_regs, so I came up with the idea 
of using 'sizeof(struct pt_regs)'.  The problem is that this comes out 
at 52, which looks plausible, but this differs wildly from the value I 
extracted from the original code (the first space after pt_regs):

#define PT_TEXT_ADDR 49*4  which I extracted from the original code 
which was:

code_start = ptrace (PTRACE_PEEKUSER, inferior_pid,
              (PTRACE_ARG3_TYPE) 49*4, 0);

Can you (or anyone see) why these 2 values are so wildly different (49*4 
= 196 versus 52 for sizeof(pt_regs)).  Clearly the 49*4 value in the 
original seems to work (or did I just get lucky?).

Another slight issue is also that using:

  #define PT_TEXT_ADDR    (PT_SIZE + 1)

etc is that you need to include <asm/ptrace.h> rather than just 
<sys/ptrace.h>, I thought including kernel headers in userspace directly 
was now deprecated ?


Regards, Stuart















More information about the uClinux-dev mailing list