public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcin Slusarz <marcin.slusarz@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@zip.com.au>,
	Thomas Gleixner <tglx@linutronix.de>,
	Jason Wessel <jason.wessel@windriver.com>
Subject: Re: [3/6] kgdb: core
Date: Sun, 10 Feb 2008 13:46:45 +0100	[thread overview]
Message-ID: <20080210124629.GA12200@joi> (raw)
In-Reply-To: <20080210071331.GC3851@elte.hu>

On Sun, Feb 10, 2008 at 08:13:31AM +0100, Ingo Molnar wrote:
> +	} else {
> +		while (count-- > 0) {
> +			unsigned char ch;
> +
> +			if (probe_kernel_address(mem, ch)) {
> +				kgdb_may_fault = 0;
> +				return ERR_PTR(-EINVAL);
> +			}
> +			mem++;
> +			*buf++ = hexchars[ch >> 4];
> +			*buf++ = hexchars[ch & 0xf];
use pack_hex_byte?

> +/*
> + * While we find nice hex chars, build a long_val.
> + * Return number of chars processed.
> + */
> +int kgdb_hex2long(char **ptr, long *long_val)
> +{
> +	int hex_val;
> +	int num = 0;
> +
> +	*long_val = 0;
> +
> +	while (**ptr) {
> +		hex_val = hex(**ptr);
> +		if (hex_val >= 0) {
> +			*long_val = (*long_val << 4) | hex_val;
> +			num++;
> +		} else
> +			break;
> +
> +		(*ptr)++;
> +	}
if (hex_val < 0)
	break;
*long_val = (*long_val << 4) | hex_val;
num++;
(*ptr)++;

> +/*
> + * SW breakpoint management:
> + */
> +static int kgdb_activate_sw_breakpoints(void)
> +{
> +	unsigned long addr;
> +	int error = 0;
> +	int i;
> +
> +	for (i = 0; i < KGDB_MAX_BREAKPOINTS; i++) {
> +		if (kgdb_break[i].state != BP_SET)
> +			continue;
> +
> +		addr = kgdb_break[i].bpt_addr;
> +		error = kgdb_arch_set_breakpoint(addr,
> +				kgdb_break[i].saved_instr);
> +		if (error)
> +			return error;
> +
> +		if (CACHE_FLUSH_IS_SAFE) {
> +			if (current->mm && addr < TASK_SIZE) {
> +				flush_cache_range(current->mm->mmap_cache,
> +						addr, addr + BREAK_INSTR_SIZE);
> +			} else {
> +				flush_icache_range(addr, addr +
> +						BREAK_INSTR_SIZE);
> +			}
> +		}
unneeded braces (here and in many other places)

> +/* Handle the '?' status packets */
> +static void gdb_cmd_status(struct kgdb_state *ks)
> +{
> +	/*
> +	 * We know that this packet is only sent
> +	 * during initial connect.  So to be safe,
> +	 * we clear out our breakpoints now in case
> +	 * GDB is reconnecting.
> +	 */
> +	remove_all_break();
> +
> +	/*
> +	 * Also, if we haven't been able to roundup all
> +	 * CPUs, send an 'O' packet informing the user
> +	 * as much.  Only need to do this once.
> +	 */
> +	if (!ks->all_cpus_synced)
> +		kgdb_msg_write("Not all CPUs have been synced for KGDB\n", 39);
> +
> +	remcom_out_buffer[0] = 'S';
> +	remcom_out_buffer[1] = hexchars[ks->signo >> 4];
> +	remcom_out_buffer[2] = hexchars[ks->signo % 16];
use pack_hex_byte or & 0xf

> +		if (ks->threadid < pid_max) {
> +			kgdb_mem2hex(getthread(ks->linux_regs,
> +					ks->threadid)->comm,
> +					remcom_out_buffer, 16);
> +		} else {
> +			if (ks->threadid >= pid_max + num_online_cpus()) {
> +				kgdb_shadowinfo(ks->linux_regs,
> +					remcom_out_buffer,
> +					ks->threadid - pid_max -
> +					num_online_cpus());
> +			} else {
> +				static char tmpstr[23 + BUF_THREAD_ID_SIZE];
> +				sprintf(tmpstr, "Shadow task %d for pid 0",
> +						(int)(ks->threadid - pid_max));
> +				kgdb_mem2hex(tmpstr, remcom_out_buffer,
> +							 strlen(tmpstr));
> +			}
> +		}
if ()
else if ()
else

will look better

> +	if (*(ptr++) != ',') {
> +		error_packet(remcom_out_buffer, -EINVAL);
> +		return;
> +	} else {
no else needed

> +		if (kgdb_hex2long(&ptr, &addr)) {
> +			if (*(ptr++) != ',' ||
> +				!kgdb_hex2long(&ptr, &length)) {
> +				error_packet(remcom_out_buffer, -EINVAL);
> +				return;
> +			}
> +		} else {
> +			error_packet(remcom_out_buffer, -EINVAL);
> +			return;
> +		}
> +	}
if (!kgdb_hex2long()) {
	error_packet();
	return;
}

if (*(ptr++) (...))
(...)

Marcin

  parent reply	other threads:[~2008-02-10 12:47 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-10  7:13 [3/6] kgdb: core Ingo Molnar
2008-02-10  7:31 ` Sam Ravnborg
2008-02-10  7:59   ` Ingo Molnar
2008-02-10  7:35 ` Christoph Hellwig
2008-02-10  7:43   ` Ingo Molnar
2008-02-10  7:57     ` Christoph Hellwig
2008-02-10  8:02       ` Ingo Molnar
2008-02-10  8:21         ` Ingo Molnar
2008-02-10  8:26           ` Christoph Hellwig
2008-02-10  9:08             ` Ingo Molnar
2008-02-10  9:17               ` Ingo Molnar
2008-02-10  9:20                 ` Ingo Molnar
2008-02-10  9:34                   ` Ingo Molnar
2008-02-10  9:31                 ` Christoph Hellwig
2008-02-10 17:17                   ` [patch] kgdb light, v6 Ingo Molnar
2008-02-10 19:43                     ` Bartlomiej Zolnierkiewicz
2008-02-10 21:31                       ` Ingo Molnar
2008-02-10 20:55                     ` Bartlomiej Zolnierkiewicz
2008-02-10 21:09                       ` Ingo Molnar
2008-02-10 21:45                         ` Jan Kiszka
2008-02-10 22:14                           ` Bartlomiej Zolnierkiewicz
2008-02-10 22:32                             ` Jan Kiszka
2008-02-10 22:40                               ` Ingo Molnar
2008-02-11  2:35                                 ` Yinghai Lu
2008-02-10 22:31                           ` Ingo Molnar
2008-02-10 22:24                         ` Bartlomiej Zolnierkiewicz
2008-02-10  8:24         ` [3/6] kgdb: core Christoph Hellwig
2008-02-10  8:57           ` Ingo Molnar
2008-02-10  9:11             ` Christoph Hellwig
2008-02-10  9:27               ` Ingo Molnar
2008-02-10  9:34                 ` Christoph Hellwig
2008-02-10 17:02                   ` Ingo Molnar
2008-02-10 12:46 ` Marcin Slusarz [this message]
2008-02-10 13:19   ` Jesper Juhl
2008-02-10 14:00     ` Marcin Slusarz
2008-02-10 13:36   ` Jan Kiszka
2008-02-10 16:43   ` Ingo Molnar
2008-02-10 19:20     ` Bartlomiej Zolnierkiewicz
2008-02-10 16:46   ` Ingo Molnar

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=20080210124629.GA12200@joi \
    --to=marcin.slusarz@gmail.com \
    --cc=akpm@zip.com.au \
    --cc=jason.wessel@windriver.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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