Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
17748ecd
Unverified
Commit
17748ecd
authored
Jul 06, 2021
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cremno-mrb_debug_strdup-and-strndup'
parents
7fa0a704
7c362ee7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
22 deletions
+64
-22
mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c
mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c
+7
-11
mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c
mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c
+7
-7
mrbgems/mruby-bin-debugger/tools/mrdb/apistring.c
mrbgems/mruby-bin-debugger/tools/mrdb/apistring.c
+34
-0
mrbgems/mruby-bin-debugger/tools/mrdb/apistring.h
mrbgems/mruby-bin-debugger/tools/mrdb/apistring.h
+14
-0
mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c
mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c
+2
-4
No files found.
mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c
View file @
17748ecd
...
...
@@ -14,6 +14,7 @@
#include <mruby/variable.h>
#include "mrdberror.h"
#include "apibreak.h"
#include "apistring.h"
#define MAX_BREAKPOINTNO (MAX_BREAKPOINT * 1024)
#define MRB_DEBUG_BP_FILE_OK (0x0001)
...
...
@@ -197,7 +198,7 @@ mrb_debug_set_break_line(mrb_state *mrb, mrb_debug_context *dbg, const char *fil
}
len
=
strlen
(
file
)
+
1
;
set_file
=
(
char
*
)
mrb_malloc
(
mrb
,
len
);
set_file
=
mrb_debug_strdup
(
mrb
,
file
);
index
=
dbg
->
bpnum
;
dbg
->
bp
[
index
].
bpno
=
dbg
->
next_bpno
;
...
...
@@ -207,8 +208,6 @@ mrb_debug_set_break_line(mrb_state *mrb, mrb_debug_context *dbg, const char *fil
dbg
->
bp
[
index
].
point
.
linepoint
.
lineno
=
lineno
;
dbg
->
bpnum
++
;
strncpy
(
set_file
,
file
,
len
);
dbg
->
bp
[
index
].
point
.
linepoint
.
file
=
set_file
;
return
dbg
->
bp
[
index
].
bpno
;
...
...
@@ -220,7 +219,6 @@ mrb_debug_set_break_method(mrb_state *mrb, mrb_debug_context *dbg, const char *c
int32_t
index
;
char
*
set_class
;
char
*
set_method
;
size_t
len
;
if
((
mrb
==
NULL
)
||
(
dbg
==
NULL
)
||
(
method_name
==
NULL
))
{
return
MRB_DEBUG_INVALID_ARGUMENT
;
...
...
@@ -235,18 +233,16 @@ mrb_debug_set_break_method(mrb_state *mrb, mrb_debug_context *dbg, const char *c
}
if
(
class_name
!=
NULL
)
{
len
=
strlen
(
class_name
)
+
1
;
set_class
=
(
char
*
)
mrb_malloc
(
mrb
,
len
);
strncpy
(
set_class
,
class_name
,
len
);
set_class
=
mrb_debug_strdup
(
mrb
,
class_name
);
}
else
{
set_class
=
NULL
;
}
len
=
strlen
(
method_name
)
+
1
;
set_method
=
(
char
*
)
mrb_malloc
(
mrb
,
len
);
strncpy
(
set_method
,
method_name
,
len
);
set_method
=
mrb_debug_strdup
(
mrb
,
method_name
)
;
if
(
set_method
==
NULL
)
{
mrb_free
(
mrb
,
set_class
);
}
index
=
dbg
->
bpnum
;
dbg
->
bp
[
index
].
bpno
=
dbg
->
next_bpno
;
...
...
mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c
View file @
17748ecd
...
...
@@ -9,6 +9,7 @@
#include "mrdb.h"
#include "mrdberror.h"
#include "apilist.h"
#include "apistring.h"
#include <mruby/compile.h>
#include <mruby/irep.h>
#include <mruby/debug.h>
...
...
@@ -74,11 +75,7 @@ dirname(mrb_state *mrb, const char *path)
p
=
strrchr
(
path
,
'/'
);
len
=
p
!=
NULL
?
(
size_t
)(
p
-
path
)
:
strlen
(
path
);
dir
=
(
char
*
)
mrb_malloc
(
mrb
,
len
+
1
);
strncpy
(
dir
,
path
,
len
);
dir
[
len
]
=
'\0'
;
return
dir
;
return
mrb_debug_strndup
(
mrb
,
path
,
len
);
}
static
source_file
*
...
...
@@ -97,8 +94,11 @@ source_file_new(mrb_state *mrb, mrb_debug_context *dbg, char *filename)
}
file
->
lineno
=
1
;
file
->
path
=
(
char
*
)
mrb_malloc
(
mrb
,
strlen
(
filename
)
+
1
);
strcpy
(
file
->
path
,
filename
);
file
->
path
=
mrb_debug_strdup
(
mrb
,
filename
);
if
(
file
->
path
==
NULL
)
{
source_file_free
(
mrb
,
file
);
return
NULL
;
}
return
file
;
}
...
...
mrbgems/mruby-bin-debugger/tools/mrdb/apistring.c
0 → 100644
View file @
17748ecd
/*
** apistring.c
**
*/
#include <string.h>
#include "apistring.h"
static
size_t
mrb_debug_strnlen
(
const
char
*
s
,
size_t
maxlen
)
{
const
char
*
p
=
memchr
(
s
,
'\0'
,
maxlen
);
return
p
!=
NULL
?
(
size_t
)(
p
-
s
)
:
maxlen
;
}
char
*
mrb_debug_strndup
(
mrb_state
*
mrb
,
const
char
*
s
,
size_t
size
)
{
size_t
l
=
mrb_debug_strnlen
(
s
,
size
);
char
*
d
=
mrb_malloc_simple
(
mrb
,
l
+
1
);
if
(
d
!=
NULL
)
{
memcpy
(
d
,
s
,
l
);
d
[
l
]
=
'\0'
;
}
return
d
;
}
char
*
mrb_debug_strdup
(
mrb_state
*
mrb
,
const
char
*
s
)
{
size_t
z
=
strlen
(
s
)
+
1
;
char
*
d
=
mrb_malloc_simple
(
mrb
,
z
);
return
d
!=
NULL
?
memcpy
(
d
,
s
,
z
)
:
NULL
;
}
mrbgems/mruby-bin-debugger/tools/mrdb/apistring.h
0 → 100644
View file @
17748ecd
/*
* apistring.h
*/
#ifndef APISTRING_H_
#define APISTRING_H_
#include "mruby.h"
/* both functions return a null pointer on failure */
char
*
mrb_debug_strndup
(
mrb_state
*
mrb
,
const
char
*
s
,
size_t
size
);
char
*
mrb_debug_strdup
(
mrb_state
*
mrb
,
const
char
*
s
);
#endif
/* APISTRING_H_ */
mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c
View file @
17748ecd
...
...
@@ -8,6 +8,7 @@
#include <string.h>
#include "apilist.h"
#include "apistring.h"
#include <mruby/compile.h>
typedef
struct
help_msg
{
...
...
@@ -232,10 +233,7 @@ parse_filename(mrb_state *mrb, char **sp, listcmd_parser_state *st)
len
=
strlen
(
*
sp
);
}
if
(
len
>
0
)
{
st
->
filename
=
(
char
*
)
mrb_malloc
(
mrb
,
len
+
1
);
strncpy
(
st
->
filename
,
*
sp
,
len
);
st
->
filename
[
len
]
=
'\0'
;
if
(
len
>
0
&&
(
st
->
filename
=
mrb_debug_strndup
(
mrb
,
*
sp
,
len
))
!=
NULL
)
{
*
sp
+=
len
;
return
TRUE
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment