Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jeremy Bennett <jeremy.bennett@embecosm.com>
To: gdb-patches@sourceware.org
Subject: Ping: CRC32 documentation patch
Date: Tue, 04 Aug 2009 17:36:00 -0000	[thread overview]
Message-ID: <1249407367.3284.80.camel@thomas> (raw)
In-Reply-To: <4A6B5BDD.80602@vmware.com>

This patch clarifies how CRC is calculated in the GDB manual. I think it
probably got lost in the rest of the discussion of CRC.

Any comments?

Suggested entry for the doc directory ChangeLog:

2009-07-26  Jeremy Bennett  <jeremy.bennett@embecosm.com>

	* gdb.texinfo (Separate Debug Files, Remote Protocol): Clarified
	CRC definitions.


Jeremy

-- 
Tel:      +44 (1590) 610184
Cell:     +44 (7970) 676050
SkypeID: jeremybennett
Email:   jeremy.bennett@embecosm.com
Web:     www.embecosm.com

diff -Naurp --exclude ChangeLog --exclude Entries --exclude Entries.Log
--exclude Repository --exclude Root --exclude gdb.texinfo.bak
src/gdb/doc/gdb.texinfo src-modified/gdb/doc/gdb.texinfo
--- src/gdb/doc/gdb.texinfo	2009-07-26 11:12:22.000000000 +0100
+++ src-modified/gdb/doc/gdb.texinfo	2009-07-26 15:24:38.000000000 +0100
@@ -13640,13 +13640,13 @@ file:
 @itemize @bullet
 @item
 The executable contains a @dfn{debug link} that specifies the name of
-the separate debug info file.  The separate debug file's name is
-usually @file{@var{executable}.debug}, where @var{executable} is the
-name of the corresponding executable file without leading directories
-(e.g., @file{ls.debug} for @file{/usr/bin/ls}).  In addition, the
-debug link specifies a CRC32 checksum for the debug file, which
-@value{GDBN} uses to validate that the executable and the debug file
-came from the same build.
+the separate debug info file.  The separate debug file's name is
usually
+@file{@var{executable}.debug}, where @var{executable} is the name of
the
+corresponding executable file without leading directories (e.g.,
+@file{ls.debug} for @file{/usr/bin/ls}).  In addition, the debug link
+specifies a 32-bit @dfn{Cyclic Redundancy Check} (CRC) checksum for the
+debug file, which @value{GDBN} uses to validate that the executable and
+the debug file came from the same build.
 
 @item
 The executable contains a @dfn{build ID}, a unique bit string that is
@@ -13796,10 +13796,27 @@ utilities (Binutils) package since versi
 
 @noindent
 
-Since there are many different ways to compute CRC's for the debug
-link (different polynomials, reversals, byte ordering, etc.), the
-simplest way to describe the CRC used in @code{.gnu_debuglink}
-sections is to give the complete code for a function that computes it:
+@cindex CRC algorithm definition
+The CRC used in @code{.gnu_debuglink} is the CRC-32 defined in
+IEEE 802.3 using the polynomial @math{x^{32} + x^{26} + x^{23} + x^{22}
++ x^{16} + x^{12} +x^{11} + x^{10} + x^8 + x^7 + x^5 + x^4 + x^2 + x +
+1}. The function is computed byte at a time, taking the least
+significant bit of each byte first. The initial pattern
+@code{0xffffffff} is used, to ensure leading zeros affect the CRC and
+the final result is inverted to ensure trailing zeros also affect the
+CRC.
+
+@emph{Note:} This is the same CRC polynomial as used in handling the
+@dfn{Remote Serial Protocol} @code{qCRC} packet (@pxref{Remote
Protocol,
+, @value{GDBN} Remote Serial Protocol}). However in the
+case of the Remote Serial Protocol, the CRC is computed @emph{most}
+significant bit first, and the result is not inverted, so trailing
+zeros have no effect on the CRC value.
+
+For a complete explanation the code for the function used in
+@code{.gnu_debuglink} is given here. Inverting the initially supplied
+@code{crc} argument means that an initial call to this function
+passing in zero will start computing the CRC using @code{0xffffffff}.
 
 @kindex gnu_debuglink_crc32
 @smallexample
@@ -28035,7 +28052,18 @@ Any other reply implies the old thread I
 @item qCRC:@var{addr},@var{length}
 @cindex CRC of memory block, remote request
 @cindex @samp{qCRC} packet
-Compute the CRC checksum of a block of memory.
+Compute the CRC checksum of a block of memory using CRC-32 defined in
+IEEE 802.3. The CRC is computed byte at a time, taking the most
+significant bit of each byte first. The initial pattern code
+@code{0xffffffff} is used to ensure leading zeros affect the CRC.
+
+@emph{Note:} This is the same CRC used in validating separate debug
+files (@pxref{Separate Debug Files, , Debugging Information in Separate
+Files}). However the algorithm is slightly different. When validating
+separate debug files, the CRC is computed taking the @emph{least}
+significant bit of each byte first, and the final result is inverted to
+detect trailing zeros.
+
 Reply:
 @table @samp
 @item E @var{NN}




  parent reply	other threads:[~2009-08-04 17:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-24 23:39 Add crc32 function to libiberty Ian Lance Taylor
2009-07-24 23:55 ` DJ Delorie
2009-07-25  6:16   ` Ian Lance Taylor
2009-07-25 15:13     ` Eli Zaretskii
2009-07-25 20:48       ` Michael Snyder
2009-07-25 20:51         ` Michael Snyder
2009-07-25 22:09           ` Dave Korn
2009-07-26 19:12         ` Jeremy Bennett
2009-08-04 17:36         ` Jeremy Bennett [this message]
2009-08-04 18:20           ` Ping: CRC32 documentation patch Eli Zaretskii
2009-08-05 10:24             ` Jeremy Bennett
2009-08-05 17:47               ` Eli Zaretskii
2009-07-25  0:44 ` Add crc32 function to libiberty H.J. Lu
2009-07-25  7:16   ` Ian Lance Taylor
2009-07-26 12:30     ` Frank Ch. Eigler
2009-07-25  7:27 ` 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=1249407367.3284.80.camel@thomas \
    --to=jeremy.bennett@embecosm.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