Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Gary Benson <gbenson@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] linux: Add maintenance commands to test libthread_db
Date: Thu, 23 Nov 2017 13:22:00 -0000	[thread overview]
Message-ID: <5e445a82-3238-b4d7-16c5-7e2f079ba453@redhat.com> (raw)
In-Reply-To: <1511361761-1333-1-git-send-email-gbenson@redhat.com>

On 11/22/2017 02:42 PM, Gary Benson wrote:

> 
> Built and regtested on RHEL 7.4 x86_64.
> 
> Ok to commit?

I noticed you're missing a NEWS entry.

Some more comments below.

> +static int
> +check_thread_db_callback (const td_thrhandle_t *th, void *arg)
> +{
> +  gdb_assert (tdb_testinfo != NULL);
> +  tdb_testinfo->threads_seen = true;
> +
> +#define LOG(fmt, args...)						\
> +  do									\
> +    {									\
> +      if (tdb_testinfo->log_progress)					\
> +	{								\
> +	  debug_printf (fmt, ## args);					\
> +	  gdb_flush (gdb_stdlog);					\
> +	}								\
> +    }									\
> +  while (0)
> +
> +#define __CHECK(expr, args...)						\

Symbols that start with __ are reserved for the C/C++ implementation.

(E.g., glibc would be in the right to define it in some header
for its own purposes).

You can rename it to CHECK_1 or something like that.

> +  do									\
> +    {									\
> +      if (!(expr))							\
> +	{								\
> +	  LOG (" ... FAIL!\n");						\
> +	  error (args);							\
> +	}								\
> +    }									\
> +  while (0)
> +
> +#define CHECK(expr)							\
> +  __CHECK (expr, "(%s) == false", #expr)
> +
> +#define CHECK_CALL(func, args...)					\
> +  do									\
> +    {									\
> +      td_err_e __err = tdb_testinfo->info->func ## _p (args);		\
> +									\
> +      __CHECK (__err == TD_OK, _("%s failed: %s"), #func,		\
> +	       thread_db_err_str (__err));				\

Likewise __err.

> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +# This test only works for native processes on Linux.

GNU/Linux, because glibc.

> +if { ![isnative] || [is_remote host] || [target_info exists use_gdb_stub]
> +     || ![istarget *-linux*] } {
> +    continue

I think this fails to filter out --target_board=native-extended-gdbserver ?

This would be more to the point, and would work, I think (haven't tested):

# This test only works for native processes on GNU/Linux.
if {[target_info gdb_protocol] != "" || ![istarget *-linux*]} {
   continue
}


> +}
> +
> +standard_testfile
> +
> +if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
> +	 executable debug] != "" } {
> +    return -1
> +}
> +
> +# TEST 1: Manual check with libthread_db not loaded.

Please remove the numbering in "TEST 1", etc.  We have a few old
testcases that have comments like that, and over the years as tests
are added/removed to the file, the numbering gets annoyingly in the
way / odd, when inevitably in the future we want to insert a
test in the middle, remove or reorder tests, etc.

> +
> +clean_restart ${binfile}
> +
> +gdb_test "maint show check-libthread-db" \
> +    "Whether to check libthread_db at load time is off."
> +
> +gdb_test_no_output "set stop-on-solib-events 1"
> +gdb_run_cmd
> +gdb_test "" \
> +    ".*Stopped due to shared library event.*no libraries added or removed.*"
> +
> +gdb_test "maint check libthread-db" \
> +    "No libthread_db loaded" \
> +    "libpthread.so not loaded"
> +
> +
> +# TEST 2: Manual check with NPTL uninitialized.
> +# libthread_db should fake a single thread with th_unique == NULL.
> +
> +gdb_test "continue" \
> +    ".*Stopped due to shared library event.*Inferior loaded .*libpthread.*"
> +
> +gdb_test_sequence "maint check libthread-db" \
> +    "libpthread.so not initialized (manual)" {
> +	"\[\r\n\]+Running libthread_db integrity checks:"
> +	"\[\r\n\]+\[ \]+Got thread 0x0 => \[0-9\]+ => 0x0 ... OK"
> +	"\[\r\n\]+libthread_db integrity checks passed."
> +    }
> +
> +
> +# TEST 3: Manual check with NPTL fully operational.
> +
> +gdb_test_no_output "set stop-on-solib-events 0"
> +gdb_breakpoint break_here
> +gdb_continue_to_breakpoint break_here
> +
> +gdb_test_sequence "maint check libthread-db" \
> +    "libpthread.so fully initialized (manual)" {
> +	"\[\r\n\]+Running libthread_db integrity checks:"
> +	"\[\r\n\]+\[ \]+Got thread 0x\[1-9a-f\]\[0-9a-f\]+ => \[0-9\]+ => 0x\[1-9a-f\]\[0-9a-f\]+; errno = 23 ... OK"
> +	"\[\r\n\]+\[ \]+Got thread 0x\[1-9a-f\]\[0-9a-f\]+ => \[0-9\]+ => 0x\[1-9a-f\]\[0-9a-f\]+; errno = 42 ... OK"
> +	"\[\r\n\]+libthread_db integrity checks passed."
> +    }
> +
> +
> +# TEST 4: Automated check with NPTL uninitialized.
> +
> +clean_restart ${binfile}
> +
> +gdb_test_no_output "maint set check-libthread-db 1"
> +gdb_test_no_output "set debug libthread-db 1"
> +gdb_breakpoint break_here
> +gdb_run_cmd
> +
> +gdb_test_sequence "" \
> +    "libpthread.so not initialized (automated)" {
> +	"\[\r\n\]+Running libthread_db integrity checks:"
> +	"\[\r\n\]+\[ \]+Got thread 0x0 => \[0-9\]+ => 0x0 ... OK"
> +	"\[\r\n\]+libthread_db integrity checks passed."
> +	"\[\r\n\]+[Thread debugging using libthread_db enabled]"
> +    }
> +
> +
> +# TEST 5: Automated check with NPTL fully operational.
> +
> +clean_restart ${binfile}
> +
> +gdb_test_no_output "maint set check-libthread-db 1"
> +gdb_test_no_output "set debug libthread-db 1"
> +
> +set test_spawn_id [spawn_wait_for_attach $binfile]
> +set testpid [spawn_id_get_pid $test_spawn_id]
> +
> +gdb_test_sequence "attach $testpid" \
> +    "libpthread.so fully initialized (automated)" {
> +	"\[\r\n\]+Running libthread_db integrity checks:"
> +	"\[\r\n\]+\[ \]+Got thread 0x\[1-9a-f\]\[0-9a-f\]+ => \[0-9\]+ => 0x\[1-9a-f\]\[0-9a-f\]+ ... OK"
> +	"\[\r\n\]+\[ \]+Got thread 0x\[1-9a-f\]\[0-9a-f\]+ => \[0-9\]+ => 0x\[1-9a-f\]\[0-9a-f\]+ ... OK"
> +	"\[\r\n\]+libthread_db integrity checks passed."
> +	"\[\r\n\]+[Thread debugging using libthread_db enabled]"
> +    }
> +
> +
> +gdb_exit
> +kill_wait_spawned_process $test_spawn_id
> 

I'm surprised to not see any validation when debugging
a core dump.  Would it work?

Thanks,
Pedro Alves


  parent reply	other threads:[~2017-11-23 13:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-22 14:42 Gary Benson
2017-11-22 19:31 ` Simon Marchi
2017-11-23 13:22 ` Pedro Alves [this message]
2018-05-23 18:57 ` [PATCH v2] " Gary Benson
2018-05-23 19:21   ` Eli Zaretskii
2018-06-05 15:46     ` Gary Benson
2018-06-05 16:11       ` Eli Zaretskii
2018-05-24 14:10   ` Simon Marchi
2018-06-05 16:31   ` Pedro Alves
2018-06-08 17:25     ` [PATCH v3/pushed] " Gary Benson
2018-06-11 17:15       ` [PATCH] Fix ref in gdb.texinfo Szabolcs Nagy
2018-06-11 17:32         ` Eli Zaretskii

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=5e445a82-3238-b4d7-16c5-7e2f079ba453@redhat.com \
    --to=palves@redhat.com \
    --cc=gbenson@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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