* [PATCH] Allow subscripting raw pointers
@ 2016-07-04 12:42 Manish Goregaokar
2016-07-05 17:20 ` Tom Tromey
0 siblings, 1 reply; 4+ messages in thread
From: Manish Goregaokar @ 2016-07-04 12:42 UTC (permalink / raw)
To: gdb-patches, Tom Tromey
This will be useful for dealing with vectors; regardless of our final solution
for the Index trait.
Right now subscripting vectors requires dancing between C and Rust mode.
2016-07-04 Manish Goregaokar <manish@mozilla.com>
gdb/ChangeLog:
* rust-lang.c (rust_subscript): Allow subscripting pointers
gdb/testsuite/ChangeLog:
* simple.rs: Add test for raw pointer subscripting
* simple.exp: Add test expectations
---
gdb/rust-lang.c | 6 ++++++
gdb/testsuite/gdb.rust/simple.exp | 1 +
gdb/testsuite/gdb.rust/simple.rs | 1 +
3 files changed, 8 insertions(+)
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 1849349..17b20c6 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1415,6 +1415,12 @@ rust_subscript (struct expression *exp, int
*pos, enum noside noside,
low_bound = 0;
high_bound = value_as_long (len);
}
+ else if (TYPE_CODE (type) == TYPE_CODE_PTR)
+ {
+ base = lhs;
+ low_bound = 0;
+ high_bound = LONGEST_MAX;
+ }
else
error (_("Cannot subscript non-array type"));
diff --git a/gdb/testsuite/gdb.rust/simple.exp
b/gdb/testsuite/gdb.rust/simple.exp
index 4622f75..32b3785 100644
--- a/gdb/testsuite/gdb.rust/simple.exp
+++ b/gdb/testsuite/gdb.rust/simple.exp
@@ -73,6 +73,7 @@ gdb_test "print w" " = \\\[1, 2, 3, 4\\\]"
gdb_test "ptype w" " = \\\[i32; 4\\\]"
gdb_test "print w\[2\]" " = 3"
gdb_test "print w\[2\] @ 2" " = \\\[3, 4\\\]"
+gdb_test "print w_ptr\[2\]" " = 3"
gdb_test "print fromslice" " = 3"
gdb_test "print slice\[0\]" " = 3"
gdb_test "print slice as &\[i32\]\[0\]" " = 3"
diff --git a/gdb/testsuite/gdb.rust/simple.rs b/gdb/testsuite/gdb.rust/simple.rs
index 3d28e27..4980826 100644
--- a/gdb/testsuite/gdb.rust/simple.rs
+++ b/gdb/testsuite/gdb.rust/simple.rs
@@ -87,6 +87,7 @@ fn main () {
let v = Something::Three;
let w = [1,2,3,4];
+ let w_ptr = &w[0];
let x = (23, 25.5);
let y = HiBob {field1: 7, field2: 8};
let z = ByeBob(7, 8);
--
2.8.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow subscripting raw pointers
2016-07-04 12:42 [PATCH] Allow subscripting raw pointers Manish Goregaokar
@ 2016-07-05 17:20 ` Tom Tromey
2016-07-05 17:32 ` Manish Goregaokar
0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2016-07-05 17:20 UTC (permalink / raw)
To: Manish Goregaokar; +Cc: gdb-patches, Tom Tromey
>>>>> "Manish" == Manish Goregaokar <manish@mozilla.com> writes:
Manish> 2016-07-04 Manish Goregaokar <manish@mozilla.com>
Manish> gdb/ChangeLog:
Manish> * rust-lang.c (rust_subscript): Allow subscripting pointers
Manish> gdb/testsuite/ChangeLog:
Manish> * simple.rs: Add test for raw pointer subscripting
Manish> * simple.exp: Add test expectations
This is ok. Thanks.
Manish> + else if (TYPE_CODE (type) == TYPE_CODE_PTR)
Manish> + {
Manish> + base = lhs;
Manish> + low_bound = 0;
Manish> + high_bound = LONGEST_MAX;
Manish> + }
Manish> else
I suspect maybe your MUA is misconfigured somehow? Your patches often
come out looking like the indentation is messed up; but in this case the
context makes it clear that the indentation is probably ok.
Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow subscripting raw pointers
2016-07-05 17:20 ` Tom Tromey
@ 2016-07-05 17:32 ` Manish Goregaokar
2016-07-05 17:39 ` Trevor Saunders
0 siblings, 1 reply; 4+ messages in thread
From: Manish Goregaokar @ 2016-07-05 17:32 UTC (permalink / raw)
Cc: gdb-patches, Tom Tromey
I am using git format-patch and pasting it into GMail text mode. Probably should set up mutt; haven't yet because I was behind a port-blocked university connection for years :)
I'll see what I can do.
Tom Tromey wrote:
> Manish> 2016-07-04 Manish Goregaokar <manish@mozilla.com>
> Manish> gdb/ChangeLog:
> Manish> * rust-lang.c (rust_subscript): Allow subscripting pointers
> Manish> gdb/testsuite/ChangeLog:
> Manish> * simple.rs: Add test for raw pointer subscripting
> Manish> * simple.exp: Add test expectations
>
> This is ok. Thanks.
>
> Manish> + else if (TYPE_CODE (type) == TYPE_CODE_PTR)
> Manish> + {
> Manish> + base = lhs;
> Manish> + low_bound = 0;
> Manish> + high_bound = LONGEST_MAX;
> Manish> + }
> Manish> else
>
> I suspect maybe your MUA is misconfigured somehow? Your patches often
> come out looking like the indentation is messed up; but in this case the
> context makes it clear that the indentation is probably ok.
>
> Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow subscripting raw pointers
2016-07-05 17:32 ` Manish Goregaokar
@ 2016-07-05 17:39 ` Trevor Saunders
0 siblings, 0 replies; 4+ messages in thread
From: Trevor Saunders @ 2016-07-05 17:39 UTC (permalink / raw)
To: Manish Goregaokar; +Cc: gdb-patches, Tom Tromey
On Tue, Jul 05, 2016 at 10:32:38AM -0700, Manish Goregaokar wrote:
> I am using git format-patch and pasting it into GMail text mode. Probably should set up mutt; haven't yet because I was behind a port-blocked university connection for years :)
fwiw while people usually block 25 I don't think I've ever seen someone
block 587.
> I'll see what I can do.
you might want to try git send-email if your going to make gmail handle
outbound smtp for you already.
Trev
>
> Tom Tromey wrote:
> > Manish> 2016-07-04 Manish Goregaokar <manish@mozilla.com>
> > Manish> gdb/ChangeLog:
> > Manish> * rust-lang.c (rust_subscript): Allow subscripting pointers
> > Manish> gdb/testsuite/ChangeLog:
> > Manish> * simple.rs: Add test for raw pointer subscripting
> > Manish> * simple.exp: Add test expectations
> >
> > This is ok. Thanks.
> >
> > Manish> + else if (TYPE_CODE (type) == TYPE_CODE_PTR)
> > Manish> + {
> > Manish> + base = lhs;
> > Manish> + low_bound = 0;
> > Manish> + high_bound = LONGEST_MAX;
> > Manish> + }
> > Manish> else
> >
> > I suspect maybe your MUA is misconfigured somehow? Your patches often
> > come out looking like the indentation is messed up; but in this case the
> > context makes it clear that the indentation is probably ok.
> >
> > Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-07-05 17:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-04 12:42 [PATCH] Allow subscripting raw pointers Manish Goregaokar
2016-07-05 17:20 ` Tom Tromey
2016-07-05 17:32 ` Manish Goregaokar
2016-07-05 17:39 ` Trevor Saunders
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox