public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] rust: Fix rust modules test
@ 2020-07-04  3:59 Daniel Xu
  2020-07-04  6:44 ` Daniel Xu
  2020-07-11 22:14 ` Tom Tromey
  0 siblings, 2 replies; 6+ messages in thread
From: Daniel Xu @ 2020-07-04  3:59 UTC (permalink / raw)
  To: gdb-patches, tom

I noticed that the modules test was failing. Some choice use of `nm`
revealed `TWENTY_THREE` was not in the final binary. Fix by taking a
pointer to the global, forcing the linker to keep the symbol in.

gdb/testsuite/
        * gdb.rust/modules.rs: Prevent linker from discarding test
          symbol

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
---
Changes from V0:
  * Take pointer to global instead. Should be more reliable than using
    the global twice.

 gdb/testsuite/gdb.rust/modules.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.rust/modules.rs b/gdb/testsuite/gdb.rust/modules.rs
index 6db082817b..479e6529cd 100644
--- a/gdb/testsuite/gdb.rust/modules.rs
+++ b/gdb/testsuite/gdb.rust/modules.rs
@@ -60,7 +60,8 @@ pub mod mod1 {
 
                 let f2 = || println!("lambda f2");
 
-                let copy = ::TWENTY_THREE;
+                // Prevent linker from discarding symbol
+                let ptr: *const u16 = &::TWENTY_THREE;
 
                 f2();           // set breakpoint here
                 f3();
-- 
2.27.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] rust: Fix rust modules test
  2020-07-04  3:59 [PATCH] rust: Fix rust modules test Daniel Xu
@ 2020-07-04  6:44 ` Daniel Xu
  2020-07-11 22:14 ` Tom Tromey
  1 sibling, 0 replies; 6+ messages in thread
From: Daniel Xu @ 2020-07-04  6:44 UTC (permalink / raw)
  To: Daniel Xu, gdb-patches, tom

On Fri Jul 3, 2020 at 8:59 PM PDT, Daniel Xu wrote:
> I noticed that the modules test was failing. Some choice use of `nm`
> revealed `TWENTY_THREE` was not in the final binary. Fix by taking a
> pointer to the global, forcing the linker to keep the symbol in.
>
> gdb/testsuite/
> * gdb.rust/modules.rs: Prevent linker from discarding test
> symbol
>
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
> ---
> Changes from V0:

This should have been a "Changes from V1".

And this patch should have veen a V2. Sorry.

[...]


Daniel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] rust: Fix rust modules test
  2020-07-04  3:59 [PATCH] rust: Fix rust modules test Daniel Xu
  2020-07-04  6:44 ` Daniel Xu
@ 2020-07-11 22:14 ` Tom Tromey
  1 sibling, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2020-07-11 22:14 UTC (permalink / raw)
  To: Daniel Xu; +Cc: gdb-patches, tom

>>>>> "Daniel" == Daniel Xu <dxu@dxuuu.xyz> writes:

Daniel> I noticed that the modules test was failing. Some choice use of `nm`
Daniel> revealed `TWENTY_THREE` was not in the final binary. Fix by taking a
Daniel> pointer to the global, forcing the linker to keep the symbol in.

Daniel> gdb/testsuite/
Daniel>         * gdb.rust/modules.rs: Prevent linker from discarding test
Daniel>           symbol

I added the PR, as suggested by Tom, and checked this in.
Thank you for doing this.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] rust: Fix rust modules test
  2020-07-06  9:32 ` Tom de Vries
@ 2020-07-07  5:16   ` Daniel Xu
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Xu @ 2020-07-07  5:16 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches, tom

Hi Tom,

On Mon Jul 6, 2020 at 2:32 AM PDT, Tom de Vries wrote:
> On 7/4/20 5:27 AM, Daniel Xu wrote:
> > I noticed that the modules test was failing. Some choice use of `nm`
> > revealed `TWENTY_THREE` was not in the final binary. Rather than trying
> > to trick the compiler/linker by using magic flags, simply `println!()`
> > the global.
> > 
> > gdb/testsuite/
>
> I cannot judge about the patch itself, but the FAIL was filed as
> PR26121, so please add here: "PR rust/26121".

Sorry about that, didn't know there was an open issue. Will send a V2.

Daniel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] rust: Fix rust modules test
  2020-07-04  3:27 Daniel Xu
@ 2020-07-06  9:32 ` Tom de Vries
  2020-07-07  5:16   ` Daniel Xu
  0 siblings, 1 reply; 6+ messages in thread
From: Tom de Vries @ 2020-07-06  9:32 UTC (permalink / raw)
  To: Daniel Xu, gdb-patches, tom

On 7/4/20 5:27 AM, Daniel Xu wrote:
> I noticed that the modules test was failing. Some choice use of `nm`
> revealed `TWENTY_THREE` was not in the final binary. Rather than trying
> to trick the compiler/linker by using magic flags, simply `println!()`
> the global.
> 
> gdb/testsuite/

I cannot judge about the patch itself, but the FAIL was filed as
PR26121, so please add here: "PR rust/26121".

Thanks,
- Tom

>         * gdb.rust/modules.rs: Prevent linker from discarding test
>           symbol
> 
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
> ---
>  gdb/testsuite/gdb.rust/modules.rs | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/gdb/testsuite/gdb.rust/modules.rs b/gdb/testsuite/gdb.rust/modules.rs
> index 6db082817b..dc2a469b2f 100644
> --- a/gdb/testsuite/gdb.rust/modules.rs
> +++ b/gdb/testsuite/gdb.rust/modules.rs
> @@ -93,4 +93,7 @@ pub mod mod1 {
>  
>  fn main () {
>      mod1::inner::innest::f1();
> +
> +    // Prevent linker from discarding `TWENTY_THREE`
> +    println!("{}", TWENTY_THREE);
>  }
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] rust: Fix rust modules test
@ 2020-07-04  3:27 Daniel Xu
  2020-07-06  9:32 ` Tom de Vries
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Xu @ 2020-07-04  3:27 UTC (permalink / raw)
  To: gdb-patches, tom

I noticed that the modules test was failing. Some choice use of `nm`
revealed `TWENTY_THREE` was not in the final binary. Rather than trying
to trick the compiler/linker by using magic flags, simply `println!()`
the global.

gdb/testsuite/
        * gdb.rust/modules.rs: Prevent linker from discarding test
          symbol

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
---
 gdb/testsuite/gdb.rust/modules.rs | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gdb/testsuite/gdb.rust/modules.rs b/gdb/testsuite/gdb.rust/modules.rs
index 6db082817b..dc2a469b2f 100644
--- a/gdb/testsuite/gdb.rust/modules.rs
+++ b/gdb/testsuite/gdb.rust/modules.rs
@@ -93,4 +93,7 @@ pub mod mod1 {
 
 fn main () {
     mod1::inner::innest::f1();
+
+    // Prevent linker from discarding `TWENTY_THREE`
+    println!("{}", TWENTY_THREE);
 }
-- 
2.27.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-07-11 22:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-04  3:59 [PATCH] rust: Fix rust modules test Daniel Xu
2020-07-04  6:44 ` Daniel Xu
2020-07-11 22:14 ` Tom Tromey
  -- strict thread matches above, loose matches on Subject: below --
2020-07-04  3:27 Daniel Xu
2020-07-06  9:32 ` Tom de Vries
2020-07-07  5:16   ` Daniel Xu

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).