public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Julio Guerra" <julio@farjump.io>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: "Pedro Alves" <palves@redhat.com>
Subject: Re: [PATCH v3] Allow using special files with File I/O functions
Date: Thu, 28 Jun 2018 19:31:00 -0000	[thread overview]
Message-ID: <0102016447dff0f3-e6632e05-1a2c-4e83-9c83-b7ee3c5aa477-000000@eu-west-1.amazonses.com> (raw)
In-Reply-To: <0102016447dcf9e9-3989bcd9-1272-4a05-93c5-77823c7a0921-000000@eu-west-1.amazonses.com>

You can find below the logs of the test I performed using our GDB server with a program embedded in a Raspberry Pi:

 

(gdb) set $st = (struct stat*) malloc(sizeof (struct stat))

(gdb) call stat("/dev/stdout", $st)
$1 = 0x0
(gdb) p *$st
$2 = {
  st_dev = 0x2, 
  st_ino = 0x4, 
  st_mode = 0x2190, 
  st_nlink = 0x1, 
  st_uid = 0x3e8, 
  st_gid = 0x5, 
  st_rdev = 0x8801, 
  st_size = 0x0, 
  st_atime = 0x5b3507e0, 
  st_spare1 = 0x0, 
  st_mtime = 0x5b34fb47, 
  st_spare2 = 0x0, 
  st_ctime = 0x0, 
  st_spare3 = 0x0, 
  st_blksize = 0x0, 
  st_blocks = 0x5b3507e0, 
  st_spare4 = {0x0, 0x0}
}
(gdb) p /o $st->st_mode            
$8 = 020620

(gdb) call stat("myfifo", $st)     
$3 = 0x0
(gdb) p *$st
$4 = {
  st_dev = 0x2, 
  st_ino = 0x4f7c, 
  st_mode = 0x11a4, 
  st_nlink = 0x1, 
  st_uid = 0x3e8, 
  st_gid = 0x3e8, 
  st_rdev = 0x0, 
  st_size = 0x0, 
  st_atime = 0x5b3504ed, 
  st_spare1 = 0x0, 
  st_mtime = 0x5b3504ed, 
  st_spare2 = 0x0, 
  st_ctime = 0x0, 
  st_spare3 = 0x0, 
  st_blksize = 0x0, 
  st_blocks = 0x5b3504ed, 
  st_spare4 = {0x0, 0x0}
}
(gdb) p /o $st->st_mode       
$6 = 010644

(gdb) call stat("/run/dbus/system_bus_socket", $st)  
$9 = 0x0
(gdb) p *$st                                       
$10 = {
  st_dev = 0x2, 
  st_ino = 0x36c7, 
  st_mode = 0xc1b6, 
  st_nlink = 0x1, 
  st_uid = 0x0, 
  st_gid = 0x0, 
  st_rdev = 0x0, 
  st_size = 0x0, 
  st_atime = 0x5b33e995, 
  st_spare1 = 0x0, 
  st_mtime = 0x5b33e995, 
  st_spare2 = 0x0, 
  st_ctime = 0x0, 
  st_spare3 = 0x0, 
  st_blksize = 0x0, 
  st_blocks = 0x5b33e995, 
  st_spare4 = {0x0, 0x0}
}
(gdb) p /o $st->st_mode                            
$11 = 0140666

(gdb) call stat("/tmp", $st)                       
$12 = 0x0
(gdb) p *$st                
$13 = {
  st_dev = 0x2, 
  st_ino = 0x7a5, 
  st_mode = 0x41ff, 
  st_nlink = 0x1, 
  st_uid = 0x0, 
  st_gid = 0x0, 
  st_rdev = 0x0, 
  st_size = 0x0, 
  st_atime = 0x5b350829, 
  st_spare1 = 0x0, 
  st_mtime = 0x5b350829, 
  st_spare2 = 0x0, 
  st_ctime = 0x0, 
  st_spare3 = 0x0, 
  st_blksize = 0x0, 
  st_blocks = 0x5a5a9802, 
  st_spare4 = {0x0, 0x0}
}
(gdb) p /o $st->st_mode     
$14 = 040777

(gdb) call stat("Makefile", $st)
$15 = 0x0
(gdb) p *$st                    
$16 = {
  st_dev = 0x0, 
  st_ino = 0xc6b9, 
  st_mode = 0x81a4, 
  st_nlink = 0x1, 
  st_uid = 0x3e8, 
  st_gid = 0x3e8, 
  st_rdev = 0x0, 
  st_size = 0x0, 
  st_atime = 0x5ae35b23, 
  st_spare1 = 0x0, 
  st_mtime = 0x5b311f46, 
  st_spare2 = 0x0, 
  st_ctime = 0x0, 
  st_spare3 = 0x0, 
  st_blksize = 0x0, 
  st_blocks = 0x5b3500d5, 
  st_spare4 = {0x0, 0x0}
}
(gdb) p /o $st->st_mode         
$17 = 0100644

