Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug improvements #2602

Merged
merged 3 commits into from
Jul 4, 2018
Merged

Debug improvements #2602

merged 3 commits into from
Jul 4, 2018

Conversation

ChrisJefferson
Copy link
Contributor

This PR:

a) Fixes MEMORY_CANARY and adds a configure option for it.

b) Adds some awful, but at least existing, documentation for kernel debugging (further improvements / extensions welcome).

@codecov
Copy link

codecov bot commented Jul 2, 2018

Codecov Report

Merging #2602 into master will increase coverage by <.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #2602      +/-   ##
==========================================
+ Coverage    74.8%    74.8%   +<.01%     
==========================================
  Files         479      479              
  Lines      242243   242243              
==========================================
+ Hits       181198   181200       +2     
+ Misses      61045    61043       -2
Impacted Files Coverage Δ
src/gasman.c 87.84% <ø> (ø) ⬆️
hpcgap/lib/hpc/stdtasks.g 64.7% <0%> (+0.51%) ⬆️

doc/dev/lib.xml Outdated
<Section Label="Sect-debugging">
<Heading>Debugging the GAP Kernel</Heading>

The GAP kernel supports a variety of options which enabled when running <C>configure</C>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GAP should be &GAP; throughout because as an entity it is displayed in a different font (as a <Package element).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required: This sentence seems to be missing a word, like "which can be enabled by running" ? Or maybe reorder the sentence for readability (and use the appropriate XML for filenames):

The GAP kernel supports a variety of compile-time options to help writing and debugging GAP kernel code.
They can be enabled by passing one or more of the following options to the configure script.

doc/dev/lib.xml Outdated
the Configuration line when GAP is started.
<P/>

Known bugs: GAP will crash if IO_fork is called while memory checking is enabled.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IO_fork should be a cross-reference to the IO package manual.

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two changes in the last commit really should be made, the rest is optional.

src/gasman.c Outdated
#define CANARY_ENABLE_VALGRIND() VALGRIND_ENABLE_ERROR_REPORTING

void CHANGED_BAG(Bag bag) {
CANARY_DISABLE_VALGRIND();

This comment was marked as resolved.

configure.ac Outdated
[AC_DEFINE([MEMORY_CANARY], [1], [define if build with valgrind extensions])],
[enable_valgrind=no]
)
AC_MSG_CHECKING([whether to add valgrind extensions to GASMAN])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: Instead of "add" here and above, I'd use "enable", to match the name of the option. Also, to me "add" has the wrong meaning here, but that's probably just me being a non-native speaker.

