This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: setting a breakpoint on a dll, relative path or absolute path issue[solved with a patch]


Sounds like I have fix this problem by using the patches below.
(I'm sorry I'm only a beginner of git, so correct me if I'm wrong)




gdb/linespec.c | 3 ++- gdb/source.c | 48 +++++++++++++++++++++++++++--------------------- gdb/utils.c | 24 ++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 22 deletions(-)

diff --git a/gdb/linespec.c b/gdb/linespec.c
index c820539..c8251c5 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1211,7 +1211,8 @@ locate_first_half (char **argptr, int *is_quote_enclosed)
quotes we do not break on enclosed spaces. */
if (!*p
|| p[0] == '\t'
- || (p[0] == ':')
+ || ((p[0] == ':')
+ && ((p[1] == ':') || (strchr (p + 1, ':') == NULL)))
|| ((p[0] == ' ') && !*is_quote_enclosed))
break;
if (p[0] == '.' && strchr (p, ':') == NULL)
diff --git a/gdb/source.c b/gdb/source.c
index 70890e1..77dc249 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -149,7 +149,7 @@ get_lines_to_list (void)


 /* Return the current source file for listing and next line to list.
    NOTE: The returned sal pc and end fields are not valid.  */
-
+
 struct symtab_and_line
 get_current_source_symtab_and_line (void)
 {
@@ -160,7 +160,7 @@ get_current_source_symtab_and_line (void)
   cursal.line = current_source_line;
   cursal.pc = 0;
   cursal.end = 0;
-
+
   return cursal;
 }

@@ -171,7 +171,7 @@ get_current_source_symtab_and_line (void)
process of determining a new default may call the caller!
Use get_current_source_symtab_and_line only to get whatever
we have without erroring out or trying to get a default. */
-
+
void
set_default_source_symtab_and_line (void)
{
@@ -187,7 +187,7 @@ set_default_source_symtab_and_line (void)
(the returned sal pc and end fields are not valid.)
and set the current default to whatever is in SAL.
NOTE: The returned sal pc and end fields are not valid. */
-
+
struct symtab_and_line
set_current_source_symtab_and_line (const struct symtab_and_line *sal)
{
@@ -702,7 +702,7 @@ is_regular_file (const char *name)
the actual file opened (this string will always start with a "/"). We
have to take special pains to avoid doubling the "/" between the directory
and the file, sigh! Emacs gets confuzzed by this when we print the
- source file name!!!
+ source file name!!!


If a file is found, return the descriptor.
Otherwise, return -1, with errno set for the last name we tried to open. */
@@ -924,7 +924,7 @@ substitute_path_rule_matches (const struct substitute_path_rule *rule,
/* Make sure that the region in the path that matches the substitution
rule is immediately followed by a directory separator (or the end of
string character). */
-
+
if (path[from_len] != '\0' && !IS_DIR_SEPARATOR (path[from_len]))
return 0;


@@ -948,17 +948,17 @@ get_substitute_path_rule (const char *path)
/* If the user specified a source path substitution rule that applies
to PATH, then apply it and return the new path. This new path must
be deallocated afterwards.
-
+
Return NULL if no substitution rule was specified by the user,
or if no rule applied to the given PATH. */
-
+
static char *
rewrite_source_path (const char *path)
{
const struct substitute_path_rule *rule = get_substitute_path_rule (path);
char *new_path;
int from_len;
-
+
if (rule == NULL)
return NULL;


@@ -985,7 +985,7 @@ rewrite_source_path (const char *path)
      Space for the path must have been malloc'd.  If a path substitution
      is applied we free the old value and set a new one.

-   On Success
+   On Success
      A valid file descriptor is returned (the return value is positive).
      FULLNAME is set to the absolute path to the file just opened.
      The caller is responsible for freeing FULLNAME.
@@ -1002,6 +1002,7 @@ find_and_open_source (const char *filename,
   char *path = source_path;
   const char *p;
   int result;
+  char *lpath;

/* Quick way out if we already know its full name. */

@@ -1010,7 +1011,7 @@ find_and_open_source (const char *filename,
       /* The user may have requested that source paths be rewritten
          according to substitution rules he provided.  If a substitution
          rule applies to this path, then apply it.  */
-      char *rewritten_fullname = rewrite_source_path (*fullname);
+      char *rewritten_fullname = rewrite_source_path (*fullname);

       if (rewritten_fullname != NULL)
         {
@@ -1020,7 +1021,12 @@ find_and_open_source (const char *filename,

result = open (*fullname, OPEN_MODE);
if (result >= 0)
- return result;
+ {
+ lpath = gdb_realpath(*fullname);
+ xfree(*fullname);
+ *fullname = lpath;
+ return result;
+ }
/* Didn't work -- free old one, try again. */
xfree (*fullname);
*fullname = NULL;
@@ -1038,7 +1044,7 @@ find_and_open_source (const char *filename,
make_cleanup (xfree, rewritten_dirname);
dirname = rewritten_dirname;
}
-
+
/* Replace a path entry of $cdir with the compilation directory
name. */
#define cdir_len 5
@@ -1072,7 +1078,7 @@ find_and_open_source (const char *filename,
filename = rewritten_filename;
}
}
-
+
result = openp (path, OPF_SEARCH_IN_PATH, filename, OPEN_MODE, fullname);
if (result < 0)
{
@@ -1086,8 +1092,8 @@ find_and_open_source (const char *filename,
}


 /* Open a source file given a symtab S.  Returns a file descriptor or
-   negative number for error.
-
+   negative number for error.
+
    This function is a convience function to find_and_open_source.  */

 int
@@ -1159,7 +1165,7 @@ find_source_lines (struct symtab *s, int desc)
   {
     struct cleanup *old_cleanups;

- /* st_size might be a large type, but we only support source files whose
+ /* st_size might be a large type, but we only support source files whose
size fits in an int. */
size = (int) st.st_size;


@@ -1773,7 +1779,7 @@ show_substitute_path_command (char *args, int from_tty)
struct substitute_path_rule *rule = substitute_path_rules;
char **argv;
char *from = NULL;
-
+
argv = gdb_buildargv (args);
make_cleanup_freeargv (argv);


@@ -1843,7 +1849,7 @@ unset_substitute_path_command (char *args, int from_tty)

       rule = next;
     }
-
+
   /* If the user asked for a specific rule to be deleted but
      we could not find it, then report an error.  */

@@ -1860,7 +1866,7 @@ set_substitute_path_command (char *args, int from_tty)
 {
   char **argv;
   struct substitute_path_rule *rule;
-
+
   argv = gdb_buildargv (args);
   make_cleanup_freeargv (argv);

@@ -1884,7 +1890,7 @@ set_substitute_path_command (char *args, int from_tty)
   rule = find_substitute_path_rule (argv[0]);
   if (rule != NULL)
     delete_substitute_path_rule (rule);
-
+
   /* Insert the new substitution rule.  */

   add_substitute_path_rule (argv[0], argv[1]);
diff --git a/gdb/utils.c b/gdb/utils.c
index d10669a..14944da 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -3442,6 +3442,30 @@ gdb_realpath (const char *filename)
   }
 #endif

+  /* The MS Windows method.  If we don't have realpath, we assume we
+     don't have symlinks and just canonicalize to a Windows absolute
+     path.  GetFullPath converts ../ and ./ in relative paths to
+     absolute paths, filling in current drive if one is not given
+     or using the current directory of a specified drive (eg, "E:foo").
+     It also converts all forward slashes to back slashes.  */
+#if defined (_WIN32)
+  {
+    char buf[MAX_PATH];
+    char* basename;
+    DWORD len = GetFullPathName (filename, MAX_PATH, buf, &basename);
+    if (len == 0 || len > MAX_PATH - 1)
+      return xstrdup (filename);
+    else
+      {
+    /* The file system is case-preserving but case-insensitive,
+       Canonicalize to lowercase, using the codepage associated
+       with the process locale.  */
+        CharLowerBuff (buf, len);
+        return xstrdup (buf);
+      }
+  }
+#endif
+
   /* This system is a lost cause, just dup the buffer.  */
   return xstrdup (filename);
 }



asmwarrior
ollydbg from codeblocks' forum


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]