(gdb) call stat("i dont exist", $st)
$18 = 0xffffffff

(gdb) call fstat(0, $st)
$1 = 0x0
(gdb) p *$st
$3 = {
  st_dev = 0x1, 
  st_ino = 0x0, 
  st_mode = 0x2100, 
  st_nlink = 0x1, 
  st_uid = 0x3e8, 
  st_gid = 0x3e8, 
  st_rdev = 0x0, 
  st_size = 0x0, 
  st_atime = 0x5b35144e, 
  st_spare1 = 0x0, 
  st_mtime = 0x5b35144e, 
  st_spare2 = 0x0, 
  st_ctime = 0x0, 
  st_spare3 = 0x0, 
  st_blksize = 0x0, 
  st_blocks = 0x5b35144e, 
  st_spare4 = {0x0, 0x0}
}

(gdb) call fstat(1, $st)
$4 = 0x0
(gdb) p *$st                                               
$5 = {
  st_dev = 0x1, 
  st_ino = 0x0, 
  st_mode = 0x2080, 
  st_nlink = 0x1, 
  st_uid = 0x3e8, 
  st_gid = 0x3e8, 
  st_rdev = 0x0, 
  st_size = 0x0, 
  st_atime = 0x5b351460, 
  st_spare1 = 0x0, 
  st_mtime = 0x5b351460, 
  st_spare2 = 0x0, 
  st_ctime = 0x0, 
  st_spare3 = 0x0, 
  st_blksize = 0x0, 
  st_blocks = 0x5b351460, 
  st_spare4 = {0x0, 0x0}
}

(gdb) call fstat(2, $st)
$6 = 0x0
(gdb) p *$st            
$7 = {
  st_dev = 0x1, 
  st_ino = 0x0, 
  st_mode = 0x2080, 
  st_nlink = 0x1, 
  st_uid = 0x3e8, 
  st_gid = 0x3e8, 
  st_rdev = 0x0, 
  st_size = 0x0, 
  st_atime = 0x5b35146b, 
  st_spare1 = 0x0, 
  st_mtime = 0x5b35146b, 
  st_spare2 = 0x0, 
  st_ctime = 0x0, 
  st_spare3 = 0x0, 
  st_blksize = 0x0, 
  st_blocks = 0x5b35146b, 
  st_spare4 = {0x0, 0x0}
}

(gdb) call fstat(3, $st)
$8 = 0xffffffff

(gdb) set $fd = open("myfifo", 0)
(gdb) call fstat($fd, $st)       
$10 = 0x0
(gdb) p *$st
$12 = {
  st_dev = 0x2, 
  st_ino = 0x4f7c, 
  st_mode = 0x11a4, 
  st_nlink = 0x1, 
  st_uid = 0x3e8, 
  st_gid = 0x3e8, 
  st_rdev = 0x0, 
  st_size = 0x0, 
  st_atime = 0x5b351511, 
  st_spare1 = 0x0, 
  st_mtime = 0x5b351511, 
  st_spare2 = 0x0, 
  st_ctime = 0x0, 
  st_spare3 = 0x0, 
  st_blksize = 0x0, 
  st_blocks = 0x5b3504ed, 
  st_spare4 = {0x0, 0x0}
}
(gdb) p /o $st->st_mode
$13 = 010644


 ​
 
 

-- 
Julio Guerra
Co-founder & CTO of Farjump
Mobile: +33 618 644 164
LinkedIn: https://linkedin.com/in/guerrajulio
Slack: farjump.slack.com

 

  parent reply	other threads:[~2018-06-28 19:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20180628192635.44056-1-julio@farjump.io>
2018-06-28 19:27 ` Julio Guerra
     [not found]   ` <b725e8cb-4a89-b204-1492-d8af5c76b89f@farjump.io>
2018-06-28 19:31     ` Julio Guerra [this message]
2018-06-29 13:42   ` Pedro Alves
     [not found]     ` <79758ca1-2541-9ae6-d793-b367d6094468@farjump.io>
2018-06-29 14:01       ` Julio Guerra
2018-06-29 14:28         ` Pedro Alves
     [not found]           ` <6ea235bf-bc87-256a-e745-e54f5e97bf5c@farjump.io>
2018-06-29 14:40             ` Julio Guerra
2018-06-29 15:01               ` Pedro Alves
     [not found]                 ` <817850f4-7ee1-6301-2256-a85b7a9edb02@farjump.io>
2018-07-04  9:44                   ` Julio Guerra
2018-07-05 16:50                     ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0102016447dff0f3-e6632e05-1a2c-4e83-9c83-b7ee3c5aa477-000000@eu-west-1.amazonses.com \
    --to=julio@farjump.io \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).