diff -cp .pc/symdb_enhance_libcpp/libcpp/directives.c libcpp/directives.c
*** .pc/symdb_enhance_libcpp/libcpp/directives.c	Mon Oct 17 17:59:12 2011
--- libcpp/directives.c	Fri May 25 14:56:56 2012
*************** _cpp_handle_directive (cpp_reader *pfile
*** 492,497 ****
--- 492,499 ----
    else if (skip == 0)
      _cpp_backup_tokens (pfile, 1);
  
+   if (pfile->cb.end_directive)
+     pfile->cb.end_directive (pfile);
    end_directive (pfile, skip);
    if (was_parsing_args && !pfile->state.in_deferred_pragma)
      {
diff -cp .pc/symdb_enhance_libcpp/libcpp/internal.h libcpp/internal.h
*** .pc/symdb_enhance_libcpp/libcpp/internal.h	Mon Jan  9 16:48:43 2012
--- libcpp/internal.h	Fri May 25 14:56:56 2012
*************** struct _cpp_line_note
*** 291,296 ****
--- 291,301 ----
       intervening space, 0 represents a note that has already been handled,
       and anything else is invalid.  */
    unsigned int type;
+ 
+   /* file offset adjustment is recorded by add_line_note to adjust
+    * cpp_token::file_offset. The case is when some spaces are left after an
+    * escaped newline `\', cpp_token::file_offset becomes inexact. */
+   const unsigned char *adjust_offset;
  };
  
  /* Represents the contents of a file cpplib has read in.  */
diff -cp .pc/symdb_enhance_libcpp/libcpp/lex.c libcpp/lex.c
*** .pc/symdb_enhance_libcpp/libcpp/lex.c	Thu Dec  8 06:05:59 2011
--- libcpp/lex.c	Fri May 25 14:56:56 2012
*************** static const struct token_spelling token
*** 51,57 ****
  #define TOKEN_SPELL(token) (token_spellings[(token)->type].category)
  #define TOKEN_NAME(token) (token_spellings[(token)->type].name)
  
! static void add_line_note (cpp_buffer *, const uchar *, unsigned int);
  static int skip_line_comment (cpp_reader *);
  static void skip_whitespace (cpp_reader *, cppchar_t);
  static void lex_string (cpp_reader *, cpp_token *, const uchar *);
--- 51,58 ----
  #define TOKEN_SPELL(token) (token_spellings[(token)->type].category)
  #define TOKEN_NAME(token) (token_spellings[(token)->type].name)
  
! static void add_line_note (cpp_buffer *, const uchar *, unsigned int,
! 			   const uchar *);
  static int skip_line_comment (cpp_reader *);
  static void skip_whitespace (cpp_reader *, cppchar_t);
  static void lex_string (cpp_reader *, cpp_token *, const uchar *);
*************** cpp_ideq (const cpp_token *token, const 
*** 82,88 ****
  /* Record a note TYPE at byte POS into the current cleaned logical
     line.  */
  static void
! add_line_note (cpp_buffer *buffer, const uchar *pos, unsigned int type)
  {
    if (buffer->notes_used == buffer->notes_cap)
      {
--- 83,90 ----
  /* Record a note TYPE at byte POS into the current cleaned logical
     line.  */
  static void
! add_line_note (cpp_buffer *buffer, const uchar *pos, unsigned int type,
! 	       const uchar * offset)
  {
    if (buffer->notes_used == buffer->notes_cap)
      {
*************** add_line_note (cpp_buffer *buffer, const
*** 93,98 ****
--- 95,101 ----
  
    buffer->notes[buffer->notes_used].pos = pos;
    buffer->notes[buffer->notes_used].type = type;
+   buffer->notes[buffer->notes_used].adjust_offset = offset;
    buffer->notes_used++;
  }
  
*************** _cpp_clean_line (cpp_reader *pfile)
*** 689,695 ****
  		{
  		  /* Have a trigraph.  We may or may not have to convert
  		     it.  Add a line note regardless, for -Wtrigraphs.  */
! 		  add_line_note (buffer, s, s[2]);
  		  if (CPP_OPTION (pfile, trigraphs))
  		    {
  		      /* We do, and that means we have to switch to the
--- 692,698 ----
  		{
  		  /* Have a trigraph.  We may or may not have to convert
  		     it.  Add a line note regardless, for -Wtrigraphs.  */
! 		  add_line_note (buffer, s, s[2], 0);
  		  if (CPP_OPTION (pfile, trigraphs))
  		    {
  		      /* We do, and that means we have to switch to the
*************** _cpp_clean_line (cpp_reader *pfile)
*** 734,740 ****
  
        /* Have an escaped newline; process it and proceed to
  	 the slow path.  */
!       add_line_note (buffer, p - 1, p != d ? ' ' : '\\');
        d = p - 2;
        buffer->next_line = p - 1;
  
--- 737,743 ----
  
        /* Have an escaped newline; process it and proceed to
  	 the slow path.  */
!       add_line_note (buffer, p - 1, p != d ? ' ' : '\\', s + 1);
        d = p - 2;
        buffer->next_line = p - 1;
  
*************** _cpp_clean_line (cpp_reader *pfile)
*** 759,772 ****
  	      if (p == buffer->next_line || p[-1] != '\\')
  		break;
  
! 	      add_line_note (buffer, p - 1, p != d ? ' ': '\\');
  	      d = p - 2;
  	      buffer->next_line = p - 1;
  	    }
  	  else if (c == '?' && s[1] == '?' && _cpp_trigraph_map[s[2]])
  	    {
  	      /* Add a note regardless, for the benefit of -Wtrigraphs.  */
! 	      add_line_note (buffer, d, s[2]);
  	      if (CPP_OPTION (pfile, trigraphs))
  		{
  		  *d = _cpp_trigraph_map[s[2]];
--- 762,775 ----
  	      if (p == buffer->next_line || p[-1] != '\\')
  		break;
  
! 	      add_line_note (buffer, p - 1, p != d ? ' ': '\\', s + 1);
  	      d = p - 2;
  	      buffer->next_line = p - 1;
  	    }
  	  else if (c == '?' && s[1] == '?' && _cpp_trigraph_map[s[2]])
  	    {
  	      /* Add a note regardless, for the benefit of -Wtrigraphs.  */
! 	      add_line_note (buffer, d, s[2], 0);
  	      if (CPP_OPTION (pfile, trigraphs))
  		{
  		  *d = _cpp_trigraph_map[s[2]];
*************** _cpp_clean_line (cpp_reader *pfile)
*** 789,795 ****
   done:
    *d = '\n';
    /* A sentinel note that should never be processed.  */
!   add_line_note (buffer, d + 1, '\n');
    buffer->next_line = s + 1;
  }
  
--- 792,798 ----
   done:
    *d = '\n';
    /* A sentinel note that should never be processed.  */
!   add_line_note (buffer, d + 1, '\n', s + 1);
    buffer->next_line = s + 1;
  }
  
*************** _cpp_lex_token (cpp_reader *pfile)
*** 1886,1891 ****
--- 1889,1896 ----
  		 handles the directive as normal.  */
  	      && pfile->state.parsing_args != 1)
  	    {
+ 	      if (pfile->cb.start_directive)
+ 		pfile->cb.start_directive (pfile, result);
  	      if (_cpp_handle_directive (pfile, result->flags & PREV_WHITE))
  		{
  		  if (pfile->directive_result.type == CPP_PADDING)
*************** _cpp_lex_direct (cpp_reader *pfile)
*** 2032,2037 ****
--- 2037,2053 ----
        _cpp_process_line_notes (pfile, false);
        result->src_loc = pfile->line_table->highest_line;
      }
+   if (buffer->cur_note != 0)
+     {
+       int index = buffer->cur_note - 1;
+       result->file_offset = buffer->cur - buffer->buf;
+       result->file_offset +=
+ 	buffer->notes[index].adjust_offset - buffer->notes[index].pos;
+     }
+   else
+     {
+       result->file_offset = buffer->cur - buffer->buf;
+     }
    c = *buffer->cur++;
  
    if (pfile->forced_token_location_p)
*************** _cpp_lex_direct (cpp_reader *pfile)
*** 2346,2351 ****
--- 2362,2369 ----
        break;
      }
  
+   if (pfile->cb.directive_token)
+     pfile->cb.directive_token (pfile, result);
    return result;
  }
  
diff -cp .pc/symdb_enhance_libcpp/libcpp/macro.c libcpp/macro.c
*** .pc/symdb_enhance_libcpp/libcpp/macro.c	Mon Jan  9 22:15:25 2012
--- libcpp/macro.c	Fri May 25 14:56:56 2012
*************** enter_macro_context (cpp_reader *pfile, 
*** 1029,1037 ****
--- 1029,1041 ----
  	      if (pragma_buff)
  		_cpp_release_buff (pfile, pragma_buff);
  
+ 	      if (pfile->cb.macro_end_arg)
+ 		pfile->cb.macro_end_arg (pfile, true);
  	      return 0;
  	    }
  
+ 	  if (pfile->cb.macro_end_arg)
+ 	    pfile->cb.macro_end_arg (pfile, false);
  	  if (macro->paramc > 0)
  	    replace_args (pfile, node, macro,
  			  (macro_arg *) buff->base,
*************** cpp_get_token_1 (cpp_reader *pfile, sour
*** 2263,2268 ****
--- 2267,2274 ----
  	  if (pfile->context->c.macro)
  	    ++num_expanded_macros_counter;
  	  _cpp_pop_context (pfile);
+ 	  if (pfile->cb.macro_end_expand)
+ 	    pfile->cb.macro_end_expand (pfile);
  	  if (pfile->state.in_directive)
  	    continue;
  	  result = &pfile->avoid_paste;
*************** cpp_get_token_1 (cpp_reader *pfile, sour
*** 2321,2328 ****
  		}
  	    }
  	  else
! 	    ret = enter_macro_context (pfile, node, result, 
! 				       virt_loc);
  	  if (ret)
   	    {
  	      if (pfile->state.in_directive || ret == 2)
--- 2327,2340 ----
  		}
  	    }
  	  else
!   	    {
!  	      if (pfile->cb.macro_start_expand)
!  		pfile->cb.macro_start_expand (pfile, result, node);
!  	  ret = enter_macro_context (pfile, node, result, virt_loc);
!      if (ret == 0 && pfile->cb.macro_end_expand)
!        /* macro expansion is canceled. */
!        pfile->cb.macro_end_expand (pfile);
!  	    }
  	  if (ret)
   	    {
  	      if (pfile->state.in_directive || ret == 2)
