This is the mail archive of the gdb@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]

Re: About the initialization of 'struct linux_record_tdep'


On Fri, Oct 15, 2010 at 00:40, Joseph S. Myers <joseph@codesourcery.com> wrote:
> On Thu, 14 Oct 2010, xingxing pan wrote:
>
>> Hi. I'm just porting the process record function to an ARM similar arch.
>> To initialize the struct linux_record_tdep, one has to collect the
>> size of various types.
>> Is there some way to do this beside diving into the kernel source or
>> system including files?
>> Why not finish the collecting during the configure stage?
>
> You don't generally have target headers available when configuring GDB,
> only those for the host system, and it is also possible that a single GDB
> configuration supports multiple target ABIs (32-bit and 64-bit say).
>
> --
> Joseph S. Myers
> joseph@codesourcery.com
>

I agree with that, for current status, this config didn't need
anything of target linux kernel.

Following part is a file that get the size of some kernel struct, you
can use it to get this size.

Thanks,
Hui

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <sys/times.h>
#include <linux/utsname.h>
#include <ustat.h>
#include <signal.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/sysinfo.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <sys/shm.h>
#include <sys/timex.h>
#include <sys/quota.h>
#include <linux/dqblk_v1.h>
#include <linux/dqblk_v2.h>
#include <linux/dqblk_xfs.h>
#include <time.h>
#include <poll.h>
#include <linux/nfsd/nfsfh.h>
#include <sys/capability.h>
#include <asm/ldt.h>
#include <linux/aio_abi.h>
#include <sys/epoll.h>
#include <mqueue.h>
//#include <termios.h>
#include <asm/termios.h>
//#include <asm/termbits.h>
#include <linux/serial.h>
#include <linux/hayesesp.h>
#define __USE_LARGEFILE64
#include <dirent.h>
#include <sys/vfs.h>
#include <sys/stat.h>
#include <fcntl.h>



struct a__old_kernel_stat {
        unsigned short st_dev;
        unsigned short st_ino;
        unsigned short st_mode;
        unsigned short st_nlink;
        unsigned short st_uid;
        unsigned short st_gid;
        unsigned short st_rdev;
        unsigned int  st_size;
        unsigned int  a;
        unsigned int  b;
        unsigned int  c;
};

int
main(int argc,char *argv[],char *envp[])
{
        printf ("%d\n", sizeof (char *));
        printf ("%d\n", sizeof (struct a__old_kernel_stat));
        printf ("%d\n", sizeof (struct tms));
        printf ("%d\n", sizeof (loff_t));
        printf ("%d\n", sizeof (struct flock));
        printf ("%d\n", sizeof (struct oldold_utsname));
        printf ("%d\n", sizeof (struct ustat));
        printf ("%d\n", sizeof (struct sigaction));
        printf ("%d\n", sizeof (sigset_t));
        printf ("%d\n", sizeof (struct rlimit));
        printf ("%d\n", sizeof (struct rusage));
        printf ("%d\n", sizeof (struct timeval));
        printf ("%d\n", sizeof (struct timezone));
        printf ("%d\n", sizeof (unsigned short));
        printf ("%d\n", sizeof (fd_set));
        printf ("%d\n", sizeof (struct dirent));
        printf ("%d\n", sizeof (struct dirent64));
        printf ("%d\n", sizeof (struct statfs));
        printf ("%d\n", sizeof (struct statfs64));
        printf ("%d\n", sizeof (struct sockaddr));
        printf ("%d\n", sizeof (int));
        printf ("%d\n", sizeof (long));
        printf ("%d\n", sizeof (unsigned long));
        printf ("%d\n", sizeof (struct msghdr));
        printf ("%d\n", sizeof (struct itimerval));
        printf ("%d\n", sizeof (struct stat));
        printf ("%d\n", sizeof (struct old_utsname));
        printf ("%d\n", sizeof (struct sysinfo));
        printf ("%d\n", sizeof (struct msqid_ds));
        printf ("%d\n", sizeof (struct shmid_ds));
        printf ("%d\n", sizeof (struct new_utsname));
        printf ("%d\n", sizeof (struct timex));
        printf ("%d\n", sizeof (struct dqinfo));
        printf ("%d\n", sizeof (struct dqblk));
        printf ("%d\n", sizeof (struct fs_quota_stat));
        printf ("%d\n", sizeof (struct timespec));
        printf ("%d\n", sizeof (struct pollfd));
        printf ("%d\n", sizeof (struct knfsd_fh));
        printf ("%d\n", sizeof (struct sigaction));
        printf ("%d\n", sizeof (sigset_t));
        printf ("%d\n", sizeof (siginfo_t));
        printf ("%d\n", sizeof (cap_user_data_t));
        printf ("%d\n", sizeof (stack_t));
        printf ("%d\n", sizeof (off_t));
        printf ("%d\n", sizeof (struct stat64));
        printf ("%d\n", sizeof (gid_t));
        printf ("%d\n", sizeof (uid_t));
        //printf ("%d\n", sizeof (struct flock64));
        printf ("%d\n", sizeof (struct user_desc));
        printf ("%d\n", sizeof (struct io_event));
        printf ("%d\n", sizeof (struct iocb));
        printf ("%d\n", sizeof (struct epoll_event));
        printf ("%d\n", sizeof (struct itimerspec));
        printf ("%d\n", sizeof (struct mq_attr));
        printf ("%d\n", sizeof (struct siginfo));
        //printf ("%d\n", sizeof (struct termios));
        //printf ("%d\n", sizeof (struct termios2));
        printf ("%d\n", sizeof (pid_t));
        //printf ("%d\n", sizeof (struct winsize));
        printf ("%d\n", sizeof (struct serial_struct));
        printf ("%d\n", sizeof (struct serial_icounter_struct));
        printf ("%d\n", sizeof (struct hayes_esp_config));
        printf ("%d\n", sizeof (size_t));
        printf ("%d\n", sizeof (struct iovec));
        printf ("%x\n", _IOR('T',0x2A, struct termios2));
        printf ("%x\n", _IOW('T',0x2B, struct termios2));
        printf ("%x\n", _IOR('T',0x2C, struct termios2));
        printf ("%x\n", _IOR('T',0x2D, struct termios2));
        printf ("%x\n", _IOR('T',0x30, unsigned int));
        printf ("%x\n", _IOW('T',0x31, int));

        return (0);
}


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