configure.ac Outdated
@@ -246,6 +246,18 @@ AC_ARG_ENABLE([memory-checking],
AC_MSG_CHECKING([whether to enable memory checking])
AC_MSG_RESULT([$enable_memory_checking])

AC_ARG_ENABLE([valgrind],
[AS_HELP_STRING([--enable-valgrind], [add valgrind extensions to GASMAN])],
[AC_DEFINE([MEMORY_CANARY], [1], [define if build with valgrind extensions])],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: build -> built? Though everywhere else, we actually use "building"

configure.ac Outdated
AS_IF([test "x$enable_valgrind" != "xno" -a "x$enable_memory_checking" != "xno"],
AC_MSG_ERROR([--enable-valgrind and --enable-memory-checking cannot be used at the same time])
)

This comment was marked as resolved.

doc/dev/lib.xml Outdated
<Section Label="Sect-debugging">
<Heading>Debugging the GAP Kernel</Heading>

The GAP kernel supports a variety of options which enabled when running <C>configure</C>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required: This sentence seems to be missing a word, like "which can be enabled by running" ? Or maybe reorder the sentence for readability (and use the appropriate XML for filenames):

The GAP kernel supports a variety of compile-time options to help writing and debugging GAP kernel code.
They can be enabled by passing one or more of the following options to the configure script.

doc/dev/lib.xml Outdated
<P/>

After configuring, the memory checking must still be turned on. This can be done
either by passing <C>--</C> to GAP's command line, or calling <C>GASMAN_MEM_CHECK(1)</C>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required: Shouldn't that -- be --enableMemCheck?

doc/dev/lib.xml Outdated
assertions are implemented using the <C>GAP_ASSERT</C> macro. These
assertions are disabled when GAP is compiled without <C>--enable-debug</C>.
When <C>--enable-debug</C> is enabled, <C>KernelDebug</C> will be shown in
the Configuration line when GAP is started.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: Why is Configuration in upper case? If it is meant to "quote" the output of GAP, I'd mark it as such, e.g.

the line starting with Configuration: when &GAP; is started.
Else, I'd use lower case. Same below.

doc/dev/lib.xml Outdated
corruption relating to GASMAN (GAP's memory manager). They cannot both be enabled
at the same time.
<P/>
<C>--enable-memory-checking</C> makes GAP check for C pointers to the content of Bags
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd not capitalize "Bag" here, though one might want to insert an explanation of what a bag is. Then again, it makes little sense to use this option if one does not know what a GAP "bag" is. Perhaps Insert in the previous line something like this:

The following explanations assume you are somewhat familiar with the internals of GASMAN (see e.g. src/gasman.c for more information).

doc/dev/lib.xml Outdated

At present, this <C>--enable-valgrind</C> only checks for invalid writes to the
last bag which was created. Also, this option does not do anything unless GAP
is run through Valgrind (for example by running <C>valgrind ./gap</C>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is Valgrind capitalized here but not above?

doc/dev/lib.xml Outdated
<P/>

<C>--enable-valgrind</C> makes changes to GASMAN so it is compatible with the
valgrind memory checking program. Without this, valgrind will report many
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: How about adding a URL here?

<URL Text="valgrind">http://valgrind.org</URL> memory checking program. Without this [...]

@ChrisJefferson ChrisJefferson force-pushed the debug-doc branch 3 times, most recently from 284b4d4 to 5062251 Compare July 3, 2018 12:07
@ChrisJefferson
Copy link
Contributor Author

All improvements seem good, so I have made all of them. The documentation should still be significantly improved, but at least something exists now.

The only change I didn't make was cross-linking to IO_fork because for some reason I was getting errors I didn't understand, and making to the dev manual is quite annoying as it takes so long to run make doc.

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be merged now, though I still left two optional suggestions

at the same time.

These options assume you are familiar somewhat familiar with the internals of GASMAN
(see gasman.c for more information). In particular, GASMAN represents memory using
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strictly speaking, this should be <F>gasman.c</F>. But can also be changed later.

doc/dev/lib.xml Outdated
the line starting <C>Configuration:</C> when &GAP; is started.
<P/>

Known bugs: &GAP; will crash if IO_fork is called while memory checking is enabled.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is not a ref for technical reasons, then shouldn't it at least be <C>IO_fork</C>? And perhaps add "from the IO package"?

@fingolfin fingolfin merged commit 7da3eb1 into gap-system:master Jul 4, 2018
@ChrisJefferson ChrisJefferson deleted the debug-doc branch August 20, 2018 10:06
@fingolfin fingolfin added topic: kernel release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes labels Sep 13, 2018
@fingolfin
Copy link
Member

As these are low-level kernel changes, I don't think this needs to be documented in the release notes... But I am not 100% certain (it depends on how exactly we define what should and what shouldn't go into release notes.... and at whom we target them: end-users only? Or also kernel devs? Thoughts?

@fingolfin fingolfin removed the release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes label Sep 13, 2018
@olexandr-konovalov olexandr-konovalov added the release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes label Sep 13, 2018
@olexandr-konovalov
Copy link
Member

Since this adds a new section "Debugging the GAP Kernel" to the manual, I would add to release notes some text conveniently linking it to that section.

@fingolfin fingolfin added release notes: added PRs introducing changes that have since been mentioned in the release notes and removed release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Sep 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: added PRs introducing changes that have since been mentioned in the release notes topic: kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants